Browse Source

We can now use dhcpcd, pump or dhclient by throwing a define at build time.

r345
master
David Whedon 23 years ago
parent
commit
0dde5a3895
  1. 28
      Makefile
  2. 6
      debian/changelog
  3. 17
      debian/rules
  4. 42
      netcfg-dhcp.c
  5. 7
      netcfg.h

28
Makefile

@ -1,8 +1,16 @@
ifndef PROGS
PROGS=netcfg-dhcp netcfg-static
endif
# this is the size of the non-shared udebs
#-rw-r--r-- 1 davidw root 7114 Jan 16 20:49 netcfg-dhcp_0.04_i386.udeb
#-rw-r--r-- 1 davidw root 7556 Jan 16 20:49 netcfg-static_0.04_i386.udeb
ifndef TARGETS
TARGETS=netcfg-dhcp netcfg-static
endif
DHCP_CLIENT=-DPUMP
#-DDHCLIENT
#-DDHCPCD
MAJOR=0
MINOR=1
MICRO=0
@ -13,7 +21,7 @@ SONAME=libnetcfg.so.$(MAJOR).$(MINOR)
LIBS=$(LIB) $(SONAME) $(LIBNAME)
INCS=-I../cdebconf/src/
LDOPTS=-L../cdebconf/src -ldebconf -Wl,-rpath,../cdebconf/src
LDOPTS=-L../cdebconf/src -ldebconf -Wl,-rpath,../cdebconf/src
#-L. -lnetcfg
PREFIX=$(DESTDIR)/usr/
CFLAGS=-Wall -Os -fomit-frame-pointer
@ -21,16 +29,10 @@ INSTALL=install
STRIPTOOL=strip
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment
all: $(PROGS)
all: $(TARGETS)
#$(LIBS)
install:
$(foreach PROG, $(PROGS), \
cp $(PROG) debian/$(PROG).postinst)
netcfg-dhcp netcfg-static: netcfg-dhcp.c utils.o netcfg.o
$(CC) $(CFLAGS) $@.c -o $@ $(INCS) $(LDOPTS) utils.o netcfg.o
$(CC) $(CFLAGS) $@.c -o $@ $(INCS) $(LDOPTS) $(DHCP_CLIENT) utils.o netcfg.o
$(STRIP) $@
size $@
@ -48,4 +50,4 @@ $(SONAME) $(LIB): $(LIBNAME)
clean:
rm -f netcfg-dhcp netcfg-static *.o
rm -f netcfg-dhcp netcfg-static *.o $(LIBS)

6
debian/changelog

@ -1,3 +1,9 @@
netcfg (0.05) unstable; urgency=low
* added support for dhclient and pump in addition to dhcpcd
-- David Whedon <dwhedon@gordian.com> Tue, 16 Jan 2001 21:17:50 -0800
netcfg (0.04) unstable; urgency=low
* fixed a segfault found by "Randolph Chung" <randolph@tausq.org>

17
debian/rules

@ -47,9 +47,11 @@ install: build
dh_testdir
dh_testroot
dh_clean -k
$(foreach PACKAGE, $(PACKAGES), \
( $(MAKE) install PROGS=$(PACKAGE) DESTDIR=`pwd`/debian/$(PACKAGE)) ; )
cp netcfg-dhcp debian/netcfg-dhcp.postinst
cp netcfg-static debian/netcfg-static.postinst
# if you ever decide to make the netcfg-common package, uncomment these to install it
# mkdir -p `pwd`/debian/netcfg-common/usr/lib/
# cp libnetcfg.so.0.1.0 `pwd`/debian/netcfg-common/usr/lib/
# Build architecture-independent files here.
binary-indep: build install
@ -70,16 +72,11 @@ binary-arch: build install
dh_installdeb
dh_shlibdeps
dh_gencontrol -- -fdebian/files~
$(foreach PACKAGE, $(PACKAGES), \
@$(foreach PACKAGE, $(PACKAGES), \
(dpkg-distaddfile $(PACKAGE)_$(VERSION)_$(ARCH).udeb \
debian-installer $(PRIORITY) ) ; )
dh_md5sums
# I think the following should work, but it doesn't, so I revert to manually
# calling dpkg-deb
# $(foreach PACKAGE, $(PACKAGES), \
# (dh_builddeb --filename=$(PACKAGE)_$(VERSION)_$(ARCH).udeb -- $(PACKAGE) \
# ); ) # to make a .udeb
$(foreach PACKAGE, $(PACKAGES), \
@$(foreach PACKAGE, $(PACKAGES), \
(cd debian ; \
dpkg-deb -b $(PACKAGE) ../../$(PACKAGE)_$(VERSION)_$(ARCH).udeb \
); )

42
netcfg-dhcp.c

@ -64,8 +64,9 @@ netcfg_write_dhcp ()
fprintf (fp,
"\n# This entry was created during the Debian installation\n");
fprintf (fp, "iface %s inet dhcp\n", interface);
fclose (fp);
}
#ifdef DHCPCD
netcfg_mkdir (DHCPCD_DIR);
if ((fp = file_open (DHCPCD_FILE)))
{
@ -74,7 +75,25 @@ netcfg_write_dhcp ()
fprintf (fp, "IFACE=%s\n", interface);
if (dhcp_hostname)
fprintf (fp, "OPTIONS='-h %s'\n", dhcp_hostname);
fclose (fp);
}
#elif defined PUMP
/* nothing to do */
#elif defined DHCLIENT
if (dhcp_hostname)
if ((fp = file_open (DHCLIENT_FILE)))
{
fprintf (fp,
"\n# dhclient configuration: created during the Debian installation\n \
interface \"%s\" {\nsend host-name \"%s\";\n}\n",
interface, dhcp_hostname);
fclose (fp);
}
#else
#error "Must specify a dhcp client"
#endif
}
@ -84,8 +103,10 @@ netcfg_activate_dhcp ()
char buf[128];
char *ptr;
execlog ("/sbin/ifconfig lo 127.0.0.1");
ptr = buf;
#ifdef DHCPCD
ptr += snprintf (buf, sizeof (buf), "/sbin/dhcpcd-2.2.x");
if (dhcp_hostname)
ptr +=
@ -93,8 +114,25 @@ netcfg_activate_dhcp ()
ptr += snprintf (ptr, sizeof (buf) - (ptr - buf), " %s", interface);
#elif defined PUMP
ptr += snprintf (buf, sizeof (buf), "/sbin/pump -i %s", interface);
if (dhcp_hostname)
ptr +=
snprintf (ptr, sizeof (buf) - (ptr - buf), " -h %s", dhcp_hostname);
#elif defined DHCLIENT
ptr += snprintf (buf, sizeof (buf), "/sbin/dhclient-2.2.x %s", interface);
#else
#error "Must specify a dhcp client"
#endif
if (execlog (buf))
netcfg_die (client);
}
int

7
netcfg.h

@ -2,14 +2,15 @@
#define _NETCFG_H_
#include <sys/types.h>
#define ETC_DIR "/etc"
#define NETWORK_DIR "/etc/network"
#define DHCPCD_DIR "/etc/dhcpc"
#define ETC_DIR "/etc"
#define NETWORK_DIR "/etc/network"
#define DHCPCD_DIR "/etc/dhcpc"
#define INTERFACES_FILE "/etc/network/interfaces"
#define HOSTS_FILE "/etc/hosts"
#define NETWORKS_FILE "/etc/networks"
#define RESOLV_FILE "/etc/resolv.conf"
#define DHCPCD_FILE "/etc/dhcpc/config"
#define DHCLIENT_FILE "/etc/dhclient.conf"
extern int netcfg_mkdir (char *path);

Loading…
Cancel
Save