wok-tiny view busybox-net/receipt @ rev 162

busybox: /etc/mtab is a symlink
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Jun 11 16:42:53 2020 +0000 (2020-06-11)
parents 424fb2c33d92
children eb617e43dc08
line source
1 # SliTaz package receipt.
3 PACKAGE="busybox-net"
4 VERSION="1.28-20170822"
5 GIT_TAG="753c4045e4f287fc4b4788afd94f58738a7f04b4"
6 CATEGORY="base-system"
7 SHORT_DESC="Busybox UNIX utilities with many network commands."
8 MAINTAINER="pascal.bellard@slitaz.org"
9 LICENSE="GPL2"
10 [ -n "$TARGET" ] || TARGET="i486"
11 DEPENDS="busybox"
12 BUILD_DEPENDS="bzip2 uclibc-cross-compiler-$TARGET wget advancecomp"
13 TARBALL="busybox-$VERSION.tar.bz2"
14 WEB_SITE="http://www.busybox.net/"
15 WGET_URL="https://git.busybox.net/busybox/snapshot/busybox-$GIT_TAG.tar.bz2"
16 CONFIG_FILES="/etc/dnsd.conf /etc/inetd.conf /etc/udhcpd.conf /etc/resolv.conf \
17 /etc/network.conf /etc/inetd.conf"
19 apply_bb_patchs()
20 {
21 cd $src
22 while read file; do
23 [ -f done.$file ] && continue
24 echo "Apply $file..."
25 patch -p1 < $stuff/busybox-git-$file || return 1
26 touch done.$file
27 done <<EOT
28 stat.u
29 ris.u
30 zmodules.u
31 cmdline.u
32 fbvnc.u
33 cpio.u
34 scriptreplay.u
35 ash.u
36 EOT
37 [ $(. $WOK/linux/receipt; printf "%d%02d%02d" ${VERSION//./ }) -le 20626 ] &&
38 echo apply 0001-mdev-create-devices-from-sys-dev.patch &&
39 patch -p1 -R < $stuff/0001-mdev-create-devices-from-sys-dev.patch
40 [ "$(which advdef)" ] &&
41 sed -i 's|^cmd_gzip.*|& \&\& advdef -z4 $@|' scripts/Makefile.lib
42 cp $stuff/$PACKAGE-git.config .config
43 var="CONFIG_CROSS_COMPILER_PREFIX"
44 sed -i "s/.*$var.*/$var=\"uclibc-$TARGET-\"/" .config
45 }
47 # Rules to configure and make the package.
48 compile_rules()
49 {
50 { apply_bb_patchs &&
51 make oldconfig &&
52 make &&
53 make install
54 } || return 1
55 echo "Chmod 4755 on busybox binary..."
56 chmod 4755 _install/bin/busybox
57 mkdir -p _install/lib
58 LD_LIBRARY_PATH=/usr/share/uclibc-cross-compiler-$TARGET/lib \
59 uclibc-$TARGET-ldd busybox 2> /dev/null | \
60 awk '/=>/ { print $3 }' | while read file ; do
61 cp -a $file _install/lib
62 while [ -L "$file" ]; do
63 dir="$(dirname $file)/"
64 file="$(readlink $file)"
65 case "$file" in
66 /*) ;;
67 *) file="$dir$file";;
68 esac
69 cp -a "$file" _install/lib
70 done
71 done
72 chown 0.0 _install/lib/*
73 }
75 # Rules to gen a SliTaz package suitable for Tazpkg.
76 genpkg_rules()
77 {
78 mkdir $fs/boot $fs/bin $fs/sbin
79 cp -a $WOK/base-tiny/stuff/. $fs/
80 sed -i -e 's| *#.*$||' -e '/^$/d' $fs/etc/services
81 cp -a $src/_install/bin/busybox $fs/bin
82 for i in /bin/sh /bin/login /bin/false /sbin/mdev /init ; do
83 ln -f $fs/bin/busybox $fs$i
84 done
85 sed '/hostname/{Nd}' -i $fs/etc/init.d/network.sh
87 # Busybox config files.
88 touch $fs/etc/resolv.conf
89 cp $stuff/inetd.conf $fs/etc
90 cp $stuff/daemon $fs/etc/init.d
91 for i in crond dnsd ftpd httpd inetd klogd ntpd syslogd telnetd tftpd \
92 udhcpd zcip ; do
93 grep -qi config_$i=y $src/.config &&
94 ln -s daemon $fs/etc/init.d/$i
95 done
96 # Udhcpc stuff.
97 mkdir -p $fs/usr/share/udhcpc
98 cp $stuff/udhcp.script $fs/usr/share/udhcpc/default.script
99 chmod +x $fs/usr/share/udhcpc/default.script
101 sed -i '2,$s/^#.*//;/^$/d' $fs/etc/init.d/rc* $fs/etc/init.d/daemon \
102 $fs/etc/init.d/*.sh
103 sed -i 's/^#.*//;/^$/d' $fs/etc/*.conf $fs/etc/*tab \
104 $fs/etc/profile $fs/etc/securetty $fs/etc/shells
105 find $fs -exec touch -r $fs {} \;
106 cp $stuff/busybox-net-git.config $fs/boot/config-busybox
107 }
109 config_form()
110 {
111 if [ -z "$MODE" ]; then
112 [ -n "$INTERFACE" ] || INTERFACE=eth0
113 [ -n "$IP" ] || IP=192.168.0.6
114 [ -n "$NETMASK" ] || NETMASK=255.255.255.0
115 [ -n "$GATEWAY" ] || GATEWAY=192.168.0.1
116 [ -n "$DNS_SERVER" ] || DNS_SERVER='192.168.0.1 192.168.0.2'
117 fi
118 cat <<EOT
119 <table>
120 <tr>
121 <td>Interface</td>
122 <td><input type="text" name="INTERFACE" value="$INTERFACE" /></td>
123 </tr>
124 <tr>
125 <td>Network configuration</td>
126 <td><select name="MODE">
127 <option value="STATIC">STATIC</option>
128 <option value="DHCP"$([ "$MODE" = "DHCP" ] && echo ' selected="selected"')>DHCP</option>
129 <option value="DISABLE"$([ "$MODE" = "DISABLE" ] && echo ' selected="selected"')>DISABLE</option>
130 </select></td>
131 </tr>
132 <tr>
133 <td>Internet address</td>
134 <td><input type="text" name="IP" value="$IP" /></td>
135 </tr>
136 <tr>
137 <td>Netmask</td>
138 <td><input type="text" name="NETMASK" value="$NETMASK" /></td>
139 </tr>
140 <tr>
141 <td>Gateway</td>
142 <td><input type="text" name="GATEWAY" value="$GATEWAY" /></td>
143 </tr>
144 <tr>
145 <td>DNS server(s)</td>
146 <td><input type="text" name="DNS_SERVER" value="$DNS_SERVER" /></td>
147 </tr>
148 </table>
149 EOT
150 }
152 post_install()
153 {
154 sed -i 's|local.sh|network.sh &|' $1/etc/rcS.conf
155 chmod 4755 $1/bin/busybox
156 ln -fs /proc/mounts $1/etc/mtab
157 DHCP="no"
158 STATIC="yes"
159 case "$MODE" in
160 "") return 1;;
161 DISABLE)
162 STATIC="no" ;;
163 DHCP) DHCP="yes"
164 STATIC="no"
165 esac
166 sed -i -e "s/^DNS_SERVER=.*/DNS_SERVER=\"$DNS_SERVER\"/" \
167 -e "s/^INTERFACE=.*/INTERFACE=\"$INTERFACE\"/" \
168 -e "s/^NETMASK=.*/NETMASK=\"$NETMASK\"/" \
169 -e "s/^GATEWAY=.*/GATEWAY=\"$GATEWAY\"/" \
170 -e "s/^STATIC=.*/STATIC=\"$STATIC\"/" \
171 -e "s/^DHCP=.*/DHCP=\"$DHCP\"/" \
172 -e "s/^IP=.*/IP=\"$IP\"/" $1/etc/network.conf
173 [ -n "$HOSTNAME" ] && echo $HOSTNAME > $1/etc/hostname
174 }