aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2002-06-06 09:57:52 +0000
committerFrancois Pons <fpons@mandriva.com>2002-06-06 09:57:52 +0000
commit507d79f646464f20a758ca8a41a3638c8ac4fc83 (patch)
tree1cbe2579e78736e64fee257cdabb3990b0889f1d
parent977a0031a904f6690d377d184a5461f639d49201 (diff)
downloadperl-URPM-507d79f646464f20a758ca8a41a3638c8ac4fc83.tar
perl-URPM-507d79f646464f20a758ca8a41a3638c8ac4fc83.tar.gz
perl-URPM-507d79f646464f20a758ca8a41a3638c8ac4fc83.tar.bz2
perl-URPM-507d79f646464f20a758ca8a41a3638c8ac4fc83.tar.xz
perl-URPM-507d79f646464f20a758ca8a41a3638c8ac4fc83.zip
0.03-1mdk
-rw-r--r--URPM.pm2
-rw-r--r--URPM.xs146
-rwxr-xr-xbuild_rpm1
-rw-r--r--perl-URPM.spec14
4 files changed, 136 insertions, 27 deletions
diff --git a/URPM.pm b/URPM.pm
index fbb8735..5d712cf 100644
--- a/URPM.pm
+++ b/URPM.pm
@@ -6,7 +6,7 @@ use vars qw($VERSION @ISA);
require DynaLoader;
@ISA = qw(DynaLoader);
-$VERSION = '0.02';
+$VERSION = '0.03';
bootstrap URPM $VERSION;
diff --git a/URPM.xs b/URPM.xs
index 2ccff09..bbbebb9 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -31,7 +31,6 @@ struct s_Package {
char *conflicts;
char *provides;
char *rates;
- int id;
unsigned flag;
Header h;
};
@@ -39,11 +38,18 @@ struct s_Package {
typedef rpmdb URPM__DB;
typedef struct s_Package* URPM__Package;
-#define FLAG_SELECTED 0x00ffffff
-#define FLAG_FORCE 0x01000000
-#define FLAG_INSTALLED 0x02000000
-#define FLAG_BASE 0x04000000
-#define FLAG_UPGRADE 0x20000000
+#define FLAG_ID 0x00ffffffU
+#define FLAG_BASE 0x01000000U
+#define FLAG_FORCE 0x02000000U
+#define FLAG_INSTALLED 0x04000000U
+#define FLAG_REQUESTED 0x08000000U
+#define FLAG_REQUIRED 0x10000000U
+#define FLAG_UPGRADE 0x20000000U
+#define FLAG_RESERVED 0x40000000U
+#define FLAG_NO_HEADER_FREE 0x80000000U
+
+#define FLAG_ID_MAX 0x00fffffe
+#define FLAG_ID_INVALID 0x00ffffff
#define FILENAME_TAG 1000000
#define FILESIZE_TAG 1000001
@@ -330,8 +336,7 @@ pack_header(URPM__Package pkg) {
if (pkg->provides == NULL)
pkg->provides = pack_list(pkg->h, RPMTAG_PROVIDENAME, RPMTAG_PROVIDEFLAGS, RPMTAG_PROVIDEVERSION);
- /* free header if it is not an iteration (id < 0) and remove reference to it */
- if (pkg->id != -1) headerFree(pkg->h);
+ if (!(pkg->flag & FLAG_NO_HEADER_FREE)) headerFree(pkg->h);
pkg->h = 0;
}
}
@@ -355,7 +360,7 @@ update_provide_entry(char *name, STRLEN len, int force, URPM__Package pkg, HV *p
}
if (isv && *isv != &PL_sv_undef) {
char id[8];
- STRLEN id_len = snprintf(id, sizeof(id), "%d", pkg->id);
+ STRLEN id_len = snprintf(id, sizeof(id), "%d", pkg->flag & FLAG_ID);
hv_fetch((HV*)SvRV(*isv), id, id_len, 1);
}
}
@@ -529,8 +534,8 @@ open_archive(char *filename, pid_t *pid) {
lseek(fd, 0, SEEK_SET);
dup2(fd, STDIN_FILENO); close(fd);
dup2(fdno[1], STDOUT_FILENO); close(fdno[1]);
- /*fd = open("/dev/null", O_WRONLY);
- dup2(fd, STDERR_FILENO); close(fd);*/
+ fd = open("/dev/null", O_WRONLY);
+ dup2(fd, STDERR_FILENO); close(fd);
execvp(unpacker[0], unpacker);
exit(1);
}
@@ -553,7 +558,8 @@ parse_line(AV *depslist, HV *provides, URPM__Package pkg, char *buff) {
data_len = 1+strlen(data);
if (!strcmp(tag, "info")) {
pkg->info = memcpy(malloc(data_len), data, data_len);
- pkg->id = 1 + av_len(depslist);
+ pkg->flag &= ~FLAG_ID;
+ pkg->flag |= 1 + av_len(depslist);
if (provides) update_provides(pkg, provides);
av_push(depslist, sv_setref_pv(newSVpv("", 0), "URPM::Package",
memcpy(malloc(sizeof(struct s_Package)), pkg, sizeof(struct s_Package))));
@@ -594,7 +600,7 @@ Pkg_DESTROY(pkg)
free(pkg->conflicts);
free(pkg->provides);
free(pkg->rates);
- if (pkg->h && pkg->id != -1) headerFree(pkg->h);
+ if (pkg->h && !(pkg->flag & FLAG_NO_HEADER_FREE)) headerFree(pkg->h);
free(pkg);
void
@@ -970,8 +976,8 @@ void
Pkg_id(pkg)
URPM::Package pkg
PPCODE:
- if (pkg->id >= 0) {
- XPUSHs(sv_2mortal(newSViv(pkg->id)));
+ if ((pkg->flag & FLAG_ID) <= FLAG_ID_MAX) {
+ XPUSHs(sv_2mortal(newSViv(pkg->flag & FLAG_ID)));
}
void
@@ -979,10 +985,11 @@ Pkg_set_id(pkg, id=-1)
URPM::Package pkg
int id
PPCODE:
- if (pkg->id >= 0) {
- XPUSHs(sv_2mortal(newSViv(pkg->id)));
+ if ((pkg->flag & FLAG_ID) <= FLAG_ID_MAX) {
+ XPUSHs(sv_2mortal(newSViv(pkg->flag & FLAG_ID)));
}
- pkg->id = id >= 0 ? id : -2; /* -1 should not be used since it marks non freeable header */
+ pkg->flag &= ~FLAG_ID;
+ pkg->flag |= id >= 0 && id <= FLAG_ID_MAX ? id : FLAG_ID_INVALID;
void
Pkg_requires(pkg)
@@ -1173,6 +1180,101 @@ Pkg_set_flag_base(pkg, value=1)
OUTPUT:
RETVAL
+int
+Pkg_flag_force(pkg)
+ URPM::Package pkg
+ CODE:
+ RETVAL = pkg->flag & FLAG_FORCE;
+ OUTPUT:
+ RETVAL
+
+int
+Pkg_set_flag_force(pkg, value=1)
+ URPM::Package pkg
+ int value
+ CODE:
+ RETVAL = pkg->flag & FLAG_FORCE;
+ if (value) pkg->flag |= FLAG_FORCE;
+ else pkg->flag &= ~FLAG_FORCE;
+ OUTPUT:
+ RETVAL
+
+int
+Pkg_flag_installed(pkg)
+ URPM::Package pkg
+ CODE:
+ RETVAL = pkg->flag & FLAG_INSTALLED;
+ OUTPUT:
+ RETVAL
+
+int
+Pkg_set_flag_installed(pkg, value=1)
+ URPM::Package pkg
+ int value
+ CODE:
+ RETVAL = pkg->flag & FLAG_INSTALLED;
+ if (value) pkg->flag |= FLAG_INSTALLED;
+ else pkg->flag &= ~FLAG_INSTALLED;
+ OUTPUT:
+ RETVAL
+
+int
+Pkg_flag_requested(pkg)
+ URPM::Package pkg
+ CODE:
+ RETVAL = pkg->flag & FLAG_REQUESTED;
+ OUTPUT:
+ RETVAL
+
+int
+Pkg_set_flag_requested(pkg, value=1)
+ URPM::Package pkg
+ int value
+ CODE:
+ RETVAL = pkg->flag & FLAG_REQUESTED;
+ if (value) pkg->flag |= FLAG_REQUESTED;
+ else pkg->flag &= ~FLAG_REQUESTED;
+ OUTPUT:
+ RETVAL
+
+int
+Pkg_flag_required(pkg)
+ URPM::Package pkg
+ CODE:
+ RETVAL = pkg->flag & FLAG_REQUIRED;
+ OUTPUT:
+ RETVAL
+
+int
+Pkg_set_flag_required(pkg, value=1)
+ URPM::Package pkg
+ int value
+ CODE:
+ RETVAL = pkg->flag & FLAG_REQUIRED;
+ if (value) pkg->flag |= FLAG_REQUIRED;
+ else pkg->flag &= ~FLAG_REQUIRED;
+ OUTPUT:
+ RETVAL
+
+int
+Pkg_flag_upgrade(pkg)
+ URPM::Package pkg
+ CODE:
+ RETVAL = pkg->flag & FLAG_UPGRADE;
+ OUTPUT:
+ RETVAL
+
+int
+Pkg_set_flag_upgrade(pkg, value=1)
+ URPM::Package pkg
+ int value
+ CODE:
+ RETVAL = pkg->flag & FLAG_UPGRADE;
+ if (value) pkg->flag |= FLAG_UPGRADE;
+ else pkg->flag &= ~FLAG_UPGRADE;
+ OUTPUT:
+ RETVAL
+
MODULE = URPM PACKAGE = URPM::DB PREFIX = Db_
@@ -1229,7 +1331,7 @@ Db_traverse(db,callback)
dSP;
URPM__Package pkg = calloc(1, sizeof(struct s_Package));
- pkg->id = -1; /* this is not a real package where header should not be freed */
+ pkg->flag = FLAG_ID_INVALID | FLAG_NO_HEADER_FREE;
pkg->h = header;
ENTER;
@@ -1293,7 +1395,7 @@ Db_traverse_tag(db,tag,names,callback)
dSP;
URPM__Package pkg = calloc(1, sizeof(struct s_Package));
- pkg->id = -1; /* this is not a real package where header should not be freed */
+ pkg->flag = FLAG_ID_INVALID | FLAG_NO_HEADER_FREE;
pkg->h = header;
ENTER;
@@ -1417,7 +1519,7 @@ Urpm_parse_hdlist(urpm, filename, packing=0)
struct s_Package pkg;
memset(&pkg, 0, sizeof(struct s_Package));
- pkg.id = 1 + av_len(depslist);
+ pkg.flag = 1 + av_len(depslist);
pkg.h = header;
if (provides) {
update_provides(&pkg, provides);
@@ -1473,7 +1575,7 @@ Urpm_parse_rpm(urpm, filename, packing=0)
headerAddEntry(header, FILESIZE_TAG, RPM_INT32_TYPE, &size, 1);
memset(&pkg, 0, sizeof(struct s_Package));
- pkg.id = 1 + av_len(depslist);
+ pkg.flag = 1 + av_len(depslist);
pkg.h = header;
if (provides) {
update_provides(&pkg, provides);
diff --git a/build_rpm b/build_rpm
index c52078c..aa4c794 100755
--- a/build_rpm
+++ b/build_rpm
@@ -4,6 +4,7 @@ RPM=`rpm --eval '%{_topdir}'`
[ -d "$RPM/SPECS" -a -d "$RPM/SOURCES" ] || exit 1
VERSION=`perl -ne '/VERSION\s+=[^0-9\.]*([0-9\.]+)/ and print "$1\n"' URPM.pm`
+perl -pi -e 's/^%define\s+version\s+(\S+)/%define version '$VERSION'/' perl-URPM.spec
echo "building URPM version $VERSION"
diff --git a/perl-URPM.spec b/perl-URPM.spec
index 96176e6..00bc8e5 100644
--- a/perl-URPM.spec
+++ b/perl-URPM.spec
@@ -1,8 +1,9 @@
%define name perl-URPM
%define real_name URPM
-%define release 3mdk
+%define version 0.03
+%define release 1mdk
-%{expand:%%define version %(perl -ne '/VERSION\s+=[^0-9\.]*([0-9\.]+)/ and print "$1\n"' URPM.pm)}
+%{expand:%%define rpm_version %(rpm -q --queryformat '%{VERSION}-%{RELEASE}' rpm)}
Packager: François Pons <fpons@mandrakesoft.com>
Summary: URPM module for perl
@@ -14,9 +15,9 @@ Group: Development/Perl
Distribution: Mandrake Linux
Source: %{real_name}-%{version}.tar.bz2
Prefix: %{_prefix}
-BuildRequires: perl-devel
+BuildRequires: perl-devel rpm-devel >= 4.0.3 bzip2-devel gcc
+Requires: perl >= 5.601 rpm >= %{rpm_version} bzip2 >= 1.0
BuildRoot: %{_tmppath}/%{name}-buildroot
-Requires: perl >= 5.601
%description
The URPM module allows you to manipulate rpm files, rpm header files and
@@ -47,6 +48,11 @@ rm -rf $RPM_BUILD_ROOT
%changelog
+* Thu Jun 6 2002 François Pons <fpons@mandrakesoft.com> 0.03-1mdk
+- added more flag method to URPM::Package
+- avoid garbage output when reading hdlist archive.
+- moved id internal reference to bit field of flag.
+
* Wed Jun 5 2002 François Pons <fpons@mandrakesoft.com> 0.02-3mdk
- removed log on opening/closing rpmdb.
- modified reading of archive to avoid incomplete read.