From 556bef47d4bc1ea2a59021aaa88ba1f499f4a727 Mon Sep 17 00:00:00 2001 From: Wichert Akkerman Date: Mon, 12 Jun 2000 16:17:41 +0000 Subject: [PATCH] configure.in: generate doc/sv/Makefile as well main/filesdb.c: fix logic when reading statusoverride-file scripts/.cvsignore: add all the perl scripts scripts/dpkg-divert.pl: + turn $admindir into $dpkglibdir, which the Makefile will handle + fix glob->regexp logic for --list scripts/Makefile.in: + replace one `sed' with `$(SED)' + add dpkg-statoverride scripts/dpkg-statoverride.pl: new util to manage statoverrides debian/rules: move Swedish manpages into the package as well --- ChangeLog | 14 +++ configure.in | 1 + debian/rules | 4 +- main/archives.c | 1 + main/filesdb.c | 21 +++-- po/cs.po | 2 +- po/dpkg.pot | 2 +- po/en.po | 2 +- po/es.po | 2 +- po/fr.po | 2 +- po/it.po | 2 +- po/ja.po | 2 +- po/pl.po | 2 +- po/ru.po | 2 +- po/sv.po | 2 +- scripts/.cvsignore | 18 ++++ scripts/Makefile.in | 4 +- scripts/dpkg-divert.pl | 31 ++++--- scripts/dpkg-statoverride.pl | 166 +++++++++++++++++++++++++++++++++++ 19 files changed, 244 insertions(+), 36 deletions(-) create mode 100755 scripts/dpkg-statoverride.pl diff --git a/ChangeLog b/ChangeLog index 298dc981..ff7cfa28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Mon Jun 12 16:35:26 CEST 2000 Wichert Akkerman + + * configure.in: generate doc/sv/Makefile as well + * main/filesdb.c: fix logic when reading statusoverride-file + * scripts/.cvsignore: add all the perl scripts + * scripts/dpkg-divert.pl: + + turn $admindir into $dpkglibdir, which the Makefile will handle + + fix glob->regexp logic for --list + * scripts/Makefile.in: + + replace one `sed' with `$(SED)' + + add dpkg-statoverride + * scripts/dpkg-statoverride.pl: new util to manage statoverrides + * debian/rules: move Swedish manpages into the package as well + Fri Jun 9 15:52:28 CEST 2000 Wichert Akkerman * Merge things from the potato branch: diff --git a/configure.in b/configure.in index ba0abed0..6795061e 100644 --- a/configure.in +++ b/configure.in @@ -143,6 +143,7 @@ lib/Makefile optlib/Makefile doc/Makefile doc/ja/Makefile +doc/sv/Makefile scripts/Makefile main/Makefile dselect/Makefile diff --git a/debian/rules b/debian/rules index 22a144dd..d91bafe2 100755 --- a/debian/rules +++ b/debian/rules @@ -89,7 +89,7 @@ binary-dpkg: stamp-binary set -e ; for i in ChangeLog THANKS TODO copyright ; do \ mv $(TMP)/usr/share/doc/dpkg/$$i $(TMP_DPKG)/usr/share/doc/dpkg/ ; \ done - set -e ; for i in "" ja ; do \ + set -e ; for i in "" ja sv ; do \ install -d -m 755 -o root -g root $(TMP_DPKG)/usr/share/man/$$i/man1 ; \ for m in md5sum.1 dpkg-deb.1 ; do \ if [ -f $(TMP)/usr/share/man/$$i/man1/$$m ] ; then \ @@ -147,7 +147,7 @@ binary-dpkg-dev: stamp-binary dpkg-parsechangelog ; do \ mv $(TMP)/usr/bin/$$i $(TMP_DPKG_DEV)/usr/bin/ ; \ done - set -e ; for i in "" ja ; do \ + set -e ; for i in "" ja sv ; do \ install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share/man/$$i/man1 ; \ for m in dpkg-name.1 dpkg-source.1 822-date.1 dpkg-architecture.1 \ dpkg-buildpackage.1 dpkg-distaddfile.1 dpkg-genchanges.1 \ diff --git a/main/archives.c b/main/archives.c index 6ff310e7..0e87865b 100644 --- a/main/archives.c +++ b/main/archives.c @@ -3,6 +3,7 @@ * archives.c - actions that process archive files, mainly unpack * * Copyright (C) 1994,1995 Ian Jackson + * Copyright (C) 2000 Wichert Akkerman * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as diff --git a/main/filesdb.c b/main/filesdb.c index 0702ddea..182e130d 100644 --- a/main/filesdb.c +++ b/main/filesdb.c @@ -3,6 +3,7 @@ * filesdb.c - management of database of files installed on system * * Copyright (C) 1995 Ian Jackson + * Copyright (C) 2000 Wichert Akkerman * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -338,13 +339,15 @@ void ensure_statoverrides(void) { if (!file) { if (errno != ENOENT) ohshite(_("failed to open statoverride file")); if (!statoverridefile) { onerr_abort--; return; } - } else if (statoverridefile) { - if (fstat(fileno(statoverridefile),&stab1)) - ohshite(_("failed to fstat previous statoverride file")); + } else { if (fstat(fileno(file),&stab2)) ohshite(_("failed to fstat statoverride file")); - if (stab1.st_dev == stab2.st_dev && stab1.st_ino == stab2.st_ino) { - fclose(file); onerr_abort--; return; + if (statoverridefile) { + if (fstat(fileno(statoverridefile),&stab1)) + ohshite(_("failed to fstat previous statoverride file")); + if (stab1.st_dev == stab2.st_dev && stab1.st_ino == stab2.st_ino) { + fclose(file); onerr_abort--; return; + } } } if (statoverridefile) fclose(statoverridefile); @@ -352,12 +355,12 @@ void ensure_statoverrides(void) { push_cleanup(cu_closefile,ehflag_bombout, 0,0,1,(void*)file); - loaded_list = nfmalloc(stab1.st_size); - loaded_list_end = loaded_list + stab1.st_size; + loaded_list = nfmalloc(stab2.st_size); + loaded_list_end = loaded_list + stab2.st_size; readden=0; - while (readden\n" "Language-Team: Czech \n" diff --git a/po/dpkg.pot b/po/dpkg.pot index 86fc795c..7cc84f3f 100644 --- a/po/dpkg.pot +++ b/po/dpkg.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-06-09 16:31+0200\n" +"POT-Creation-Date: 2000-06-12 14:26+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/po/en.po b/po/en.po index 19aa13f5..b5b12c81 100644 --- a/po/en.po +++ b/po/en.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-06-09 16:31+0200\n" +"POT-Creation-Date: 2000-06-12 16:12+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/po/es.po b/po/es.po index 49d8cbbb..56995163 100644 --- a/po/es.po +++ b/po/es.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Debian dpkg 1.6.13\n" -"POT-Creation-Date: 2000-06-09 16:31+0200\n" +"POT-Creation-Date: 2000-06-12 16:12+0200\n" "PO-Revision-Date: 2000-04-23 23:50+0200\n" "Last-Translator: Santiago Vila \n" "Language-Team: Spanish \n" diff --git a/po/fr.po b/po/fr.po index b96d9279..dd10d476 100644 --- a/po/fr.po +++ b/po/fr.po @@ -19,7 +19,7 @@ msgid "" msgstr "" "Project-Id-Version: Debian dpkg 1.6.13\n" -"POT-Creation-Date: 2000-06-09 16:31+0200\n" +"POT-Creation-Date: 2000-06-12 16:12+0200\n" "PO-Revision-Date: 2000-04-29 00:48+02:00\n" "Last-Translator: Jérôme Marant \n" "Language-Team: French\n" diff --git a/po/it.po b/po/it.po index 55868ac2..a346e49c 100644 --- a/po/it.po +++ b/po/it.po @@ -37,7 +37,7 @@ msgid "" msgstr "" "Project-Id-Version: dpkg 1.6.13\n" -"POT-Creation-Date: 2000-06-09 16:31+0200\n" +"POT-Creation-Date: 2000-06-12 16:12+0200\n" "PO-Revision-Date: 2000-05-24 01:19+02:00\n" "Last-Translator: Lele Gaifax \n" "Language-Team: italian \n" diff --git a/po/ja.po b/po/ja.po index a7978916..b737a404 100644 --- a/po/ja.po +++ b/po/ja.po @@ -17,7 +17,7 @@ msgid "" msgstr "" "Project-Id-Version: 1.6.7\n" -"POT-Creation-Date: 2000-06-09 16:31+0200\n" +"POT-Creation-Date: 2000-06-12 16:12+0200\n" "PO-Revision-Date: 2000-03-04 14:39+09:00\n" "Last-Translator: Keita Maehara \n" "Language-Team: Debian Japanease List \n" diff --git a/po/pl.po b/po/pl.po index afdbcfb2..4d1a3fac 100644 --- a/po/pl.po +++ b/po/pl.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: dpkg 1.6.12\n" -"POT-Creation-Date: 2000-06-09 16:31+0200\n" +"POT-Creation-Date: 2000-06-12 16:12+0200\n" "PO-Revision-Date: 2000-04-19 16:44+0100\n" "Last-Translator: Piotr Roszatycki \n" "Language-Team: Polish\n" diff --git a/po/ru.po b/po/ru.po index 0de523b3..7a28c838 100644 --- a/po/ru.po +++ b/po/ru.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: dpkg 1.6.5\n" -"POT-Creation-Date: 2000-06-09 16:31+0200\n" +"POT-Creation-Date: 2000-06-12 16:12+0200\n" "PO-Revision-Date: $Date$\n" "Last-Translator: Michael Sobolev \n" "Language-Team: ru \n" diff --git a/po/sv.po b/po/sv.po index bc75bbcc..e949463d 100644 --- a/po/sv.po +++ b/po/sv.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: dpkg 1.6.12\n" -"POT-Creation-Date: 2000-06-09 16:31+0200\n" +"POT-Creation-Date: 2000-06-12 16:12+0200\n" "PO-Revision-Date: 2000-05-16 20:28+0200\n" "Last-Translator: Peter Karlsson \n" "MIME-Version: 1.0\n" diff --git a/scripts/.cvsignore b/scripts/.cvsignore index 8d678982..8e985cea 100644 --- a/scripts/.cvsignore +++ b/scripts/.cvsignore @@ -1,2 +1,20 @@ Makefile.in elisp-comp +822-date +cl-debian +cleanup-info +controllib +dpkg-architecture +dpkg-distaddfile +dpkg-divert +dpkg-genchanges +dpkg-gencontrol +dpkg-parsechangelog +dpkg-scanpackages +dpkg-scansources +dpkg-shlibdeps +dpkg-source +dpkg-statoverride +install-info +update-alternatives +update-rc.d diff --git a/scripts/Makefile.in b/scripts/Makefile.in index db49dd26..1a437dc9 100644 --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -10,7 +10,7 @@ BIN_SCRIPTS = dpkg-name dpkg-source dpkg-genchanges \ dpkg-scanpackages dpkg-scansources dpkg-architecture SBIN_SCRIPTS = update-rc.d update-alternatives install-info \ - dpkg-divert cleanup-info + dpkg-divert dpkg-statoverride cleanup-info MAN1PAGES = dpkg-name.1 dpkg-source.1 822-date.1 dpkg-architecture.1 MAN8PAGES = update-rc.d.8 update-alternatives.8 install-info.8 \ @@ -62,7 +62,7 @@ install-program: $(mkinstalldirs) $(DESTDIR)/$(parsechangelogdir) set -e ; for i in $(CHANGELOG_PARSERS) ; do \ if test -f $$i ; then d= ; else d="$(srcdir)/" ; fi ; \ - rn=`echo $$i | sed -e 's/^cl-//'` ; \ + rn=`echo $$i | $(SED) -e 's/^cl-//'` ; \ $(INSTALL_SCRIPT) $$d$$i $(DESTDIR)/$(parsechangelogdir)/$$rn ; \ done $(mkinstalldirs) $(DESTDIR)/$(dpkglibdir) diff --git a/scripts/dpkg-divert.pl b/scripts/dpkg-divert.pl index aa456684..7b68d61c 100755 --- a/scripts/dpkg-divert.pl +++ b/scripts/dpkg-divert.pl @@ -5,15 +5,21 @@ sub ENOENT { 2; } # Sorry about this, but the errno-part of POSIX.pm isn't in perl-*-base $version= '1.0.11'; # This line modified by Makefile +$dpkglibdir= "."; # This line modified by Makefile + sub showversion { print("Debian GNU/Linux dpkg-divert $version.\n") || &quit("failed to write version: $!"); } sub usage { &showversion; - print(STDOUT <) { s/\n$//; push(@contest,$_); $_=; s/\n$// || &badfmt("missing altname"); @@ -165,7 +170,7 @@ if ($mode eq 'add') { s/\\\*/.*/g; push(@list,"^$_\$"); } - $pat= join('$|^',@list); + $pat= join('|',@list); for ($i=0; $i<=$#contest; $i++) { next unless ($contest[$i] =~ m/$pat/o || $altname[$i] =~ m/$pat/o || @@ -229,18 +234,18 @@ sub dorename { sub save { return if $testmode; - open(N,"> $admindir/diversions-new") || &quit("create diversions-new: $!"); - chmod 0644, "$admindir/diversions-new"; + open(N,"> $dpkglibdir/diversions-new") || &quit("create diversions-new: $!"); + chmod 0644, "$dpkglibdir/diversions-new"; for ($i=0; $i<=$#contest; $i++) { print(N "$contest[$i]\n$altname[$i]\n$package[$i]\n") || &quit("write diversions-new: $!"); } close(N) || &quit("close diversions-new: $!"); - unlink("$admindir/diversions-old") || + unlink("$dpkglibdir/diversions-old") || $! == &ENOENT || &quit("remove old diversions-old: $!"); - link("$admindir/diversions","$admindir/diversions-old") || + link("$dpkglibdir/diversions","$dpkglibdir/diversions-old") || $! == &ENOENT || &quit("create new diversions-old: $!"); - rename("$admindir/diversions-new","$admindir/diversions") + rename("$dpkglibdir/diversions-new","$dpkglibdir/diversions") || &quit("install new diversions: $!"); } @@ -249,4 +254,4 @@ sub infon { &infol($contest[$i],$altname[$i],$package[$i]); } sub quit { print STDERR "dpkg-divert: @_\n"; exit(2); } sub badusage { print STDERR "dpkg-divert: @_\n\n"; print("You need --help.\n"); exit(2); } -sub badfmt { &quit("internal error: $admindir/diversions corrupt: $_[0]"); } +sub badfmt { &quit("internal error: $dpkglibdir/diversions corrupt: $_[0]"); } diff --git a/scripts/dpkg-statoverride.pl b/scripts/dpkg-statoverride.pl new file mode 100755 index 00000000..8e3a6266 --- /dev/null +++ b/scripts/dpkg-statoverride.pl @@ -0,0 +1,166 @@ +#! /usr/bin/perl + +$dpkglibdir= "/var/lib/dpkg"; # This line modified by Makefile +$version= '1.3.0'; # This line modified by Makefile + +$verbose= 1; +$force= 0; +$doupdate= 0; +$mode= ""; + +sub UsageVersion { + print STDERR < + dpkg-statoverride [options] --remove + dpkg-statoverride [options] --list [] + +Options: + --update immediately update file permissions + --force force an action even if a sanity check fails + --quiet quiet operation, minimal output + --help print this help screenm and exit + --admindir set the directory with the statoverride file +EOF +} + +sub CheckModeConflict { + return unless $mode; + &badusage("two modes specified: $_ and --$mode"); +} + +while (@ARGV) { + $_=shift(@ARGV); + last if m/^--$/; + if (!m/^-/) { + unshift(@ARGV,$_); last; + } elsif (m/^--help$/) { + &UsageVersion; exit(0); + } elsif (m/^--update$/) { + $doupdate=1; + } elsif (m/^--quiet$/) { + $verbose=1; + } elsif (m/^--force$/) { + $force=1; + } elsif (m/^--admindir$/) { + @ARGV || &badusage("--admindir needs a directory argument"); + $dpkglibdir= shift(@ARGV); + } elsif (m/^--add$/) { + &CheckModeConflict; + $mode= 'add'; + } elsif (m/^--remove$/) { + &CheckModeConflict; + $mode= 'remove'; + } elsif (m/^--list$/) { + &CheckModeConflict; + $mode= 'list'; + } else { + &badusage("unknown option \`$_'"); + } +} + +$dowrite=0; + +&badusage("no mode specified") unless $mode; +&ReadOverrides; + +if ($mode eq "add") { + @ARGV==4 || &badusage("--add needs four arguments"); + $user=$ARGV[0]; + ($user =~ m/^#[0-9]*/ or (($tmp)=getpwnam($user))) || &badusage("illegal user $user"); + $group=$ARGV[1]; + ($group =~ m/^#[0-9]*/ or (($tmp)=getgrnam($group))) || &badusage("illegal group $group"); + $mode= $ARGV[2]; + (($mode<0) or ($mode>07777)) && &badusage("illegal mode $mode"); + $file= $ARGV[3]; + $file =~ m/\n/ && &badusage("file may not contain newlines"); + + if (defined $user{$file}) { + print STDERR "An override for \"$file\" already exists, "; + if ($doforce) { + print STDERR "but --force specified so lets ignore it.\n"; + } else { + print STDERR "aborting\n"; + exit(3); + } + } + $user{$file}=$user; + $group{$file}=$group; + $mode{$file}=$mode; + $dowrite=1; +} elsif ($mode eq "remove") { + @ARGV==1 || &badusage("--remove needs four arguments"); + $file=$ARGV[0]; + if (not defined $user{$file}) { + print "No override present."; + exit(0); + } + delete $user{$file}; + delete $group{$file}; + delete $mode{$file}; + $dowrite=1; +} elsif ($mode eq "list") { + my (@list,@ilist,$pattern,$file); + + @ilist= @ARGV ? @ARGV : ('*'); + while (defined($_=shift(@ilist))) { + s/\W/\\$&/g; + s/\\\?/./g; + s/\\\*/.*/g; + push(@list,"^$_\$"); + } + $pat= join('|',@list); + for $file (keys %owner) { + next unless ($file =~ m/$pat/o); + print "$owner{$file} $group{$file} $mode{$file} $file\n"; + } +} + +&WriteOverrides if ($dowrite); + +exit(0); + +sub ReadOverrides { + open(SO,"$dpkglibdir/statoverride") || &quit("cannot open statoverride: $!"); + while () { + my ($owner,$group,$mode,$file); + chomp; + + ($owner,$group,$mode,$file)=split(' ', $_, 4); + die "Multiple overrides for \"$file\", aborting" + if defined $owner{$file}; + $owner{$file}=$owner; + $group{$file}=$group; + $mode{$file}=$mode; + } + close(SO); +} + + +sub WriteOverrides { + my ($file); + + open(SO,"$dpkglibdir/statoverride-new") || &quit("cannot open new statoverride file: $!"); + foreach $file (keys %owner) { + print SO "$owner{$file} $group{$file} $mode{$file} $file\n"; + } + close(SO); + chmod(0644, "$dpkglibdir/statoverride-new"); + unlink("$dpkglibdir/statoverride-old") || + $! == &ENOENT || &quit("error removing statoverride-old: $!"); + link("$dpkglibdir/statoverride","$dpkglibdir/statoverride-old") || + $! == &ENOENT || &quit("error creating new statoverride-old: $!"); + rename("$dpkglibdir/statoverride-new","$dpkglibdir/statoverride") + || &quit("error installing new statoverride: $!"); +} + + +sub quit { print STDERR "dpkg-statoverride: @_\n"; exit(2); } +sub badusage { print STDERR "dpkg-statoverride: @_\n\n"; print("You need --help.\n"); exit(2); } -- 2.39.5