#!/bin/bash
name=busybox
version=1.35.0
release=1
url='https://busybox.net'
description='BusyBox is a software suite that provides several Unix utilities in a single executable file.'
email='parduscix@yandex.ru'
maintainer='sulincix'
license=('GPLv3')
arch=(x86_64)
source=("https://busybox.net/downloads/busybox-$version.tar.bz2"
        "files/busybox.sysconf"
        "files/busybox.initramfs"
        "files/udhcpc.openrc"
        "files/udhcpc.script"
)
md5sums=("585949b1dd4292b604b7d199866e9913"
         "SKIP"
         "SKIP"
         "SKIP"
         "SKIP"
)
group=(sys.base)

cd $name-$version

setup(){
    make defconfig
    sed -i "s|.*CONFIG_STATIC_LIBGCC .*|CONFIG_STATIC_LIBGCC=y|" .config
    sed -i "s|.*CONFIG_STATIC .*|CONFIG_STATIC=y|" .config
}

build(){
    make $jobs
}

package(){
    mkdir -p ${DESTDIR}/bin/ ${DESTDIR}/etc/sysconf.d ${DESTDIR}/usr/share/initramfs-tools/{hooks,conf-hooks.d}/
    install busybox ${DESTDIR}/bin/busybox
    install ../busybox.sysconf ${DESTDIR}/etc/sysconf.d/busybox
    install ../busybox.initramfs ${DESTDIR}/usr/share/initramfs-tools/hooks/zz-busybox
    echo "BUSYBOXDIR=/bin" > ${DESTDIR}/usr/share/initramfs-tools/conf-hooks.d/busybox
    # install udhcpc script and service
    mkdir -p ${DESTDIR}/usr/share/udhcpc/ ${DESTDIR}/etc/init.d/
    install ../udhcpc.script ${DESTDIR}/usr/share/udhcpc/default.script
    install ../udhcpc.openrc ${DESTDIR}/etc/init.d/udhcpc
}

