]> git.armaanb.net Git - asd-repo.git/blob - core/busybox/build
busybox: don't build powertop
[asd-repo.git] / core / busybox / build
1 #!/bin/sh -e
2
3 for patch in *.patch; do
4     patch -p1 < "$patch"
5 done
6
7 # Remove forced gcc/g++ usage so builds work on gcc-less systems.
8 sed -i "s#= g[c+][c+]#= ${CC:=cc}#g" Makefile
9 sed -i "s#\(\$(CROSS_COMPILE)\)gcc#\1${CC}#g" Makefile
10
11 # Ensure that busybox's build system is aware that 'cc' may point
12 # to clang rather than GCC. This is the case in non-GCC systems.
13 case $("$CC" --version) in (*clang*)
14     sed -i "s&\(\$(CC),\)clang&\1${CC}&g" Makefile.flags
15 esac
16
17 # Build and install regular busybox.
18 # This excludes utilities which require 'suid' to function.
19 cp -f config .config
20 make CC="$CC" HOSTCC="$CC"
21 make CONFIG_PREFIX="$1/usr" install
22
23 # Rename the binary temporarily.
24 mv "$1/usr/bin/busybox" "$1/usr/bin/busybox-nosuid"
25
26 # Build and install suid busybox.
27 # This _only_ includes utlities which require 'suid' to function.
28 cp -f config-suid .config
29 make CC="$CC" HOSTCC="$CC"
30 make CONFIG_PREFIX="$1/usr" install
31
32 # Aptly name the busybox binaries.
33 mv -f "$1/usr/bin/busybox"        "$1/usr/bin/busybox-suid"
34 mv -f "$1/usr/bin/busybox-nosuid" "$1/usr/bin/busybox"
35
36 # Install the non-suid symlinks.
37 "$1/usr/bin/busybox" --list | while read -r bin; do
38     ln -s busybox "$1/usr/bin/$bin"
39 done
40
41 # Install the suid symlinks.
42 "$1/usr/bin/busybox-suid" --list | while read -r bin; do
43     ln -s busybox-suid "$1/usr/bin/$bin"
44 done
45
46 # Set suid on busybox suid.
47 chmod u+s "$1/usr/bin/busybox-suid"
48
49 # Install runit services.
50 install -Dm755 crond.run           "$1/etc/sv/crond/run"
51 install -Dm755 syslogd.run         "$1/etc/sv/syslogd/run"
52 install -Dm755 mdev.run            "$1/etc/sv/mdev/run"
53 install -Dm755 ntpd.run            "$1/etc/sv/ntpd/run"
54 ln -s /run/runit/supervise.crond   "$1/etc/sv/crond/supervise"
55 ln -s /run/runit/supervise.syslogd "$1/etc/sv/syslogd/supervise"
56 ln -s /run/runit/supervise.mdev    "$1/etc/sv/mdev/supervise"
57 ln -s /run/runit/supervise.ntpd    "$1/etc/sv/ntpd/supervise"
58
59 install -Dm644 mdev.conf "$1/etc/mdev.conf"
60 install -Dm644 docs/busybox.1 "$1/usr/share/man/man1/busybox.1"
61
62 rm "$1/usr/bin/sh"