2022-02-05 14:23:32 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
|
|
|
|
# Copyright (C) 2018 Team LibreELEC (https://libreelec.tv)
|
|
|
|
# Copyright (C) 2018-present Team CoreELEC (https://coreelec.org)
|
|
|
|
|
|
|
|
PKG_NAME="busybox"
|
|
|
|
PKG_VERSION="1.32.1"
|
|
|
|
PKG_SHA256="9d57c4bd33974140fd4111260468af22856f12f5b5ef7c70c8d9b75c712a0dee"
|
|
|
|
PKG_LICENSE="GPL"
|
|
|
|
PKG_SITE="http://www.busybox.net"
|
|
|
|
PKG_URL="http://busybox.net/downloads/$PKG_NAME-$PKG_VERSION.tar.bz2"
|
|
|
|
PKG_DEPENDS_HOST="gcc:host"
|
|
|
|
PKG_DEPENDS_TARGET="toolchain busybox:host hdparm hd-idle dosfstools e2fsprogs zip unzip usbutils parted procps-ng gptfdisk libtirpc"
|
|
|
|
PKG_DEPENDS_INIT="toolchain libtirpc"
|
|
|
|
PKG_LONGDESC="BusyBox combines tiny versions of many common UNIX utilities into a single small executable."
|
|
|
|
# busybox fails to build with GOLD support enabled with binutils-2.25
|
|
|
|
PKG_BUILD_FLAGS="-parallel -gold"
|
|
|
|
PKG_NEED_UNPACK="$PROJECT_DIR/$PROJECT/initramfs"
|
|
|
|
|
|
|
|
# nano text editor
|
|
|
|
if [ "$NANO_EDITOR" = "yes" ]; then
|
|
|
|
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET nano"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# nfs support
|
|
|
|
if [ "$NFS_SUPPORT" = yes ]; then
|
|
|
|
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET rpcbind"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$TARGET_ARCH" = "x86_64" ]; then
|
|
|
|
PKG_DEPENDS_TARGET+=" pciutils"
|
|
|
|
fi
|
|
|
|
|
|
|
|
pre_build_target() {
|
|
|
|
PKG_MAKE_OPTS_TARGET="ARCH=$TARGET_ARCH \
|
|
|
|
HOSTCC=$HOST_CC \
|
|
|
|
CROSS_COMPILE=$TARGET_PREFIX \
|
|
|
|
KBUILD_VERBOSE=1 \
|
|
|
|
install"
|
|
|
|
|
|
|
|
mkdir -p $PKG_BUILD/.$TARGET_NAME
|
|
|
|
cp -RP $PKG_BUILD/* $PKG_BUILD/.$TARGET_NAME
|
|
|
|
}
|
|
|
|
|
|
|
|
pre_build_host() {
|
|
|
|
PKG_MAKE_OPTS_HOST="ARCH=$TARGET_ARCH CROSS_COMPILE= KBUILD_VERBOSE=1 install"
|
|
|
|
|
|
|
|
mkdir -p $PKG_BUILD/.$HOST_NAME
|
|
|
|
cp -RP $PKG_BUILD/* $PKG_BUILD/.$HOST_NAME
|
|
|
|
}
|
|
|
|
|
|
|
|
pre_build_init() {
|
|
|
|
PKG_MAKE_OPTS_INIT="ARCH=$TARGET_ARCH \
|
|
|
|
HOSTCC=$HOST_CC \
|
|
|
|
CROSS_COMPILE=$TARGET_PREFIX \
|
|
|
|
KBUILD_VERBOSE=1 \
|
|
|
|
install"
|
|
|
|
|
|
|
|
mkdir -p $PKG_BUILD/.$TARGET_NAME-init
|
|
|
|
cp -RP $PKG_BUILD/* $PKG_BUILD/.$TARGET_NAME-init
|
|
|
|
}
|
|
|
|
|
|
|
|
configure_host() {
|
|
|
|
cd $PKG_BUILD/.$HOST_NAME
|
2022-03-16 22:03:28 +00:00
|
|
|
cp ${PKG_DIR}/config/busybox-host.conf .config
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
# set install dir
|
|
|
|
sed -i -e "s|^CONFIG_PREFIX=.*$|CONFIG_PREFIX=\"$PKG_BUILD/.install_host\"|" .config
|
|
|
|
|
|
|
|
make oldconfig
|
|
|
|
}
|
|
|
|
|
|
|
|
configure_target() {
|
|
|
|
cd $PKG_BUILD/.$TARGET_NAME
|
|
|
|
find_file_path config/busybox-target.conf
|
|
|
|
cp $FOUND_PATH .config
|
|
|
|
|
|
|
|
# set install dir
|
2022-03-16 22:03:28 +00:00
|
|
|
sed -i -e "s|^CONFIG_PREFIX=.*$|CONFIG_PREFIX=\"${INSTALL}/usr\"|" .config
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
if [ ! "$CRON_SUPPORT" = "yes" ] ; then
|
|
|
|
sed -i -e "s|^CONFIG_CROND=.*$|# CONFIG_CROND is not set|" .config
|
|
|
|
sed -i -e "s|^CONFIG_FEATURE_CROND_D=.*$|# CONFIG_FEATURE_CROND_D is not set|" .config
|
|
|
|
sed -i -e "s|^CONFIG_CRONTAB=.*$|# CONFIG_CRONTAB is not set|" .config
|
|
|
|
sed -i -e "s|^CONFIG_FEATURE_CROND_SPECIAL_TIMES=.*$|# CONFIG_FEATURE_CROND_SPECIAL_TIMES is not set|" .config
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! "$SAMBA_SUPPORT" = yes ]; then
|
|
|
|
sed -i -e "s|^CONFIG_FEATURE_MOUNT_CIFS=.*$|# CONFIG_FEATURE_MOUNT_CIFS is not set|" .config
|
|
|
|
fi
|
|
|
|
|
|
|
|
# optimize for size
|
|
|
|
CFLAGS=`echo $CFLAGS | sed -e "s|-Ofast|-Os|"`
|
|
|
|
CFLAGS=`echo $CFLAGS | sed -e "s|-O.|-Os|"`
|
|
|
|
CFLAGS="$CFLAGS -I$SYSROOT_PREFIX/usr/include/tirpc"
|
|
|
|
|
|
|
|
LDFLAGS="$LDFLAGS -fwhole-program"
|
|
|
|
|
|
|
|
make oldconfig
|
|
|
|
}
|
|
|
|
|
|
|
|
configure_init() {
|
|
|
|
cd $PKG_BUILD/.$TARGET_NAME-init
|
|
|
|
find_file_path config/busybox-init.conf
|
|
|
|
cp $FOUND_PATH .config
|
|
|
|
|
|
|
|
# set install dir
|
2022-03-16 22:03:28 +00:00
|
|
|
sed -i -e "s|^CONFIG_PREFIX=.*$|CONFIG_PREFIX=\"${INSTALL}/usr\"|" .config
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
# optimize for size
|
|
|
|
CFLAGS=`echo $CFLAGS | sed -e "s|-Ofast|-Os|"`
|
|
|
|
CFLAGS=`echo $CFLAGS | sed -e "s|-O.|-Os|"`
|
|
|
|
CFLAGS="$CFLAGS -I$SYSROOT_PREFIX/usr/include/tirpc"
|
|
|
|
|
|
|
|
LDFLAGS="$LDFLAGS -fwhole-program"
|
|
|
|
|
|
|
|
make oldconfig
|
|
|
|
}
|
|
|
|
|
|
|
|
makeinstall_host() {
|
|
|
|
mkdir -p $TOOLCHAIN/bin
|
|
|
|
cp -R $PKG_BUILD/.install_host/bin/* $TOOLCHAIN/bin
|
|
|
|
}
|
|
|
|
|
|
|
|
makeinstall_target() {
|
2022-03-16 22:03:28 +00:00
|
|
|
mkdir -p ${INSTALL}/usr/bin
|
|
|
|
[ $TARGET_ARCH = x86_64 ] && cp ${PKG_DIR}/scripts/getedid ${INSTALL}/usr/bin
|
|
|
|
cp ${PKG_DIR}/scripts/createlog ${INSTALL}/usr/bin/
|
|
|
|
cp ${PKG_DIR}/scripts/dtfile ${INSTALL}/usr/bin
|
|
|
|
cp ${PKG_DIR}/scripts/dtname ${INSTALL}/usr/bin
|
|
|
|
cp ${PKG_DIR}/scripts/lsb_release ${INSTALL}/usr/bin/
|
|
|
|
cp ${PKG_DIR}/scripts/pastebinit ${INSTALL}/usr/bin/
|
|
|
|
ln -sf pastebinit ${INSTALL}/usr/bin/paste
|
|
|
|
|
|
|
|
mkdir -p ${INSTALL}/usr/lib/coreelec
|
|
|
|
cp ${PKG_DIR}/scripts/functions ${INSTALL}/usr/lib/coreelec
|
|
|
|
cp ${PKG_DIR}/scripts/fs-resize ${INSTALL}/usr/lib/coreelec
|
2022-03-29 10:43:27 +00:00
|
|
|
sed -e "s/@DISTRONAME@/${DISTRONAME}/g" \
|
2022-03-16 22:03:28 +00:00
|
|
|
-i ${INSTALL}/usr/lib/coreelec/fs-resize
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
if listcontains "${FIRMWARE}" "rpi-eeprom"; then
|
2022-03-16 22:03:28 +00:00
|
|
|
cp ${PKG_DIR}/scripts/rpi-flash-firmware ${INSTALL}/usr/lib/libreelec
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|
2022-03-16 22:03:28 +00:00
|
|
|
mkdir -p ${INSTALL}/etc
|
|
|
|
cp ${PKG_DIR}/config/profile ${INSTALL}/etc
|
|
|
|
cp ${PKG_DIR}/config/inputrc ${INSTALL}/etc
|
|
|
|
cp ${PKG_DIR}/config/httpd.conf ${INSTALL}/etc
|
|
|
|
cp ${PKG_DIR}/config/suspend-modules.conf ${INSTALL}/etc
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
# /etc/fstab is needed by...
|
2022-03-16 22:03:28 +00:00
|
|
|
touch ${INSTALL}/etc/fstab
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
# /etc/machine-id, needed by systemd and dbus
|
2022-03-16 22:03:28 +00:00
|
|
|
ln -sf /storage/.cache/systemd-machine-id ${INSTALL}/etc/machine-id
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
# /etc/mtab is needed by udisks etc...
|
2022-03-16 22:03:28 +00:00
|
|
|
ln -sf /proc/self/mounts ${INSTALL}/etc/mtab
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
# create /etc/hostname
|
2022-03-16 22:03:28 +00:00
|
|
|
ln -sf /proc/sys/kernel/hostname ${INSTALL}/etc/hostname
|
2022-02-05 14:23:32 +00:00
|
|
|
|
2022-05-12 00:47:42 +00:00
|
|
|
# create folder for named tables support
|
|
|
|
ln -sf /storage/.config/iproute2 $INSTALL/etc/iproute2
|
|
|
|
|
2022-02-05 14:23:32 +00:00
|
|
|
# add webroot
|
2022-03-16 22:03:28 +00:00
|
|
|
mkdir -p ${INSTALL}/usr/www
|
|
|
|
echo "It works" > ${INSTALL}/usr/www/index.html
|
2022-02-05 14:23:32 +00:00
|
|
|
|
2022-03-16 22:03:28 +00:00
|
|
|
mkdir -p ${INSTALL}/usr/www/error
|
|
|
|
echo "404" > ${INSTALL}/usr/www/error/404.html
|
2022-02-05 14:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
post_install() {
|
2022-04-03 20:41:49 +00:00
|
|
|
### This resolves a conflict with the bash package.
|
|
|
|
if [ "$(readlink ${INSTALL}/usr/bin/sh)" = "busybox" ]
|
|
|
|
then
|
|
|
|
rm -f ${INSTALL}/usr/bin/sh
|
|
|
|
ln -s bash ${INSTALL}/usr/bin/sh
|
|
|
|
fi
|
2022-03-16 22:03:28 +00:00
|
|
|
ROOT_PWD="`$TOOLCHAIN/bin/cryptpw -m sha512 ${ROOT_PASSWORD}`"
|
2022-02-05 14:23:32 +00:00
|
|
|
|
2022-03-16 22:03:28 +00:00
|
|
|
echo "chmod 4755 ${INSTALL}/usr/bin/busybox" >> $FAKEROOT_SCRIPT
|
|
|
|
echo "chmod 000 ${INSTALL}/usr/cache/shadow" >> $FAKEROOT_SCRIPT
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
add_user root "$ROOT_PWD" 0 0 "Root User" "/storage" "/bin/sh"
|
|
|
|
add_group root 0
|
|
|
|
add_group users 100
|
|
|
|
|
|
|
|
add_user nobody x 65534 65534 "Nobody" "/" "/bin/sh"
|
|
|
|
add_group nogroup 65534
|
|
|
|
|
|
|
|
enable_service shell.service
|
|
|
|
enable_service show-version.service
|
|
|
|
enable_service var.mount
|
|
|
|
listcontains "${FIRMWARE}" "rpi-eeprom" && enable_service rpi-flash-firmware.service
|
|
|
|
|
|
|
|
# cron support
|
|
|
|
if [ "$CRON_SUPPORT" = "yes" ] ; then
|
2022-03-16 22:03:28 +00:00
|
|
|
mkdir -p ${INSTALL}/usr/lib/systemd/system
|
|
|
|
cp ${PKG_DIR}/system.d.opt/cron.service ${INSTALL}/usr/lib/systemd/system
|
2022-02-05 14:23:32 +00:00
|
|
|
enable_service cron.service
|
2022-03-16 22:03:28 +00:00
|
|
|
mkdir -p ${INSTALL}/usr/share/services
|
|
|
|
cp -P ${PKG_DIR}/default.d/*.conf ${INSTALL}/usr/share/services
|
|
|
|
cp ${PKG_DIR}/system.d.opt/cron-defaults.service ${INSTALL}/usr/lib/systemd/system
|
2022-02-05 14:23:32 +00:00
|
|
|
enable_service cron-defaults.service
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
makeinstall_init() {
|
2022-03-16 22:03:28 +00:00
|
|
|
mkdir -p ${INSTALL}/bin
|
|
|
|
ln -sf busybox ${INSTALL}/usr/bin/sh
|
|
|
|
ln -sf busybox ${INSTALL}/usr/bin/bc
|
|
|
|
chmod 4755 ${INSTALL}/usr/bin/busybox
|
2022-02-05 14:23:32 +00:00
|
|
|
|
2022-03-16 22:03:28 +00:00
|
|
|
mkdir -p ${INSTALL}/etc
|
|
|
|
touch ${INSTALL}/etc/fstab
|
|
|
|
ln -sf /proc/self/mounts ${INSTALL}/etc/mtab
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
if find_file_path initramfs/platform_init; then
|
2022-03-16 22:03:28 +00:00
|
|
|
cp ${FOUND_PATH} ${INSTALL}
|
|
|
|
sed -e "s/@BOOT_LABEL@/${DISTRO_BOOTLABEL}/g" \
|
|
|
|
-e "s/@DISK_LABEL@/${DISTRO_DISKLABEL}/g" \
|
|
|
|
-i ${INSTALL}/platform_init
|
|
|
|
chmod 755 ${INSTALL}/platform_init
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|
2022-03-16 22:03:28 +00:00
|
|
|
cp ${PKG_DIR}/scripts/functions ${INSTALL}
|
|
|
|
cp ${PKG_DIR}/scripts/init ${INSTALL}
|
2022-02-05 14:23:32 +00:00
|
|
|
|
2022-02-11 01:00:14 +00:00
|
|
|
if [ -e "${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/device.init" ]
|
|
|
|
then
|
|
|
|
cp ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/device.init ${INSTALL}
|
2022-02-11 11:04:26 +00:00
|
|
|
else
|
|
|
|
touch ${INSTALL}/device.init
|
2022-02-11 01:00:14 +00:00
|
|
|
fi
|
2022-02-11 11:04:26 +00:00
|
|
|
chmod 755 ${INSTALL}/device.init
|
2022-02-05 14:23:32 +00:00
|
|
|
|
2022-03-16 22:03:28 +00:00
|
|
|
sed -e "s/@DISTRONAME@/${DISTRONAME}/g" \
|
2022-03-29 10:43:27 +00:00
|
|
|
-e "s/@DEVICENAME@/${DEVICE}/g" \
|
2022-03-16 22:03:28 +00:00
|
|
|
-e "s/@KERNEL_NAME@/${KERNEL_NAME}/g" \
|
|
|
|
-i ${INSTALL}/init
|
|
|
|
chmod 755 ${INSTALL}/init
|
2022-02-05 14:23:32 +00:00
|
|
|
}
|