tcpdump mailing list archives

packaging/pcap.spec, shared library


From: Neil Spring <nspring () cs washington edu>
Date: Sat, 29 Nov 2003 18:26:23 -0800

I thought I would play around with libpcap 0.8 with software
on planetlab (planet-lab.org) machines, and found a few
bumps.  First, I needed an RPM, and packaging/pcap.spec
doesn't seem to have been updated for months.  Second, the
spec file does not install a shared library, and neither
does the default Makefile.  Third "make tar" doesn't seem to
be what is used anymore, as recent releases have been gzip
compressed (.gz) and not compress (.Z) compressed.

Below is a patch that does a few good things, though they
may not be portable.  I hope some are worth inclusion.  I
think the spec file is out of date enough that my changes
won't break anything that isn't already broken. ;)

First, it replenishes FILES, adding a spec file to the
tarball.  Adding the spec file to the tarball is handy
because "rpm -tb <tarfilename>" can create the package.

Second, it tries to build a shared library file in
Makefile.in.  It seems to work on my mac and on my linux
machine (and is based on patch files from fink and some
rpm-based distribution).  It is probably better to yank that
part of the patch, but it seems that folks expect a shared
library and I chose to build the patch below as correctly as
I could at first and make it practical later.  ... well, the
"right" solution is probably libtool, but that's a headache
for another day.   It shouldn't break anything -- one has
to run "make shared" and "make install-shared" to invoke
these rules.

Third, it builds packaging/pcap.spec using sed when creating
a tar file, ensuring that it has the proper file name and
version number embedded.  This means that a user might
expect to be able to run "rpm -tb libpcap-0.8.1.tar.gz" and
get an .rpm as a result.  I am more of a Debian evangelist,
so I can't speak to the quality of the packaging, in
particular I don't know what redhat claims to do with
sonames.  I do, however, like the idea of having fewer
people to trust than web-searching for rpms.  This
auto-generation can be tricky when dealing with version
numbers that have -'s in them (as recent beta releases
have).  I think -'s are handled properly, but I'm uncertain.
The spec file is updated to place the man page in
/usr/share/man.

Fourth, the patch updates the "tar" rule to use gzip.  The
tar rule is used to ensure that the .spec file is updated
with the most current VERSION before release.  Perhaps this
rule could be used again, as I hear it is considered bad
form to include CVS directories in distributed source.

Finally, it regenerates the Makefile if it appears out of
date.  This was useful for me, but might be subtly
problematic.

thanks,
-neil



diff -urb --new-file --exclude=Makefile --exclude=configure --exclude=CVS libpcap/FILES libpcap.packaging/FILES
--- libpcap/FILES       Fri Nov 28 14:38:19 2003
+++ libpcap.packaging/FILES     Fri Nov 28 14:38:31 2003
@@ -13,6 +13,7 @@
 SUNOS4/nit_if.o.sparc
 SUNOS4/nit_if.o.sun3
 SUNOS4/nit_if.o.sun4c.4.0.3c
+TODO
 VERSION
 aclocal.m4
 arcnet.h
@@ -96,4 +97,6 @@
 Win32/Src/inet_aton.c
 Win32/Src/inet_net.c
 Win32/Src/inet_pton.c
+packaging/pcap.spec
+packaging/pcap.spec.in
 
diff -urb --new-file --exclude=Makefile --exclude=configure --exclude=CVS libpcap/Makefile.in 
libpcap.packaging/Makefile.in
--- libpcap/Makefile.in Fri Nov 28 14:38:21 2003
+++ libpcap.packaging/Makefile.in       Fri Nov 28 14:38:33 2003
@@ -46,6 +46,7 @@
 INCLS = -I. @V_INCLS@
 DEFS = @DEFS@ @V_DEFS@
 LIBS = @V_LIBS@
+DYEXT = @DYEXT@
 
 # Standard CFLAGS
 CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
@@ -103,6 +104,19 @@
        ar rc $@ $(OBJ) $(LIBS)
        $(RANLIB) $@
 
+shared: libpcap.$(DYEXT)
+libpcap.so: $(OBJ)
+       @rm -f $@
+       ld -shared -o $@.`cat VERSION` $(OBJ)
+
+# the following rule succeeds, but the result is untested.
+libpcap.dylib: $(OBJ)
+       rm -f libpcap*.dylib
+       $(CC) -dynamiclib -undefined error -o libpcap.`cat VERSION`.dylib $(OBJ) \
+               -install_name $(libdir)/libpcap.0.dylib -compatibility_version `cat VERSION` \
+               -current_version `cat VERSION`
+
+
 scanner.c: $(srcdir)/scanner.l
        @rm -f $@
        $(LEX) -t $< > $$$$.$@; mv $$$$.$@ $@
@@ -151,7 +165,7 @@
 bpf_filter.o: bpf_filter.c
        $(CC) $(CFLAGS) -c bpf_filter.c
 
-install:
+install: libpcap.a 
        [ -d $(DESTDIR)$(libdir) ] || \
            (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
        $(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
@@ -168,6 +182,13 @@
        $(INSTALL_DATA) $(srcdir)/pcap.3 \
            $(DESTDIR)$(mandir)/man3/pcap.3
 
+install-shared: install-shared-$(DYEXT)
+install-shared-so: libpcap.so
+       $(INSTALL_PROGRAM) libpcap.so.`cat VERSION` $(DESTDIR)$(libdir)/libpcap.so.`cat VERSION`
+install-shared-dylib: libpcap.dylib
+       $(INSTALL_PROGRAM) libpcap.`cat VERSION`.dylib $(DESTDIR)$(libdir)/libpcap.`cat VERSION`.dylib
+       VER=`cat VERSION`; cd $(DESTDIR)$(libdir) && ln -sf libpcap.$$VER.dylib libpcap.0.dylib;  ln -sf 
libpcap.0.dylib libpcap.dylib
+
 uninstall:
        rm -f $(DESTDIR)$(libdir)/libpcap.a
        rm -f $(DESTDIR)$(includedir)/pcap.h
@@ -176,16 +197,21 @@
        rm -f $(DESTDIR)$(mandir)/man3/pcap.3
 
 clean:
-       rm -f $(CLEANFILES)
+       rm -f $(CLEANFILES) libpcap*.dylib libpcap.so*
 
-distclean:
-       rm -f $(CLEANFILES) Makefile config.cache config.log config.status \
+distclean: clean
+       rm -f Makefile config.cache config.log config.status \
            config.h gnuc.h os-proto.h bpf_filter.c stamp-h stamp-h.in
+       rm -rf autom4te.cache
 
 tags: $(TAGFILES)
        ctags -wtd $(TAGFILES)
 
-tar:
+packaging/pcap.spec: packaging/pcap.spec.in VERSION
+       RPMVERSION=`cat VERSION | sed s/-.*//g`; \
+               sed -e s/@VERSION@/$$RPMVERSION/ -e s/@NAME@/libpcap-`cat VERSION`/ $<   > $@
+
+tar: Makefile packaging/pcap.spec
        @cwd=`pwd` ; dir=`basename $$cwd` ; name=libpcap-`cat VERSION` ; \
            list="" ; tar="tar chf" ; \
            for i in `cat FILES` ; do list="$$list $$name/$$i" ; done; \
@@ -193,11 +219,16 @@
            "rm -f ../$$name; ln -s $$dir ../$$name" ; \
             rm -f ../$$name; ln -s $$dir ../$$name ; \
            echo \
-           "(cd .. ; $$tar - [lots of files]) | compress > /tmp/$$name.tar.Z" ; \
-            (cd .. ; $$tar - $$list) | compress > /tmp/$$name.tar.Z ; \
+           "(cd .. ; $$tar - [lots of files]) | gzip -c > /tmp/$$name.tar.gz" ; \
+            (cd .. ; $$tar - $$list) | gzip -c > /tmp/$$name.tar.gz ; \
            echo \
            "rm -f ../$$name" ; \
             rm -f ../$$name
 
 depend:        $(GENSRC) $(GENHDR) bpf_filter.c
        ./mkdep -c $(CC) $(DEFS) $(INCLS) $(SRC)
+
+Makefile: Makefile.in config.status
+       ./config.status
+       @echo your Makefile was out of date, now run $(MAKE) again
+       exit 1
diff -urb --new-file --exclude=Makefile --exclude=configure --exclude=CVS libpcap/configure.in 
libpcap.packaging/configure.in
--- libpcap/configure.in        Fri Nov 28 14:38:18 2003
+++ libpcap.packaging/configure.in      Fri Nov 28 14:38:30 2003
@@ -340,6 +340,7 @@
        fi
 fi
 
+DYEXT="so"
 case "$host_os" in
 
 aix*)
@@ -379,6 +380,10 @@
 solaris*)
        AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
        ;;
+darwin*)
+       DYEXT="dylib"
+    V_CCOPT="$V_CCOPT -fno-common"
+       ;;
 esac
 
 AC_PROG_RANLIB
@@ -406,6 +411,7 @@
 AC_SUBST(V_RANLIB)
 AC_SUBST(V_YACC)
 AC_SUBST(SSRC)
+AC_SUBST(DYEXT)
 
 AC_PROG_INSTALL
 
diff -urb --new-file --exclude=Makefile --exclude=configure --exclude=CVS libpcap/packaging/pcap.spec 
libpcap.packaging/packaging/pcap.spec
--- libpcap/packaging/pcap.spec Fri Nov 28 14:38:22 2003
+++ libpcap.packaging/packaging/pcap.spec       Fri Nov 28 14:52:03 2003
@@ -1,5 +1,5 @@
 %define prefix   /usr
-%define version 2003.02.10
+%define version 0.8
 
 Summary: packet capture library
 Name: libpcap
@@ -7,7 +7,7 @@
 Release: 1
 Group: Development/Libraries
 Copyright: BSD
-Source: libpcap-current.tar.gz
+Source: libpcap-0.8.tar.gz
 BuildRoot: /tmp/%{name}-buildroot
 URL: http://www.tcpdump.org
 
@@ -29,22 +29,37 @@
 
 %install
 rm -rf $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT/usr/{lib,include,man}
+mkdir -p $RPM_BUILD_ROOT/usr/{lib,include}
+mkdir -p $RPM_BUILD_ROOT/usr/share/man
 mkdir -p $RPM_BUILD_ROOT/usr/include/net
 mkdir -p $RPM_BUILD_ROOT/usr/man/man3
-install -m 755 -o root libpcap.a $RPM_BUILD_ROOT/usr/lib
-install -m 644 -o root pcap.3 $RPM_BUILD_ROOT/usr/man/man3
-install -m 644 -o root pcap.h $RPM_BUILD_ROOT/usr/include
-install -m 644 -o root pcap-bpf.h $RPM_BUILD_ROOT/usr/include/net
-install -m 644 -o root pcap-namedb.h $RPM_BUILD_ROOT/usr/include
+make install DESTDIR=$RPM_BUILD_ROOT mandir=/usr/share/man
+cd $RPM_BUILD_ROOT/usr/lib
+V1=`echo 0.8 | sed 's/\\.[^\.]*$//g'`
+V2=`echo 0.8 | sed 's/\\.[^\.]*\.[^\.]*$//g'`
+ln -sf libpcap.so.0.8 libpcap.so.$V1
+if test "$V2" -ne "$V1"; then
+    ln -sf libpcap.so.$V1 libpcap.so.$V2
+    ln -sf libpcap.so.$V2 libpcap.so
+else
+    ln -sf libpcap.so.$V1 libpcap.so
+fi
+
+#install -m 755 -o root libpcap.a $RPM_BUILD_ROOT/usr/lib
+#install -m 644 -o root pcap.3 $RPM_BUILD_ROOT/usr/man/man3
+#install -m 644 -o root pcap.h $RPM_BUILD_ROOT/usr/include
+#install -m 644 -o root pcap-bpf.h $RPM_BUILD_ROOT/usr/include/net
+#install -m 644 -o root pcap-namedb.h $RPM_BUILD_ROOT/usr/include
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(-,root,root)
-%doc LICENSE CHANGES INSTALL README.linux TODO VERSION CREDITS pcap.spec
+%doc LICENSE CHANGES INSTALL.txt README.linux TODO VERSION CREDITS packaging/pcap.spec
 /usr/lib/libpcap.a
+/usr/share/man/man3/*
 /usr/include/pcap.h
 /usr/include/pcap-bpf.h
 /usr/include/pcap-namedb.h
+/usr/lib/libpcap.so*
diff -urb --new-file --exclude=Makefile --exclude=configure --exclude=CVS libpcap/packaging/pcap.spec.in 
libpcap.packaging/packaging/pcap.spec.in
--- libpcap/packaging/pcap.spec.in      Wed Dec 31 16:00:00 1969
+++ libpcap.packaging/packaging/pcap.spec.in    Fri Nov 28 14:51:59 2003
@@ -0,0 +1,65 @@
+%define prefix   /usr
+%define version @VERSION@
+
+Summary: packet capture library
+Name: libpcap
+Version: %version
+Release: 1
+Group: Development/Libraries
+Copyright: BSD
+Source: @NAME ()  tar gz
+BuildRoot: /tmp/%{name}-buildroot
+URL: http://www.tcpdump.org
+
+%description
+Packet-capture library LIBPCAP @VERSION@
+Now maintained by "The Tcpdump Group"
+See http://www.tcpdump.org
+Please send inquiries/comments/reports to tcpdump-workers () tcpdump org
+
+%prep
+%setup
+
+%post
+ldconfig
+
+%build
+CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix
+make
+
+%install
+rm -rf $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT/usr/{lib,include}
+mkdir -p $RPM_BUILD_ROOT/usr/share/man
+mkdir -p $RPM_BUILD_ROOT/usr/include/net
+mkdir -p $RPM_BUILD_ROOT/usr/man/man3
+make install DESTDIR=$RPM_BUILD_ROOT mandir=/usr/share/man
+cd $RPM_BUILD_ROOT/usr/lib
+V1=`echo @VERSION@ | sed 's/\\.[^\.]*$//g'`
+V2=`echo @VERSION@ | sed 's/\\.[^\.]*\.[^\.]*$//g'`
+ln -sf libpcap.so.@VERSION@ libpcap.so.$V1
+if test "$V2" -ne "$V1"; then
+    ln -sf libpcap.so.$V1 libpcap.so.$V2
+    ln -sf libpcap.so.$V2 libpcap.so
+else
+    ln -sf libpcap.so.$V1 libpcap.so
+fi
+
+#install -m 755 -o root libpcap.a $RPM_BUILD_ROOT/usr/lib
+#install -m 644 -o root pcap.3 $RPM_BUILD_ROOT/usr/man/man3
+#install -m 644 -o root pcap.h $RPM_BUILD_ROOT/usr/include
+#install -m 644 -o root pcap-bpf.h $RPM_BUILD_ROOT/usr/include/net
+#install -m 644 -o root pcap-namedb.h $RPM_BUILD_ROOT/usr/include
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%doc LICENSE CHANGES INSTALL.txt README.linux TODO VERSION CREDITS packaging/pcap.spec
+/usr/lib/libpcap.a
+/usr/share/man/man3/*
+/usr/include/pcap.h
+/usr/include/pcap-bpf.h
+/usr/include/pcap-namedb.h
+/usr/lib/libpcap.so*

-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:tcpdump-workers-request () tcpdump org?body=unsubscribe


Current thread: