Re: ifupdown: Add support for GNU/Hurd (updated patches)
On Tue, 2012-05-22 at 02:56 +0200, Samuel Thibault wrote:
> Svante Signell, le Mon 21 May 2012 20:14:10 +0200, a écrit :
> > --- a/debian/rules 2012-04-25 00:37:27.000000000 +0200
> > +++ b/debian/rules 2012-05-09 15:42:47.000000000 +0200
> > @@ -77,6 +77,8 @@
> > override_dh_gencontrol:
> > ifeq ($(DEB_HOST_ARCH_OS),linux)
> > dh_gencontrol -- -V'net:Depends=iproute (>= 20071016-1)' -V'net:Suggests=net-tools'
> > -else
> > +else ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
> > dh_gencontrol -- -V'net:Depends=net-tools' -V'net:Suggests='
> > -endif
> > +else ifeq ($(DEB_HOST_ARCH_OS),hurd)
> > + dh_gencontrol -- -V'net:Depends=inetutils-tools' -V'net:Suggests='
> > +endif
>
> Looks good.
patch1:
I get an error when building the .deb:
dh_builddeb
dpkg-deb: error: failed to open package info file
`debian/ifupdown/DEBIAN/control' for reading: No such file or directory
dh_builddeb: dpkg-deb --build debian/ifupdown .. returned exit code 2
make: *** [binary] Error 1
dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit
status 2
Looks like dh_dencontrol is not run, with dpkg-buildpackage Running
manually works:
fakeroot dh_gencontrol -- -V'net:Depends=inetutils-tools'
-V'net:Suggests='
dh_builddeb
> > --- /dev/null 2012-04-02 18:20:02.000000000 +0200
> > +++ ifupdown-0.7~rc2+experimental/debian/testbuild-hurd 2012-05-12 19:26:49.000000000 +0200
>
> Looks right, except one bit detailed below.
>
> > --- a/ifupdown.nw 2012-04-25 00:37:27.000000000 +0200
> > +++ b/ifupdown.nw 2012-05-21 19:38:30.000000000 +0200
> > @@ -551,7 +551,7 @@
> >
> > use strict;
> >
> > -<<determine the target architecrure>>
> > +<<determine the target architecture>>
> >
> > # declarations
> > <<defn2c variables>>
> > @@ -566,7 +566,7 @@
> > @
> >
> > First of all, we determine the target architecture by calling [[dpkg-architecture]] and stripping the trailing newline:
> > -<<determine the target architecrure>>=
> > +<<determine the target architecture>>=
> > my $DEB_HOST_ARCH_OS = `dpkg-architecture -qDEB_HOST_ARCH_OS`;
> >
> > $DEB_HOST_ARCH_OS =~ s/\n//;
> > @@ -965,7 +965,7 @@
> >
> > use strict;
> >
> > -<<determine the target architecrure>>
> > +<<determine the target architecture>>
> >
> > # declarations
> > <<defn2man variables>>
>
> Please file as separate patch :)
patch0
> > @@ -1016,7 +1016,7 @@
> >
> > Which only leaves extracting the description and options for each
> > method. And, of course, this imposes less restrictions of the
> > -[[.defn]] file than [[defn2c.pl]] did. It's a crazy old world.
> > +[.defn]] file than [[defn2c.pl]] did. It's a crazy old world.
>
> Mmm, is it not spurious?
Yes, spurious!
> > @@ -4575,6 +4575,26 @@
> > <<common functions implementations>>
> > @
> >
> > +\subsection{Hurd-specific functions}
>
> You should have said that it's simply the kfreebsd version, patched.
> Diffing them is easier :)
>
> > + conversion
> > + hwaddress cleanup_hwaddress (Not yet supported)
>
> Remove " (Not yet supported)" here, it apparently makes compilation fail.
Did not have this problem in rc2
> > + up
> > + [[FIXME: Add proper commands here for ipv6]]
> > + settrans -afg /servers/socket/26 /hurd/pfinet --interface %iface% --ipv6 ::1
>
> Remove that settrans, it would disturb the existing pfinet. Better
> assume that the user has set up inet6 already.
>
> > + inetutils-ifconfig --interface %iface% inet6 ::1
>
> Apparently inetutils-ifconfig does not support ipv6. So I'd say keep the
> FIXME as such for now.
>
> Apart from that it looks good, thanks!
patch2
> I've applied it to -rc3, fixed a few things described below, and
> uploaded to debian-ports.
>
> There is just one bit missing in the .nw file, see attached patch.
> Without it ifup mostly segfaults for me. Also, the testbuild-hurd file
> is not exactly right, --exit-on-error should be removed, as it is on
> kfreebsd.
Did not have these problems with rc2, anyway fixed in patch3.
diff -ur ifupdown-0.7~rc3.orig/ifupdown.nw ifupdown-0.7~rc3/ifupdown.nw
--- ifupdown-0.7~rc3.orig/ifupdown.nw 2012-05-14 21:49:57.000000000 +0200
+++ ifupdown-0.7~rc3/ifupdown.nw 2012-05-22 10:05:09.000000000 +0200
@@ -553,7 +553,7 @@
use strict;
-<<determine the target architecrure>>
+<<determine the target architecture>>
# declarations
<<defn2c variables>>
@@ -568,7 +568,7 @@
@
First of all, we determine the target architecture by calling [[dpkg-architecture]] and stripping the trailing newline:
-<<determine the target architecrure>>=
+<<determine the target architecture>>=
my $DEB_HOST_ARCH_OS = `dpkg-architecture -qDEB_HOST_ARCH_OS`;
$DEB_HOST_ARCH_OS =~ s/\n//;
@@ -977,7 +977,7 @@
use strict;
-<<determine the target architecrure>>
+<<determine the target architecture>>
# declarations
<<defn2man variables>>
--- ifupdown-0.7~rc3.orig/debian/rules 2012-05-14 21:49:57.000000000 +0200
+++ ifupdown-0.7~rc3/debian/rules 2012-05-22 10:48:00.000000000 +0200
@@ -77,6 +77,8 @@
override_dh_gencontrol:
ifeq ($(DEB_HOST_ARCH_OS),linux)
dh_gencontrol -- -V'net:Depends=iproute (>= 20071016-1)' -V'net:Suggests=net-tools'
-else
+else ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
dh_gencontrol -- -V'net:Depends=net-tools' -V'net:Suggests='
+else ifeq ($(DEB_HOST_ARCH_OS),hurd)
+ dh_gencontrol -- -V'net:Depends=inetutils-tools' -V'net:Suggests='
endif
--- /dev/null 2012-04-02 18:20:02.000000000 +0200
+++ ifupdown-0.7~rc3/debian/testbuild-hurd 2012-05-22 11:08:35.000000000 +0200
@@ -0,0 +1,281 @@
+#!/bin/sh -e
+
+rm -rf tests/
+mkdir tests
+cat >tests/testcase.1 <<EOF
+# RUN: -a
+auto eth0
+iface eth0 inet static
+ address 1.2.3.4
+ netmask 255.255.255.0
+ up echo hi
+ post-up echo hello
+EOF
+cat >tests/up.1 <<EOF
+====stdout====
+====stderr====
+run-parts --verbose /etc/network/if-pre-up.d
+Configuring interface eth0=eth0 (inet)
+run-parts --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth0 --address 1.2.3.4 --netmask 255.255.255.0 --up
+
+echo hi
+echo hello
+run-parts --verbose /etc/network/if-up.d
+run-parts --verbose /etc/network/if-up.d
+EOF
+
+cat >tests/testcase.2 <<EOF
+# RUN: -a
+auto eth0 eth1 eth2
+auto eth3 eth4 eth5
+allow-hotplug eth6
+iface eth0 inet static
+ address 1.2.3.4
+ netmask 255.255.255.0
+iface eth1 inet static
+ address 1.3.4.5
+ netmask 255.255.255.0
+iface eth2 inet static
+ address 1.4.5.6
+ netmask 255.255.255.0
+iface eth3 inet static
+ address 1.5.6.7
+ netmask 255.255.255.0
+iface eth4 inet static
+ address 1.7.8.9
+ netmask 255.255.255.0
+iface eth5 inet static
+ address 1.8.9.10
+ netmask 255.255.255.0
+iface eth6 inet static
+ address 1.11.12.13
+ netmask 255.255.255.0
+iface eth7 inet static
+ address 1.14.15.16
+ netmask 255.255.255.0
+EOF
+cat >tests/up.2 <<EOF
+====stdout====
+====stderr====
+run-parts --verbose /etc/network/if-pre-up.d
+Configuring interface eth0=eth0 (inet)
+run-parts --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth0 --address 1.2.3.4 --netmask 255.255.255.0 --up
+
+run-parts --verbose /etc/network/if-up.d
+Configuring interface eth1=eth1 (inet)
+run-parts --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth1 --address 1.3.4.5 --netmask 255.255.255.0 --up
+
+run-parts --verbose /etc/network/if-up.d
+Configuring interface eth2=eth2 (inet)
+run-parts --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth2 --address 1.4.5.6 --netmask 255.255.255.0 --up
+
+run-parts --verbose /etc/network/if-up.d
+Configuring interface eth3=eth3 (inet)
+run-parts --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth3 --address 1.5.6.7 --netmask 255.255.255.0 --up
+
+run-parts --verbose /etc/network/if-up.d
+Configuring interface eth4=eth4 (inet)
+run-parts --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth4 --address 1.7.8.9 --netmask 255.255.255.0 --up
+
+run-parts --verbose /etc/network/if-up.d
+Configuring interface eth5=eth5 (inet)
+run-parts --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth5 --address 1.8.9.10 --netmask 255.255.255.0 --up
+
+run-parts --verbose /etc/network/if-up.d
+run-parts --verbose /etc/network/if-up.d
+EOF
+
+cat >tests/testcase.3 <<EOF
+# RUN: -a
+auto eth0
+iface eth0 inet static
+ address 1.2.3.4
+ netmask 255.255.255.0
+iface eth0 inet6 static
+ address 3ffe:ffff:100:f101::1
+ netmask 64
+EOF
+cat >tests/up.3 <<EOF
+====stdout====
+====stderr====
+run-parts --verbose /etc/network/if-pre-up.d
+Configuring interface eth0=eth0 (inet)
+run-parts --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth0 --address 1.2.3.4 --netmask 255.255.255.0 --up
+
+run-parts --verbose /etc/network/if-up.d
+Configuring interface eth0=eth0 (inet6)
+run-parts --verbose /etc/network/if-pre-up.d
+FIXME: Add proper commands here for ipv6
+
+
+run-parts --verbose /etc/network/if-up.d
+run-parts --verbose /etc/network/if-up.d
+EOF
+
+cat >tests/testcase.4 <<EOF
+# RUN: eth0=work
+mapping eth0
+ script tests/map.eth0.work
+iface work inet static
+ address 1.2.3.4
+ netmask 255.255.255.0
+ up echo hi
+ post-up echo hello
+EOF
+cat >tests/up.4 <<EOF
+====stdout====
+====stderr====
+Configuring interface eth0=work (inet)
+run-parts --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth0 --address 1.2.3.4 --netmask 255.255.255.0 --up
+
+echo hi
+echo hello
+run-parts --verbose /etc/network/if-up.d
+EOF
+
+cat >tests/testcase.5 <<EOF
+# RUN: -a
+auto eth0
+iface eth0 inet static
+ address 1.2.3.4
+ netmask 255.255.255.0
+ hwaddress ether 00:DE:AD:00:BE:AF
+EOF
+cat >tests/up.5 <<EOF
+====stdout====
+====stderr====
+run-parts --verbose /etc/network/if-pre-up.d
+Configuring interface eth0=eth0 (inet)
+run-parts --verbose /etc/network/if-pre-up.d
+Warning: Option hwaddress: 00:DE:AD:00:BE:AF not yet supported
+inetutils-ifconfig --interface eth0 --address 1.2.3.4 --netmask 255.255.255.0 --up
+
+run-parts --verbose /etc/network/if-up.d
+run-parts --verbose /etc/network/if-up.d
+EOF
+
+cat >tests/testcase.6 <<EOF
+# RUN: -a
+auto eth0
+iface eth0 inet static
+ address 1.2.3.4
+ netmask 255.255.255.0
+ hwaddress 00:DE:AD:00:BE:AF
+EOF
+cat >tests/up.6 <<EOF
+====stdout====
+====stderr====
+run-parts --verbose /etc/network/if-pre-up.d
+Configuring interface eth0=eth0 (inet)
+run-parts --verbose /etc/network/if-pre-up.d
+Warning: Option hwaddress: 00:DE:AD:00:BE:AF not yet supported
+inetutils-ifconfig --interface eth0 --address 1.2.3.4 --netmask 255.255.255.0 --up
+
+run-parts --verbose /etc/network/if-up.d
+run-parts --verbose /etc/network/if-up.d
+EOF
+
+cat >tests/testcase.7 <<EOF
+# RUN: -a
+auto eth0 eth0.1 tunnel
+iface eth0 inet static
+ address 1.2.3.4
+ netmask 255.255.255.0
+iface eth0 inet6 static
+ address 3ffe:ffff:100:f101::1
+ netmask 64
+ privext 2
+ accept_ra 0
+iface eth0.1 inet6 static
+ address 3ffe:ffff:120:f101::1
+ netmask 64
+iface tunnel inet6 6to4
+ local 1.2.3.4
+EOF
+cat >tests/up.7 <<EOF
+====stdout====
+====stderr====
+Configuring interface eth0=eth0 (inet)
+run-parts --verbose /etc/network/if-pre-up.d
+ip addr add 1.2.3.4/255.255.255.0 dev eth0
+ip link set dev eth0 up
+
+run-parts --verbose /etc/network/if-up.d
+Configuring interface eth0=eth0 (inet6)
+run-parts --verbose /etc/network/if-pre-up.d
+modprobe -q net-pf-10 > /dev/null 2>&1 || true # ignore failure.
+sysctl net.ipv6.conf.eth0.use_tempaddr=2
+sysctl net.ipv6.conf.eth0.accept_ra=0
+sysctl net.ipv6.conf.eth0.autoconf=0
+
+ip link set dev eth0 up
+ip -6 addr add 3ffe:ffff:100:f101::1/64 dev eth0
+
+run-parts --verbose /etc/network/if-up.d
+Configuring interface eth0.1=eth0.1 (inet6)
+run-parts --verbose /etc/network/if-pre-up.d
+modprobe -q net-pf-10 > /dev/null 2>&1 || true # ignore failure.
+
+
+sysctl net.ipv6.conf.eth0/1.autoconf=0
+
+ip link set dev eth0.1 up
+ip -6 addr add 3ffe:ffff:120:f101::1/64 dev eth0.1
+
+run-parts --verbose /etc/network/if-up.d
+Configuring interface tunnel=tunnel (inet6)
+run-parts --verbose /etc/network/if-pre-up.d
+modprobe -q net-pf-10 > /dev/null 2>&1 || true # ignore failure.
+ip tunnel add tunnel mode sit remote any local 1.2.3.4
+ip link set tunnel up
+ip addr add 2002:0102:0304::1/16 dev tunnel
+ip route add 2000::/3 via ::192.88.99.1 dev tunnel
+run-parts --verbose /etc/network/if-up.d
+EOF
+
+# Note: Testcase 7 is not run on GNU/Hurd, tunnel is not yet implemented.
+result=true
+for test in 1 2 3 4 5 6; do
+ args="$(cat tests/testcase.$test | sed -n 's/^# RUN: //p')"
+ ./ifup -nv --force -i tests/testcase.$test $args \
+ >tests/up-res-out.$test 2>tests/up-res-err.$test ||
+ true
+ (echo "====stdout===="; cat tests/up-res-out.$test
+ echo "====stderr===="; cat tests/up-res-err.$test) > tests/up-res.$test
+
+ echo "Testcase $test: $args"
+
+ if diff -ub tests/up.$test tests/up-res.$test; then
+ echo "(okay)"
+ else
+ echo "(failed)"
+ result=false
+ fi
+ echo "=========="
+done
+
+if $result; then
+ echo "(okay overall)"
+ exit 0
+else
+ echo "(failed overall)"
+ exit 1
+fi
--- ifupdown-0.7~rc3.orig/ifupdown.nw 2012-05-14 21:49:57.000000000 +0200
+++ ifupdown-0.7~rc3/ifupdown.nw 2012-05-22 11:01:57.000000000 +0200
@@ -4753,6 +4753,26 @@
<<common functions implementations>>
@
+\subsection{Hurd-specific functions}
+
+<<archhurd.h>>=
+/* no OS-specific functions yet */
+<<common functions declarations>>
+@
+
+<<archhurd.c>>=
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/utsname.h>
+#include <sys/stat.h>
+
+#include "archhurd.h"
+
+<<common functions implementations>>
+@
+
\section{Linux Address Families}
\subsection{IPv4 Address Family}
@@ -5452,6 +5472,189 @@
@
+\section{Hurd Address Families}
+\subsection{IPv4 Address Family}
+
+<<inet.defn>>=
+architecture hurd
+
+<<Hurd inet methods>>
+@
+
+<<Hurd inet methods>>=
+<<Hurd inet methods: loopback>>
+
+<<Hurd inet methods: static>>
+
+<<inet methods: manual>>
+
+<<Hurd inet methods: dhcp>>
+
+<<inet methods: bootp>>
+
+<<inet methods: ppp>>
+
+<<inet methods: wvdial>>
+
+<<inet methods: ipv4ll>>
+@
+
+<<Hurd inet methods: loopback>>=
+method loopback
+ description
+ This method may be used to define the IPv4 loopback interface.
+
+ up
+ inetutils-ifconfig --interface %iface% 127.0.0.1 --up
+
+ down
+ inetutils-ifconfig --interface %iface% --down
+@
+
+<<Hurd inet methods: static>>=
+method static
+ description
+ This method may be used to define Ethernet interfaces with statically
+ allocated IPv4 addresses.
+
+ options
+ address address -- Address (dotted quad/netmask) *required*
+ netmask mask -- Netmask (dotted quad or CIDR)
+ broadcast broadcast_address -- Broadcast address (dotted quad)
+ metric metric -- Routing metric for default gateway (integer)
+ gateway address -- Default gateway (dotted quad)
+ pointopoint address -- Address of other end point (dotted quad). \
+ Note the spelling of "point-to".
+ hwaddress address -- Link local address (Not yet supported)
+ mtu size -- MTU size
+
+ conversion
+ hwaddress cleanup_hwaddress
+
+ up
+ [[Warning: Option hwaddress: %hwaddress% not yet supported]]
+ inetutils-ifconfig --interface %iface% --address %address% [[--netmask %netmask%]] \
+ [[--broadcast %broadcast%]] [[--mtu %mtu%]] --up
+ [[fsysopts /servers/socket/2 $(showtrans /servers/socket/2) --gateway %gateway% ]]
+
+ down
+ inetutils-ifconfig --interface %iface% --down
+@
+
+<<Hurd inet methods: dhcp>>=
+method dhcp
+ description
+ This method may be used to obtain an address via DHCP with any of
+ the tools: dhclient, udhcpc, dhcpcd.
+ (They have been listed in their order of precedence.)
+ If you have a complicated DHCP setup you should
+ note that some of these clients use their own configuration files
+ and do not obtain their configuration information via *ifup*.
+
+ options
+ hostname hostname -- Hostname to be requested (dhcpcd, udhcpc)
+ leasetime leasetime -- Preferred lease time in seconds (dhcpcd)
+ vendor vendor -- Vendor class identifier (dhcpcd)
+ client client -- Client identifier (dhcpcd, udhcpc)
+ hwaddress address -- Hardware Address (Not yet supported)
+
+ conversion
+ hwaddress cleanup_hwaddress
+
+ up
+ [[Warning: Option hwaddress: %hwaddress% not yet supported]]
+ dhclient -1 -v -pf /run/dhclient.%iface%.pid -lf /var/lib/dhcp/dhclient.%iface%.leases %iface% \
+ if (execable("/sbin/dhclient"))
+ udhcpc -n -p /run/udhcpc.%iface%.pid -i %iface% [[-H %hostname%]] \
+ [[-c %client%]] \
+ elsif (execable("/sbin/udhcpc"))
+ dhcpcd [[-h %hostname%]] [[-i %vendor%]] [[-I %client%]] \
+ [[-l %leasetime%]] %iface% \
+ elsif (execable("/sbin/dhcpcd"))
+
+ down
+ dhclient -v -r -pf /run/dhclient.%iface%.pid -lf /var/lib/dhcp/dhclient.%iface%.leases %iface% \
+ if (execable("/sbin/dhclient"))
+ kill -USR2 $(cat /run/udhcpc.%iface%.pid); kill -TERM $(cat /run/udhcpc.%iface%.pid) \
+ elsif (execable("/sbin/udhcpc"))
+ dhcpcd -k %iface% \
+ elsif (execable("/sbin/dhcpcd"))
+
+ ifconfig --interface %iface% --down
+@
+
+\subsection{IPv6 Address Family}
+
+<<inet6.defn>>=
+architecture hurd
+
+method loopback
+ description
+ This method may be used to define the IPv6 loopback interface.
+ up
+ [[FIXME: Add proper commands here for ipv6]]
+ down
+ [[FIXME: Add proper commands here for ipv6]]
+
+method static
+ description
+ This method may be used to define interfaces with statically assigned
+ IPv6 addresses.
+
+ options
+ address address -- Address (colon delimited) *required*
+ netmask mask -- Netmask (number of bits, eg 64) *required*
+ gateway address -- Default gateway (colon delimited)
+ media type -- Medium type, driver dependent
+ hwaddress address -- Hardware address (Not yet supported)
+ mtu size -- MTU size
+
+ conversion
+ hwaddress cleanup_hwaddress
+
+ up
+ [[FIXME: Add proper commands here for ipv6]]
+ [[Warning: Option media: %media% not yet supported]]
+ [[Warning: Option hwaddress: %hwaddress% not yet supported]]
+
+ down
+ [[FIXME: Add proper commands here for ipv6]]
+
+method manual
+ description
+ This method may be used to define interfaces for which no configuration
+ is done by default. Such interfaces can be configured manually by
+ means of *up* and *down* commands or /etc/network/if-*.d scripts.
+
+ up
+
+ down
+
+method dhcp
+ description
+ This method may be used to obtain network interface configuration via
+ stateful DHCPv6 with dhclient. In stateful DHCPv6, the DHCP server is
+ responsible for assigning addresses to clients.
+
+ options
+ hwaddress address -- Hardware address (Not yet supported)
+
+ conversion
+ hwaddress cleanup_hwaddress
+
+ up
+ [[Warning: Option hwaddress: %hwaddress% not yet supported]]
+ inetutils-ifconfig --interface %iface% --up
+ dhclient -6 -1 -pf /run/dhclient6.%iface%.pid -lf /var/lib/dhcp/dhclient6.%iface%.leases %iface% \
+ if (execable("/sbin/dhclient"))
+
+ down
+ dhclient -6 -r -pf /run/dhclient6.%iface%.pid -lf /var/lib/dhcp/dhclient6.%iface%.leases %iface% \
+ if (execable("/sbin/dhclient"))
+ inetutils-ifconfig --interface %iface% --down
+
+@
+
\section{Internal address metafamily}
<<address family declarations>>=
@@ -5501,6 +5704,13 @@
method none
description
+ up
+ down
+
+architecture hurd
+
+method none
+ description
up
down
Reply to: