On Sat, Feb 09, 2002 at 05:39:16PM +0100, Wichert Akkerman wrote: > Previously utsl@quic.net wrote: > > Please consider this patch, which adds FreeBSD support to dpkg. It is based > > on a fresh checkout from CVS, so it should apply easily. > > Can you please split the patch in multiple parts: > > 1. make functions static > 2. type changes > 3. support for wildcards > 4. adding freebsd to archtables Ok, I've split it up: 1 & 2: Not sure what you're looking for here. I put the start-stop-daemon changes into patch #1. The function changes were to make them match the prototypes at the top of the file. I haven't got this part really well tested yet, so it might be a good idea to hold off on applying this patch for a while. 3: Fixed a major problem with this, while I split it off. I had hardcoded my arch in, instead of the target variables. Oops. It's now possible to use perl-style regular expressions in archtable. These are only used in configure, not in dpkg itself, so the arch in the gcc-lib path still has to be in archtable. 4: Adjust FreeBSD archs in archtable and dpkg-architecture. 5: Fix __va_copy test in configure.in. The one that was there didn't really make sure it works. 6: Fix dpkg-shlibdeps to work on FreeBSD. The ldd on FreeBSD doesn't work on shared libraries. ldconfig -r does approximately what ldconfig -p does on Linux, and sort of provides the same information as ldd would have.
diff -urN dpkg/utils/start-stop-daemon.c dpkg-1.10-freebsd/utils/start-stop-daemon.c --- dpkg/utils/start-stop-daemon.c Fri Feb 1 23:28:13 2002 +++ dpkg-1.10-freebsd/utils/start-stop-daemon.c Fri Feb 8 04:36:55 2002 @@ -32,6 +32,8 @@ # define OSOpenBSD #elif defined(hpux) # define OShpux +#elif defined(__FreeBSD__) +# define OSFreeBSD #else # error Unknown architecture - cannot build start-stop-daemon #endif @@ -43,7 +45,7 @@ # include <ps.h> #endif -#if defined(OSOpenBSD) +#if defined(OSOpenBSD) || defined(OSFreeBSD) #include <sys/param.h> #include <sys/user.h> #include <sys/proc.h> @@ -675,7 +677,7 @@ { #if defined(OSLinux) || defined(OShpux) if (execname && !pid_is_exec(pid, &exec_stat)) -#elif defined(OSHURD) +#elif defined(OSHURD) || defined(OSFreeBSD) /* I will try this to see if it works */ if (execname && !pid_is_cmd(pid, execname)) #endif @@ -707,7 +709,9 @@ /* WTA: this needs to be an autoconf check for /proc/pid existance. */ -#if defined(OSLinux) || defined (OSsunos) + +/* WART: FreeBSD also has /proc support */ +#if defined(OSLinux) || defined (OSsunos) || defined(OSfreebsd) static void do_procinit(void) { @@ -768,8 +772,8 @@ #endif /* OSHURD */ -#if defined(OSOpenBSD) -int +#if defined(OSOpenBSD) || defined(OSFreeBSD) +static int pid_is_cmd(pid_t pid, const char *name) { kvm_t *kd; @@ -810,8 +814,8 @@ return (strcmp(name, start_argv_0_p) == 0) ? 1 : 0; } -int -pid_is_user(pid_t pid, int uid) +static int +pid_is_user(pid_t pid, uid_t uid) { kvm_t *kd; int nentries; /* Value not used */ @@ -833,7 +837,7 @@ return (proc_uid == (uid_t)uid); } -int +static int pid_is_exec(pid_t pid, const char *name) { kvm_t *kd;
diff -urN dpkg/configure.in dpkg-1.10-freebsd/configure.in --- dpkg/configure.in Sat Feb 2 17:58:58 2002 +++ dpkg-1.10-freebsd/configure.in Fri Feb 8 23:35:45 2002 @@ -93,7 +93,7 @@ dpkg_archset='' AC_MSG_CHECKING(Debian architecture) -dpkg_archset="`awk '$1 == "'$target_cpu-$target_os'" { print $2 }' $srcdir/archtable`" +dpkg_archset="`perl -ane 'if("'$target_cpu-$target_os'"=~m#^$F[0]$#) {print $F[1]; exit(0)}' archtable`" # Finish off if test "x$dpkg_archset" = "x"; then AC_MSG_RESULT([$target_cpu-$target_os, but not found in archtable])
diff -urN dpkg/archtable dpkg-1.10-freebsd/archtable --- dpkg/archtable Tue Jan 1 13:16:37 2002 +++ dpkg-1.10-freebsd/archtable Fri Feb 8 01:17:11 2002 @@ -43,6 +43,8 @@ hppa1.1-linux-gnu hppa hppa hppa2.0-linux-gnu hppa hppa hppa64-linux-gnu hppa hppa +i386-freebsd.+ freebsd-i386 freebsd-i386 +i386-freebsd4 freebsd-i386 freebsd-i386 i386-freebsd freebsd-i386 freebsd-i386 s390-linux-gnu s390 s390 s390-ibm-linux-gnu s390 s390 diff -urN dpkg/scripts/dpkg-architecture.pl dpkg-1.10-freebsd/scripts/dpkg-architecture.pl --- dpkg/scripts/dpkg-architecture.pl Tue Jan 1 14:07:49 2002 +++ dpkg-1.10-freebsd/scripts/dpkg-architecture.pl Fri Feb 8 04:45:52 2002 @@ -65,7 +65,7 @@ 's390', 's390-linux', 'ia64', 'ia64-linux', 'openbsd-i386', 'i386-openbsd', - 'freebsd-i386', 'i386-freebsd', + 'freebsd-i386', 'i386-freebsd4', 'darwin-powerpc', 'powerpc-darwin', 'darwin-i386', 'i386-darwin');
diff -urN dpkg/configure.in dpkg-1.10-freebsd/configure.in --- dpkg/configure.in Sat Feb 2 17:58:58 2002 +++ dpkg-1.10-freebsd/configure.in Fri Feb 8 23:35:45 2002 @@ -173,11 +173,20 @@ } inline int foo (int x) {], AC_DEFINE(HAVE_INLINE)) AC_MSG_CHECKING([for __va_copy]) -AC_TRY_COMPILE([ -#include <stdarg.h> -],[ -va_list v1,v2; -__va_copy(v1, v2); +AC_TRY_RUN([ + #include <stdarg.h> + void f (int i, ...) { + va_list args1, args2; + va_start (args1, i); + __va_copy (args2, args1); + if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) + exit (1); + va_end (args1); va_end (args2); + } + int main() { + f (0, 42); + return 0; + } ], [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_VA_COPY)],[AC_MSG_RESULT(no)
diff -urN dpkg/scripts/dpkg-shlibdeps.pl dpkg-1.10-freebsd/scripts/dpkg-shlibdeps.pl --- dpkg/scripts/dpkg-shlibdeps.pl Wed Jun 20 16:30:15 2001 +++ dpkg-1.10-freebsd/scripts/dpkg-shlibdeps.pl Fri Feb 8 23:57:06 2002 @@ -91,12 +91,29 @@ } } +$deb_build_arch = `dpkg --print-installation-architecture`; +if ($?>>8) { + &syserr("dpkg --print-installation-architecture failed"); +} +chomp $deb_build_arch; + for ($i=0;$i<=$#exec;$i++) { if (!isbin ($exec[$i])) { next; } # First we get an ldd output to see what libs + paths we have at out # disposal. my %so2path = (); + +if($deb_build_arch eq "freebsd-i386") { + defined($c= open(P,"-|")) || syserr("cannot fork for ldconfig"); + if (!$c) { exec("ldconfig","-r"); syserr("cannot exec ldconfig"); } + while (<P>) { + if (m,^\s+\d+:-l(\w+)(\.\d+)\s+=>\s+(\S+)$,) { + $so2path{"lib$1.so$2"} = $3; + } + } + close(P); $? && subprocerr("ldconfig"); +} else { defined($c= open(P,"-|")) || syserr("cannot fork for ldd"); if (!$c) { exec("ldd","--",$exec[$i]); syserr("cannot exec ldd"); } while (<P>) { @@ -105,6 +122,7 @@ } } close(P); $? && subprocerr("ldd on \`$exec[$i]'"); +} # Now we get the direct deps of the program. We then check back with # the ldd output from above to see what our path is.
Attachment:
pgpni4ylFW_Gt.pgp
Description: PGP signature