diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/.cvsignore | 1 | ||||
-rw-r--r-- | tools/2isdndb.pm | 6 | ||||
-rw-r--r-- | tools/Makefile | 41 | ||||
-rw-r--r-- | tools/alpha/cd/Makefile | 6 | ||||
-rw-r--r-- | tools/alpha/cd/README | 9 | ||||
-rw-r--r-- | tools/alpha/cd/aboot.cnf | 6 | ||||
-rwxr-xr-x | tools/alpha/cd/up1000/apb.cfg | 4 | ||||
-rwxr-xr-x | tools/closurepkgs | 58 | ||||
-rw-r--r-- | tools/ddcprobe/Makefile | 10 | ||||
-rw-r--r-- | tools/ddcprobe/lrmi.c | 2 | ||||
-rwxr-xr-x | tools/gencompss | 6 | ||||
-rwxr-xr-x | tools/make_mdkinst_stage2 | 47 | ||||
-rwxr-xr-x | tools/syncrpms | 157 |
13 files changed, 262 insertions, 91 deletions
diff --git a/tools/.cvsignore b/tools/.cvsignore index e570b13fa..21a6d396b 100644 --- a/tools/.cvsignore +++ b/tools/.cvsignore @@ -1,2 +1,3 @@ rpm2header gendepslist +xhost+ diff --git a/tools/2isdndb.pm b/tools/2isdndb.pm index 4b0f9d8f7..536808706 100644 --- a/tools/2isdndb.pm +++ b/tools/2isdndb.pm @@ -2,16 +2,18 @@ open F, "isdndb.txt" or die "file $file not found"; open G, ">tutu" or die "file $file not found"; foreach (<F>) { s/\#.*//; - s/\[City\]\s+National//; +# s/\[City\]\s+National//; /\[Country\]\s*(.*)/ and $country = $1; /\[City\]\s*(.*)/ and $city = $1; /\[Name\]\s*(.*)/ and $name = $1; /\[Prefix\]\s*(.*)/ and $prefix = $1; /\[ISDN\]\s*(.*)/ and $isdn = $1; + /\[Encaps\]\s*.*/ and do { defined $dns1 and $dns2=""; }; /\[Domain\]\s*(.*)/ and $domain = $1; /\[DNS\]\s*(.*)/ and ($dns1 ? $dns2 : $dns1) = $1; + /\[End\]\s*(.*)/ and do { undef $name; undef $prefix; undef $isdn; undef $domain; undef $dns1; undef $dns2; }; if ($isdn && !$prefix) { $prefix = "" } - if (defined $name && defined $prefix && defined $isdn && defined $domain && defined $dns1 && defined $dns2) { + if (defined $name && defined $isdn && defined $domain && defined $dns1 && defined $dns2) { print G join("|", $country, $city, join("=>", $name, $prefix . $isdn, $domain, $dns1, $dns2)), "\n"; undef $name; undef $prefix; diff --git a/tools/Makefile b/tools/Makefile index c76c5fc6d..375ed0551 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,25 +1,38 @@ ROOTDEST = /export +DEST = $(ROOTDEST)/Mandrake/mdkinst +RPMS = $(wildcard $(ROOTDEST)/Mandrake/RPMS/*.rpm) +DIRS = ddcprobe serial_probe BASE = $(ROOTDEST)/Mandrake/base +CFLAGS = -Wall -ALL = gendepslist rpm2header -.PHONY: clean install +.PHONY: clean install $(DIRS) + +all: $(BASE)/depslist.ordered $(BASE)/filelist $(BASE)/compss $(DIRS) xhost+ install + +$(DIRS): + make -C $@ install: - $(MAKE) gendepslist rpm2header - install make_mdkinst_stage2 gendepslist rpm2header genhdlist $(ROOTDEST)/misc + install make_mdkinst_stage2 $(ROOTDEST)/misc + cd /usr/bin ; install packdrake $(ROOTDEST)/misc || { echo "packdrake is missing"; exit 1; } + cd /usr/bin ; install genbasefiles rpm2header genhdlist_cz2 $(ROOTDEST)/misc || { echo "install rpmtools first!" ; exit 1; } + mkdir -p $(DEST)/usr/bin + +xhost+: %: %.c + $(CC) $(CFLAGS) $< -L/usr/X11R6/lib -lX11 -o $@ -gendepslist: %: %.cc - $(CXX) -I/usr/include/rpm $(CFLAGS) $< -lrpm -ldb1 -lz -o $@ +ddcprobe/ddcxinfos: + $(MAKE) -C ddcprobe ddcxinfos -rpm2header: %: %.c - $(CC) -I/usr/include/rpm $(CFLAGS) $< -lrpm -ldb1 -lz -o $@ +$(BASE)/compss $(BASE)/depslist.ordered: $(BASE)/hdlists $(BASE)/hdlist.cz + genbasefiles $(BASE) `cat $< | perl -pe 's|^(\S*).*|'$(BASE)'/$$1|' ` -$(BASE)/depslist: $(BASE)/hdlist gendepslist - ./gendepslist -h $@ $< +$(BASE)/filelist: $(RPMS) +# genfilelist $(ROOTDEST)/Mandrake/RPMS* >$@ -$(BASE)/hdlist: $(RPMS) - $(MAKE) install - ./genhdlist $(ROOTDEST) +$(BASE)/hdlist.cz: $(BASE)/hdlists $(RPMS) + genhdlists --noclean --distrib $(ROOTDEST) clean: - rm -rf *~ gendepslist rpm2header + for i in $(DIRS); do $(MAKE) -C $$i clean; done + rm -rf *~ xhost+ ddcprobe/ddcxinfos */*.o diff --git a/tools/alpha/cd/Makefile b/tools/alpha/cd/Makefile index c5235660b..67af70f2f 100644 --- a/tools/alpha/cd/Makefile +++ b/tools/alpha/cd/Makefile @@ -1,4 +1,8 @@ install: - cp -f README $(ROOTDEST) + cp -f README README.milo $(ROOTDEST) install -d $(ROOTDEST)/etc cp -f aboot.cnf $(ROOTDEST)/etc + + install -d $(ROOTDEST)/boot + cp -a up1000 $(ROOTDEST)/boot + mv -f $(ROOTDEST)/boot/up1000/apb.* $(ROOTDEST) diff --git a/tools/alpha/cd/README b/tools/alpha/cd/README index 98dc50fda..78eb94bd5 100644 --- a/tools/alpha/cd/README +++ b/tools/alpha/cd/README @@ -1,6 +1,9 @@ !! beta version !! -Mandrake Alpha short Howto-Install : +Mandrake Alpha short Howto-Install + +this doc is for SRM, if you have alphabios, see README.milo + * to install from the cdrom: @@ -20,8 +23,8 @@ Mandrake Alpha short Howto-Install : the system - if the device is not available via SRM, use the -cdrom: `boot -file boot/v.gz -root /dev/sda1' (replace sda1 by the -root you installed on) +cdrom: `boot dqa0 -file boot/v.gz -fl root=/dev/sda1' (replace sda1 by the +root you installed on, and dqa0 by the cdrom device) * to install from the network: diff --git a/tools/alpha/cd/aboot.cnf b/tools/alpha/cd/aboot.cnf index 4ddaaf949..42c7a4382 100644 --- a/tools/alpha/cd/aboot.cnf +++ b/tools/alpha/cd/aboot.cnf @@ -1,3 +1,3 @@ -0:boot/instboot.gz initrd=boot/cdrom.rdz mdkinst rw ramdisk=32000 -1:boot/instboot.gz initrd=boot/network.rdz mdkinst rw ramdisk=32000 -2:boot/instboot.gz initrd=boot/hd.rdz mdkinst rw ramdisk=32000 +0:boot/instboot.gz initrd=boot/cdrom.rdz mdkinst rw ramdisk=32000 cdrom +1:boot/instboot.gz initrd=boot/network.rdz mdkinst rw ramdisk=32000 network +2:boot/instboot.gz initrd=boot/hd.rdz mdkinst rw ramdisk=32000 hd diff --git a/tools/alpha/cd/up1000/apb.cfg b/tools/alpha/cd/up1000/apb.cfg index 366e42bb4..06614adcb 100755 --- a/tools/alpha/cd/up1000/apb.cfg +++ b/tools/alpha/cd/up1000/apb.cfg @@ -1,2 +1,2 @@ -floppy|bootl boot/up1000/up1000.pal boot/instboot.gz root=/dev/fd0 load_ramdisk=1 mdkinst rw ramdisk_size=32000 -floppy_text|bootl boot/up1000/up1000.pal boot/instboot.gz root=/dev/fd0 load_ramdisk=1 mdkinst rw ramdisk_size=32000 text +floppy|bootl boot\up1000\up1000.pal boot\instboot.gz root=/dev/fd0 load_ramdisk=1 mdkinst rw ramdisk_size=32000 +floppy_text|bootl boot\up1000\up1000.pal boot\instboot.gz root=/dev/fd0 load_ramdisk=1 mdkinst rw ramdisk_size=32000 text diff --git a/tools/closurepkgs b/tools/closurepkgs index dccd41977..f060d1b29 100755 --- a/tools/closurepkgs +++ b/tools/closurepkgs @@ -27,26 +27,66 @@ sub read_depslist { $depslist; } -sub main { +sub read_compsslist { my ($file) = @_; - my $depslist = read_depslist($file); + my %compsslist; + + local *F; + open F, $file or die "closurepkgs: unable to open compsslist file $file\n"; + foreach (<F>) { + my ($name, $level) = /^\s*(\S+)\s+(\d+)/; + $compsslist{$name} = $level; + } + close F; + + \%compsslist; +} + +sub main { + my ($depslist_file, $compsslist_file) = @_; + my $depslist = read_depslist($depslist_file); + my $compsslist = read_compsslist($compsslist_file); - my @pkgs = qw(XFree86 dhcpcd pump ppp ypbind rhs-printfilters samba ncpfs kernel-fb); + my @pkgs = qw(XFree86 XFree86-server XFree86-glide-module Device3Dfx Glide_V3-DRI Glide_V5 Mesa dhcpcd pump dhcpxd dhcp-client isdn4net isdn4k-utils dev pptp-adsl-fr rp-pppoe ppp ypbind rhs-printfilters lpr cups cups-drivers samba ncpfs); push @pkgs, "XFree86-$_" foreach qw(3DLabs 3dfx 8514 AGX FBDev I128 Mach8 Mach32 Mach64 Mono P9000 Rage128 S3 S3V SVGA VGA16 W32); + #- closure the list of package to be kept for oem. my %closure; foreach (@pkgs) { $closure{$_} = 1; - map { $closure{chop_version($_->{name})} = 1 } map { ($depslist->{ordered}[$_]) } @{$depslist->{packages}{$_}{deps}}; + map { $closure{chop_version($_->{name})} = 1 } map { $depslist->{ordered}[$_] } map { split /\|/ } @{$depslist->{packages}{$_}{deps}}; } - #- remove base package, which are already installed. - foreach (qw(basesystem sed initscripts console-tools utempter ldconfig chkconfig ntsysv setup filesystem SysVinit bdflush crontabs dev e2fsprogs etcskel fileutils findutils getty_ps grep gzip hdparm info kernel less ldconfig logrotate losetup man mingetty modutils mount net-tools passwd procmail procps psmisc mandrake-release rootfiles rpm sash ash setserial shadow-utils sh-utils stat sysklogd tar termcap textutils time tmpwatch util-linux vim-minimal vixie-cron which perl-base msec)) { - delete $closure{$_}; - map { delete $closure{chop_version($_->{name})} } map { ($depslist->{ordered}[$_]) } @{$depslist->{packages}{$_}{deps}}; + #- closure the list of package to always install for oem. (level >= 50)... + my %install; + foreach (grep { $compsslist->{$_} >= 70 } keys %{$depslist->{packages}}) { + $install{$_} = 1; + map { $install{chop_version($_->{name})} = 1 } map { $depslist->{ordered}[$_] } map { split /\|/ } @{$depslist->{packages}{$_}{deps}}; + } + + #- remove base packages, which have to be installed, according to basesystem. + delete $closure{'basesystem'}; + $install{'basesystem'} = 1; + map { delete $closure{chop_version($_->{name})}; + $install{chop_version($_->{name})} = 1 } map { $depslist->{ordered}[$_] } map { split /\|/ } @{$depslist->{packages}{'basesystem'}{deps}}; + + #- special packages that are to be move to closure always ... + foreach (qw(kernel-smp kernel-linus kernel-secure hackkernel-smp hackkernel-linus hackkernel-secure)) { + $depslist->{packages}{$_} or next; + $closure{$_} = 1; + delete $install{$_}; } - map { print $depslist->{packages}{$_}{name}, "\n" } grep { $closure{$_} } keys %closure; + #- dump out the list of package according to the 2 lists defined above. + my $total_install = 0; + map { $total_install += $depslist->{packages}{$_}{size}; + delete $closure{$_}; + print "I:", $depslist->{packages}{$_}{name}, "\n" } grep { $depslist->{packages}{$_} } keys %install; + my $total_closure = 0; + map { $total_closure += $depslist->{packages}{$_}{size}; + print "C:", $depslist->{packages}{$_}{name}, "\n" } grep { $depslist->{packages}{$_} } keys %closure; + print "\n\ntotal_install=$total_install\n"; + print "total_closure=$total_closure\n"; } main(@ARGV); diff --git a/tools/ddcprobe/Makefile b/tools/ddcprobe/Makefile index e2bf84011..07ba43786 100644 --- a/tools/ddcprobe/Makefile +++ b/tools/ddcprobe/Makefile @@ -1,6 +1,11 @@ CFLAGS=-Wall -O # -g -DDEBUG TARGETS=ddcxinfos +ARCH := $(patsubst i%86,i386,$(shell uname -m)) +ARCH := $(patsubst sparc%,sparc,$(ARCH)) + +ifeq (i386,$(ARCH)) + ddcxinfos: lrmi.o vesamode.o vbe.o ddcxinfos.o libvbe.a: lrmi.o vesamode.o vbe.o @@ -14,5 +19,10 @@ $(DESTDIR)/usr/include/vbe.h: $(DESTDIR)/usr/lib/libvbe.a: install -m 644 libvbe.a $(DESTDIR)/usr/lib/libvbe.a +else +ddcxinfos: not_handled.c + gcc -o $@ $< +endif + clean: $(RM) $(TARGETS) *.o core diff --git a/tools/ddcprobe/lrmi.c b/tools/ddcprobe/lrmi.c index ca8af0a1e..e7e25ce2e 100644 --- a/tools/ddcprobe/lrmi.c +++ b/tools/ddcprobe/lrmi.c @@ -727,7 +727,7 @@ static int lrmi_vm86(struct vm86_struct *vm) { int r; -#ifdef __PIC__ +#if 1 asm volatile ( "pushl %%ebx\n\t" "movl %2, %%ebx\n\t" diff --git a/tools/gencompss b/tools/gencompss index b26ef7c2c..b12328e49 100755 --- a/tools/gencompss +++ b/tools/gencompss @@ -1,14 +1,14 @@ #!/usr/bin/perl -open F, "bzip2 -dc @ARGV 2>/dev/null | hdlist2groups - |"; +open F, "packdrake -c @ARGV | hdlist2groups - |"; foreach (<F>) { chop; /(.*):(.*)/; - push @{$l{$2}}, $1; + $l{$2}{$1} = undef; } close F or die; foreach (sort keys %l) { print "$_\n"; - print "\t$_\n" foreach sort @{$l{$_}}; + print "\t$_\n" foreach sort keys %{$l{$_}}; print "\n"; } diff --git a/tools/make_mdkinst_stage2 b/tools/make_mdkinst_stage2 index 724808dd7..97b989e93 100755 --- a/tools/make_mdkinst_stage2 +++ b/tools/make_mdkinst_stage2 @@ -6,13 +6,21 @@ exit } -STAGE2TMP=/tmp/stage2_tmp +TMPDIR=${TMPDIR=/tmp} +STAGE2TMP=$TMPDIR/stage2_tmp MKE2FS="/sbin/mke2fs -q -m 0 -F -s 1" -MNTPOINT=/tmp/stage2_img +MNTPOINT=$TMPDIR/stage2_img REP4PMS=/usr/bin/perl-install DEST=$1 STAGE2=$2 +testandset() { [ -x $1/packdrake ] && BUILD_ARCHIVE=$1/packdrake; } +testandset `pwd`/misc +testandset `pwd`/. +testandset /$DEST/../../misc +testandset `pwd`/$DEST/../../misc +[ -z "$BUILD_ARCHIVE" ] && { echo "can't find packdrake"; exit 1; } + if [ $EUID != "0" ]; then SUDO="sudo" PATH="/sbin:/usr/sbin:$PATH" @@ -22,21 +30,42 @@ $SUDO rm -rf $STAGE2TMP install -d $STAGE2TMP $SUDO cp -a $DEST/* $STAGE2TMP +#mkdir -p $MNTPOINT 2>/dev/null +#for i in $MNTPOINT $STAGE2; do $SUDO umount $i 2>/dev/null ; done +#dd if=/dev/zero of=$STAGE2 bs=1k count=24000 +#$MKE2FS -N 1000 $STAGE2 +#$SUDO mount -t ext2 $STAGE2 $MNTPOINT -o loop +# hack to reduce the STAGE2 image (do not edit without modifying in DrakX) +# be sure to keep the biggest server +rm -f $STAGE2TMP/usr/X11R6/bin/XF86_{VGA16,3DLabs,TGA,S3} +rm -f $STAGE2TMP/$REP4PMS/po/DrakX.pot +#for i in /usr/share/locale; do \ +# name=`basename $i` ; \ +# (cd $STAGE2TMP/$i ; find * | cpio -o 2>/dev/null | bzip2 > ../$name.cpio.bz2 ; cd .. ; rm -rf $name) \ +#done +for i in /usr/share/locale; do + name=`basename $i` + (cd $STAGE2TMP/$i ; find * | $BUILD_ARCHIVE -b9s ../$name.cz2 4000000) + rm -rf $STAGE2TMP/$i +done +for i in /usr/share/keymaps /usr/share/xmodmap $REP4PMS/po; do + name=`basename $i` + (cd $STAGE2TMP/$i ; ls * | $BUILD_ARCHIVE -b9s ../$name.cz2 400000) + rm -rf $STAGE2TMP/$i +done + + + mkdir -p $MNTPOINT 2>/dev/null for i in $MNTPOINT $STAGE2; do $SUDO umount $i 2>/dev/null ; done -dd if=/dev/zero of=$STAGE2 bs=1M count=15 +dd if=/dev/zero of=$STAGE2 bs=1k count=$[ `du -s $STAGE2TMP | cut -f1` + 1024 ] $MKE2FS -N 1000 $STAGE2 $SUDO mount -t ext2 $STAGE2 $MNTPOINT -o loop -# hack to reduce the STAGE2 image (do not edit without modifying in DrakX) -rm $STAGE2TMP/usr/X11R6/bin/XF86_VGA16 -for i in /usr/share/locale /usr/share/keymaps /usr/share/xmodmap $REP4PMS/po; do \ - name=`basename $i` ; \ - (cd $STAGE2TMP/$i ; find * | cpio -o 2>/dev/null | bzip2 > ../$name.cpio.bz2 ; cd .. ; rm -rf $name) \ -done $SUDO cp -a $STAGE2TMP/* $MNTPOINT $SUDO rm -rf $STAGE2TMP +df $MNTPOINT $SUDO umount $STAGE2 rmdir $MNTPOINT diff --git a/tools/syncrpms b/tools/syncrpms index 1c7eea761..ccb806d6c 100755 --- a/tools/syncrpms +++ b/tools/syncrpms @@ -28,7 +28,7 @@ sub version_compare { my ($a, $b) = @_; local $_; - while ($a && $b) { + while ($a || $b) { my ($sb, $sa) = map { $1 if $a =~ /^\W*\d/ ? s/^\W*0*(\d+)// : s/^\W*(\D+)// } ($b, $a); $_ = length($sa) cmp length($sb) || $sa cmp $sb and return $_; } @@ -43,6 +43,14 @@ sub cp { exec '/bin/cp', @_; } } +sub mv { + my $pid; + if ($pid = fork()) { + waitpid($pid, 0); + } else { + exec '/bin/mv', @_; + } +} sub rm { my $pid; if ($pid = fork()) { @@ -54,39 +62,57 @@ sub rm { #- get a hash on name of srpms/rpms in a directory. sub get_rpms { - my ($dir, $rpms, $flag) = @_; + my ($dir, $rpms, $flag, $modifiable) = @_; opendir D, $dir or die "cannot open directory $dir\n"; map { - if (/([^\/]*?)-([^-]*)-([^-]*)\.([^-]*)(?:\.src)?\.rpm$/) { - if ($rpms->{$1}) { - if (version_compare($rpms->{$1}{version}, $2) > 0 || - version_compare($rpms->{$1}{version}, $2) == 0 && version_compare($rpms->{$1}{release}, $3) > 0) { - if ($flag->{clean}) { - print "removing obseleted $rpms->{$1}{file} by $_ in $rpms->{$1}{dir}\n" if $flag->{verbose}; - rm("$rpms->{$1}{dir}/$rpms->{$1}{file}"); + if (/([^\/]*?)-([^-]*)-([^-]*)\.([^-\.]*)\.rpm$/) { + my $key = "$1 $4"; #- get name including architecture. + if ($rpms->{$key}) { + if (version_compare($2, $rpms->{$key}{version}) > 0 || + version_compare($2, $rpms->{$key}{version}) == 0 && version_compare($3, $rpms->{$key}{release}) > 0) { + if ($modifiable) { + if ($flag->{sorted}) { + print "you said rpms directory are sorted, so I keep obseleted $rpms->{$key}{file} by $_ in $rpms->{$key}{dir}\n" if $flag->{verbose}; + } else { + if (-d $flag->{conflict}) { + print "moving obseleted $rpms->{$key}{file} by $_ in $rpms->{$key}{dir}\n" if $flag->{verbose}; + mv("$rpms->{$key}{dir}/$rpms->{$key}{file}", $flag->{conflict}); + } elsif ($flag->{clean}) { + print "removing obseleted $rpms->{$key}{file} by $_ in $rpms->{$key}{dir}\n" if $flag->{verbose}; + rm("$rpms->{$key}{dir}/$rpms->{$key}{file}"); + } + } } - $rpms->{$1} = { name => $1, - version => $2, - release => $3, - arch => $4, - dir => $dir, - file => $_, - }; + $rpms->{$key} = { key => $key, + name => $1, + version => $2, + release => $3, + arch => $4, + dir => $dir, + file => $_, + }; } else { - if ($flag->{clean}) { - print "removing older or equal $_ by $rpms->{$1}{file} in $dir\n" if $flag->{verbose}; - rm("$dir/$_"); + if ($modifiable) { + if (-d $flag->{conflict}) { + print "copying older or equal $_ by $rpms->{$key}{file} in $flag->{conflict}\n" if $flag->{verbose}; + cp("$dir/$_", $flag->{conflict}); + chmod 0644, "$flag->{conflict}/$_"; + } elsif ($flag->{clean}) { + print "removing older or equal $_ by $rpms->{$key}{file} in $dir\n" if $flag->{verbose}; + rm("$dir/$_"); + } } } } else { - $rpms->{$1} = { name => $1, - version => $2, - release => $3, - arch => $4, - dir => $dir, - file => $_, - }; + $rpms->{$key} = { key => $key, + name => $1, + version => $2, + release => $3, + arch => $4, + dir => $dir, + file => $_, + }; } } else { print STDERR "unable to parse filename $_\n"; @@ -95,6 +121,39 @@ sub get_rpms { closedir D; } +#- sync packages list according to hashes of rpms. +sub sync_medium { + my ($rpmsdirs, $list, $rpms, $flag) = @_; + my %pkg2dir; + + #- build a hash according to rpmsdirs and list for package name. + my $i = 0; + foreach (@$list) { + local *F; + open F, $_ or die "unable to open packages list file \"$_\"\n"; + foreach (<F>) { + chomp; + print STDERR "package \"$_\" is listed in mulitple list files!\n" if $pkg2dir{$_}; + $pkg2dir{$_} = $rpmsdirs->[$i]; + print "package \"$_\" listed in list files does not exists in rpms directory\n" if $flag->{verbose} && !$rpms->{$_}; + } + close F; + + ++$i; + } + + #- check for right directory, and move if necessary. + foreach (values %$rpms) { + unless ($pkg2dir{$_->{key}}) { + print "file $_->{file} in $_->{dir} define package \"$_->{name}\" not listed in list files\n" if $flag->{verbose}; + } elsif ($_->{dir} ne $pkg2dir{$_->{key}}) { + print "moving file $_->{file} in $_->{dir} to $pkg2dir{$_->{key}}\n" if $flag->{verbose}; + mv("$_->{dir}/$_->{file}", $pkg2dir{$_->{key}}); + $_->{dir} = $pkg2dir{$_->{key}}; + } + } +} + #- sync two hashes of rpms, update rpms and printer newer version that are not taken into account. sub sync_rpms { my ($source, $target, $flag) = @_; @@ -107,6 +166,7 @@ sub sync_rpms { } if (-d $flag->{add}) { cp("$source->{$_}{dir}/$source->{$_}{file}", $flag->{add}); + chmod 0644, "$flag->{add}/$source->{$_}{file}"; } } } @@ -122,15 +182,16 @@ sub sync_rpms { } if ($flag->{update}) { cp("$source->{$_}{dir}/$source->{$_}{file}", $target->{$_}{dir}); + chmod 0644, "$target->{$_}{dir}/$source->{$_}{file}"; unless (-e "$target->{$_}{dir}/$source->{$_}{file}") { die "unable to copy $source->{$_}{file} from $source->{$_}{dir} into $target->{$_}{dir}\n"; } - rm("$target->{$_}{dir}/$target->{$_}{file}"); + rm("$target->{$_}{dir}/$target->{$_}{file}") unless $source->{$_}{file} eq $target->{$_}{file}; #- copy on eq } } elsif (version_compare($source->{$_}{version}, $target->{$_}{version}) != 0 || version_compare($source->{$_}{release}, $target->{$_}{release}) != 0) { if ($flag->{verbose}) { - print STDERR "keeping more up-to-date version $target->{$_}{dir}/$source->{$_}{file} against $source->{$_}{dir}/$source->{$_}{file}, check your repository !\n"; + print STDERR "keeping more up-to-date version $target->{$_}{dir}/$target->{$_}{file} against $source->{$_}{dir}/$source->{$_}{file}, check your repository !\n"; } } #- say nothing if source is equal to target. } @@ -140,8 +201,9 @@ sub sync_rpms { foreach (keys %$target) { unless ($source->{$_}) { if ($flag->{verbose}) { - print "removing $target->{$_}{file}" . ($flag->{remove} ? " from $target->{$_}{dir}\n" : " is neccessary!\n") - } + print "removing $target->{$_}{file}" . ($flag->{remove} ? " from $target->{$_}{dir}\n" : " is neccessary!\n"); + my $k = $_; + } if ($flag->{remove}) { rm("$target->{$_}{dir}/$target->{$_}{file}"); } @@ -153,21 +215,24 @@ sub sync_rpms { sub main { my @from_rpms; my @to_rpms; - my $target_rpms; + my @list; + my $target; my %flag; my %source; my %target; foreach (@_) { if (/^--(\w*)$/) { - if ($1 eq 'verbose' || $1 eq 'update' || $1 eq 'remove' || $1 eq 'clean') { + if ($1 eq 'verbose' || $1 eq 'update' || $1 eq 'remove' || $1 eq 'clean' || $1 eq 'sorted') { $flag{$1} = 1; - } elsif ($1 eq 'add') { - $flag{add} = undef; + } elsif ($1 eq 'add' || $1 eq 'conflict') { + $flag{$1} = undef; } elsif ($1 eq 'from') { - $target_rpms = \@from_rpms; + $target = \@from_rpms; } elsif ($1 eq 'to') { - $target_rpms = \@to_rpms; + $target = \@to_rpms; + } elsif ($1 eq 'list') { + $target = \@list; } else { die "unknown option: $1\n"; } @@ -175,26 +240,30 @@ sub main { if (exists $flag{add} && ! $flag{add}) { $flag{add} = $_; die "cannot add to non-directory: $_\n" unless -d $flag{add}; + } elsif (exists $flag{conflict} && ! $flag{conflict}) { + $flag{conflict} = $_; + die "cannot add to non-directory: $_\n" unless -d $flag{conflict}; } else { - die "unknown parameter: $_\n" unless $target_rpms; - push @$target_rpms, $_; + die "unknown parameter: $_\n" unless $target; + push @$target, $_; } } } - die "usage: syncrpms [--update] [--remove] [--clean] [--add <dir>] --from <dir_sources> --to <dir_target>\n" - unless scalar(@from_rpms) > 0 && scalar(@to_rpms) > 0; + die "usage: syncrpms [--update] [--remove] [--clean] [--sorted] [--add <dir>] [--conflict <dir>] --from <dir_sources> --to <dir_targets> [--list <files>]\n" + unless scalar(@from_rpms) > 0 || scalar(@to_rpms) > 0; #- parse directory structures. - get_rpms($_, \%source, \%flag) foreach @from_rpms; - get_rpms($_, \%target, \%flag) foreach @to_rpms; - + get_rpms($_, \%source, \%flag, 0) foreach @from_rpms; print STDERR "reading " . scalar(keys %source) . " packages as source rpms from\n"; print STDERR " $_\n" foreach @from_rpms; + + get_rpms($_, \%target, \%flag, 1) foreach @to_rpms; print STDERR "reading " . scalar(keys %target) . " packages as target rpms from\n"; print STDERR " $_\n" foreach @to_rpms; - sync_rpms(\%source, \%target, \%flag); + sync_medium(\@to_rpms, \@list, \%target, \%flag) if scalar(@list) > 0 && scalar(@to_rpms) > 0; + sync_rpms(\%source, \%target, \%flag) if scalar(@from_rpms) > 0 && scalar(@to_rpms) > 0; } main(@ARGV); |