From be1c3ba8581ff35eef96f90ec82c2d71b4b21d8b Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@netc.eu>
Date: Sat, 20 Jul 2019 23:56:09 +0700
Subject: [PATCH] busybox: build dynamically and fix directories

---
 core/busybox/build           |   9 ++-
 core/busybox/checksums       |   3 +-
 core/busybox/files/.config   |   4 +-
 core/busybox/files/mdev.conf | 117 -----------------------------------
 core/busybox/sources         |   1 -
 core/busybox/version         |   2 +-
 6 files changed, 10 insertions(+), 126 deletions(-)
 delete mode 100644 core/busybox/files/mdev.conf

diff --git a/core/busybox/build b/core/busybox/build
index b428391d..a840cd0a 100755
--- a/core/busybox/build
+++ b/core/busybox/build
@@ -6,6 +6,12 @@ make install
 # Work around no 'DESTDIR'.
 cp -a _install/. "$1"
 
+# Fix package filesystem.
+mv "$1/bin/"* "$1/usr/bin"
+mv "$1/sbin/"* "$1/usr/bin"
+mv "$1/usr/sbin/"* "$1/usr/bin"
+rmdir "$1/bin" "$1/usr/sbin" "$1/sbin"
+
 # Install runit services.
 install -Dm755 acpid.run "$1/etc/sv/acpid/run"
 install -Dm755 crond.run "$1/etc/sv/crond/run"
@@ -13,6 +19,3 @@ install -Dm755 syslogd.run "$1/etc/sv/syslogd/run"
 ln -s /run/runit/supervise.acpid "$1/etc/sv/acpid/supervise"
 ln -s /run/runit/supervise.crond "$1/etc/sv/crond/supervise"
 ln -s /run/runit/supervise.syslogd "$1/etc/sv/syslogd/supervise"
-
-# Install mdev config.
-cp mdev.conf "$1/etc/mdev.conf"
diff --git a/core/busybox/checksums b/core/busybox/checksums
index 82a90a26..29eef35b 100644
--- a/core/busybox/checksums
+++ b/core/busybox/checksums
@@ -1,6 +1,5 @@
 3d1d04a4dbd34048f4794815a5c48ebb9eb53c5277e09ffffc060323b95dfbdc  busybox-1.30.1.tar.bz2
-79178c0d52767fc76208c366d20ec774cb5380786b6387486be3389a6493b4f6  .config
+544cbd08a836d63a4d98d0982a395612f37c0a2a122c7bf7137e1d731cc39454  .config
 6c3eb5cf839c7a31c337df0cd8388b397e1415ffa7a63e9678552c9c63dd869f  acpid.run
 814dea14ac612125e97dcc1d619219b2c9dfc14850bf48d858421fb2c98eca12  crond.run
 4a5981f4b0d791fe9b84b0b2e01ae905f6565c8245b3cd603e6decf34ddad71a  syslogd.run
-0dd496b956e664f2f267fbcf3563977a4b16ca01f9af208653fff25d8b0da431  mdev.conf
diff --git a/core/busybox/files/.config b/core/busybox/files/.config
index c4345ff2..a238923f 100644
--- a/core/busybox/files/.config
+++ b/core/busybox/files/.config
@@ -40,8 +40,8 @@ CONFIG_PLATFORM_LINUX=y
 #
 # Build Options
 #
-CONFIG_STATIC=y
-# CONFIG_PIE is not set
+# CONFIG_STATIC is not set
+CONFIG_PIE=y
 # CONFIG_NOMMU is not set
 # CONFIG_BUILD_LIBBUSYBOX is not set
 # CONFIG_FEATURE_LIBBUSYBOX_STATIC is not set
diff --git a/core/busybox/files/mdev.conf b/core/busybox/files/mdev.conf
deleted file mode 100644
index 70b624d8..00000000
--- a/core/busybox/files/mdev.conf
+++ /dev/null
@@ -1,117 +0,0 @@
-# mdev-like-a-boss
-
-# Syntax:
-# [-]devicename_regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
-# [-]$ENVVAR=regex    user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
-# [-]@maj,min[-min2]  user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
-#
-# [-]: do not stop on this match, continue reading mdev.conf
-# =: move, >: move and create a symlink
-# !: do not create device node
-# @|$|*: run cmd if $ACTION=remove, @cmd if $ACTION=add, *cmd in all cases
-
-# support module loading on hotplug
-$MODALIAS=.*    root:root 660 @modprobe -b "$MODALIAS"
-
-# null may already exist; therefore ownership has to be changed with command
-null        root:root 666 @chmod 666 $MDEV
-zero        root:root 666
-full        root:root 666
-random      root:root 444
-urandom     root:root 444
-hwrandom    root:root 444
-grsec       root:root 660
-
-# Kernel-based Virtual Machine.
-kvm     root:kvm 660
-
-# vhost-net, to be used with kvm.
-vhost-net   root:kvm 660
-
-kmem        root:root 640
-mem         root:root 640
-port        root:root 640
-# console may already exist; therefore ownership has to be changed with command
-console     root:tty 600 @chmod 600 $MDEV
-ptmx        root:tty 666
-pty.*       root:tty 660
-
-# Typical devices
-tty         root:tty 666
-tty[0-9]*   root:tty 660
-vcsa*[0-9]* root:tty 660
-ttyS[0-9]*  root:uucp 660
-
-# block devices
-ram([0-9]*)     root:disk 660 >rd/%1
-loop([0-9]+)    root:disk 660 >loop/%1
-sd[a-z].*       root:disk 660 */opt/mdev/helpers/storage-device
-vd[a-z].*       root:disk 660 */opt/mdev/helpers/storage-device
-hd[a-z].*       root:disk 660 */opt/mdev/helpers/storage-device
-md[0-9]*        root:disk 660 */opt/mdev/helpers/storage-device
-dm-[0-9]*       root:disk 660 */opt/mdev/helpers/storage-device
-bcache[0-9]*    root:disk 660 */opt/mdev/helpers/storage-device
-mmcblk[0-9].*   root:disk 660 */opt/mdev/helpers/storage-device
-sr[0-9]*        root:cdrom 660 @ln -sf $MDEV cdrom
-fd[0-9]*        root:floppy 660
-
-# Run settle-nics every time new NIC appear.
-# If you don't want to auto-populate /etc/mactab with NICs, run 'settle-nis' without '--write-mactab' param.
--SUBSYSTEM=net;DEVPATH=.*/net/.*;.*     root:root 600 @/opt/mdev/helpers/settle-nics --write-mactab
-
-net/tun[0-9]*   root:kvm 660
-net/tap[0-9]*   root:root 600
-
-# alsa sound devices and audio stuff
-SUBSYSTEM=sound;.*  root:audio 660 @/opt/mdev/helpers/sound-control
-
-adsp        root:audio 660 >sound/
-audio       root:audio 660 >sound/
-dsp         root:audio 660 >sound/
-mixer       root:audio 660 >sound/
-sequencer.* root:audio 660 >sound/
-
-
-# raid controllers
-cciss!(.*)  root:disk 660 =cciss/%1
-ida!(.*)    root:disk 660 =ida/%1
-rd!(.*)     root:disk 660 =rd/%1
-
-
-fuse        root:root 666
-
-card[0-9]   root:video 660 =dri/
-
-agpgart     root:root 660 >misc/
-psaux       root:root 660 >misc/
-rtc         root:root 664 >misc/
-
-# input stuff
-SUBSYSTEM=input;.* root:input 660
-
-# v4l stuff
-vbi[0-9]    root:video 660 >v4l/
-video[0-9]  root:video 660 >v4l/
-
-# dvb stuff
-dvb.*       root:video 660
-
-# drm etc
-dri/.*      root:video 660
-
-# Don't create old usbdev* devices.
-usbdev[0-9].[0-9]* root:root 660 !
-
-# Stop creating x:x:x:x which looks like /dev/dm-*
-[0-9]+\:[0-9]+\:[0-9]+\:[0-9]+ root:root 660 !
-
-# /dev/cpu support.
-microcode       root:root 600 =cpu/
-cpu([0-9]+)     root:root 600 =cpu/%1/cpuid
-msr([0-9]+)     root:root 600 =cpu/%1/msr
-
-# Populate /dev/bus/usb.
-SUBSYSTEM=usb;DEVTYPE=usb_device;.* root:root 660 */opt/mdev/helpers/dev-bus-usb
-
-# Catch-all other devices, Right now useful only for debuging.
-#.* root:root 660 */opt/mdev/helpers/catch-all
diff --git a/core/busybox/sources b/core/busybox/sources
index 744149c5..49ec684f 100644
--- a/core/busybox/sources
+++ b/core/busybox/sources
@@ -3,4 +3,3 @@ files/.config
 files/acpid.run
 files/crond.run
 files/syslogd.run
-files/mdev.conf
diff --git a/core/busybox/version b/core/busybox/version
index b944d8ca..31f1103e 100644
--- a/core/busybox/version
+++ b/core/busybox/version
@@ -1 +1 @@
-1.30.1 11
+1.30.1 12