[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

patch to add FreeBSD support



Please consider this patch, which adds FreeBSD support to dpkg.  It is based
on a fresh checkout from CVS, so it should apply easily.

I added support for wildcards in the archtable to configure, because
config.guess returns i386-unknown-freebsd4.5, and will change regularly. This
seemed like it require excessive maintenance. The NetBSD and OpenBSD ports
will likely benefit from this as well.
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/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("'i386-freebsd4.5'"=~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])
@@ -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)
 AC_MSG_CHECKING([for va_list assignment copy])
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/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.
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;

Attachment: pgpTZppCEg3Ii.pgp
Description: PGP signature


Reply to: