Просмотр исходного кода

Add new enoent utility to get ENOENT at runtime

Wichert Akkerman лет назад: 25
Родитель
Сommit
98b5b8eaa5
5 измененных файлов с 38 добавлено и 14 удалено
  1. 7 0
      ChangeLog
  2. 5 5
      scripts/dpkg-divert.pl
  3. 9 6
      scripts/update-alternatives.pl
  4. 9 3
      utils/Makefile.in
  5. 8 0
      utils/enoent.c

+ 7 - 0
ChangeLog

@@ -1,3 +1,10 @@
+Tue Apr 24 13:03:54 CEST 2001 Wichert Akkerman <wakkerma@debian.org>
+
+  * utils/enoent.c: new utility to get ENOENT value at runtime
+  * utils/Makefile.in: install ENOENT in dpkglibdir
+  * scripts/dpkg-divert.pl, update-alternatives.pl: use enoent to get
+    ENOENT value
+
 Tue Apr 24 13:01:28 CEST 2001 Wichert Akkerman <wakkerma@debian.org>
 
   * dselect/Makefile.in, main/Makefile.in, utils/Makefile.in: use

+ 5 - 5
scripts/dpkg-divert.pl

@@ -1,11 +1,11 @@
 #!/usr/bin/perl --
 
-#use POSIX; &ENOENT;
-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
 $admindir= "/var/lib/dpkg"; # This line modified by Makefile
+$dpkglibdir= "../utils"; # This line modified by Makefile
+
+$enoent=`$dpkglibdir/enoent` || die "Cannot get ENOENT value from $dpkglibdir/enoent: $!";
+sub ENOENT { $enoent; }
 
 sub showversion {
     print("Debian dpkg-divert $version.\n") || &quit("failed to write version: $!");
@@ -15,7 +15,7 @@ sub usage {
     &showversion;
     print STDERR <<EOF
 Copyright (C) 1995 Ian Jackson.
-Copyright (C) 2000 Wichert Akkerman.
+Copyright (C) 2000,2001 Wichert Akkerman.
 
 This is free software; see the GNU General Public Licence version 2 or later
 for copying conditions. There is NO warranty.

+ 9 - 6
scripts/update-alternatives.pl

@@ -1,8 +1,8 @@
 #!/usr/bin/perl --
 
-#use POSIX; &ENOENT;
-sub ENOENT { 2; }
-# Sorry about this, but the errno-part of POSIX.pm isn't in perl-*-base
+$admindir= "/var/lib/dpkg"; # This line modified by Makefile
+$dpkglibdir= "../utils"; # This line modified by Makefile
+$version= '0.93.80'; # This line modified by Makefile
 
 # Global variables:
 #  $alink            Alternative we are managing (ie the symlink we're making/removing) (install only)
@@ -25,12 +25,15 @@ sub ENOENT { 2; }
 #  %priorities       Map from @version-index to priority
 #  %slavepath        Map from (@version-index,slavename) to slave-path
 
-$version= '0.93.80'; # This line modified by Makefile
+$enoent=`$dpkglibdir/enoent` || die "Cannot get ENOENT value from $dpkglibdir/enoent: $!";
+$enoent=`$dpkglibdir/enoent`;
+sub ENOENT { $enoent; }
+
 sub usageversion {
     print(STDERR <<END)
 Debian update-alternatives $version.
 Copyright (C) 1995 Ian Jackson.
-Copyright (C) 2000 Wichert Akkerman
+Copyright (C) 2000,2001 Wichert Akkerman
 This is free software; see the GNU General Public Licence
 version 2 or later for copying conditions.  There is NO warranty.
 
@@ -54,7 +57,7 @@ sub quit { print STDERR "update-alternatives: @_\n"; exit(2); }
 sub badusage { print STDERR "update-alternatives: @_\n\n"; &usageversion; exit(2); }
 
 $altdir= '/etc/alternatives';
-$admindir= '/var/lib/dpkg' . '/alternatives';
+$admindir= $admindir . '/alternatives';
 $testmode= 0;
 $verbosemode= 0;
 $mode='';

+ 9 - 3
utils/Makefile.in

@@ -16,16 +16,19 @@ MD5_SOURCES		= md5sum.c
 MD5_OBJECTS		= $(patsubst %.c, %.o, $(MD5_SOURCES))
 MD5_MANPAGES		= md5sum.1
 
-GENFILES		= $(MD5_OBJECTS) md5sum
+ENOENT_SOURCES		= enoent.c
+ENOENT_OBJECTS		= $(patsubst %.c, %.o, $(ENOENT_SOURCES))
+
+GENFILES		= $(MD5_OBJECTS) md5sum $(ENOENT_OBJECTS) enoent
 ifeq (@USE_START_STOP_DAEMON@, true)
 GENFILES		+= $(SSD_OBJECTS) start-stop-daemon
 endif
 
 .PHONY: all
 ifeq (@USE_START_STOP_DAEMON@, true)
-all:: start-stop-daemon md5sum
+all:: start-stop-daemon md5sum enoent
 else
-all:: md5sum
+all:: md5sum enoent
 endif
 
 .PHONY: install
@@ -51,6 +54,9 @@ endif
 	$(mkinstalldirs) $(DESTDIR)/$(bindir)
 	$(INSTALL_PROGRAM) md5sum $(DESTDIR)/$(bindir)
 
+	$(mkinstalldirs) $(DESTDIR)/$(dpkglibdir)
+	$(INSTALL_PROGRAM) enoent $(DESTDIR)/$(dpkglibdir)
+
 .PHONY: install-doc
 install-doc:
 ifeq (@USE_START_STOP_DAEMON@, true)

+ 8 - 0
utils/enoent.c

@@ -0,0 +1,8 @@
+#include <stdio.h>
+#include <errno.h>
+
+int main(int argc, char** argv) {
+	printf("%d", ENOENT);
+	return 0;
+}
+