127 lines
3.9 KiB
Bash
Executable File
127 lines
3.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
. ./scripts/colors.sh
|
|
. ./scripts/funcs.sh
|
|
. ./scripts/config.sh
|
|
. ./scripts/busybox.sh
|
|
. ./scripts/uclibc.sh
|
|
. ./scripts/kernel.sh
|
|
. ./scripts/zlib.sh
|
|
. ./scripts/dropbear.sh
|
|
. ./scripts/sftp_server.sh
|
|
. ./scripts/curl.sh
|
|
. ./scripts/bash.sh
|
|
. ./scripts/git.sh
|
|
. ./scripts/gitea.sh
|
|
. ./scripts/libnl.sh
|
|
. ./scripts/iw.sh
|
|
. ./scripts/openssl.sh
|
|
. ./scripts/hostapd.sh
|
|
. ./scripts/dnsmasq.sh
|
|
. ./scripts/iptables.sh
|
|
. ./scripts/8821au_ko.sh
|
|
. ./scripts/finit_init.sh
|
|
. ./scripts/libsqlite3.sh
|
|
. ./scripts/lm_sensors.sh
|
|
. ./scripts/wpa_supplicant.sh
|
|
. ./scripts/lrzsz.sh
|
|
. ./scripts/tcc.sh
|
|
. ./scripts/cleanup_rootfs.sh
|
|
|
|
#----------- Building rootfs ----------------------
|
|
rootfs() {
|
|
printf "$UGREEN** Building rootfs\n$RESET"
|
|
# rm -rv $rootfspath # &>> $fulllogfile
|
|
mkdir -pv $rootfspath # &>> $fulllogfile
|
|
cd $rootfspath
|
|
mkdir -pv $(cat $rootfsfile) # &>> $fulllogfile
|
|
ln -sv usr/lib lib # &>> $fulllogfile
|
|
[ "$ARCH" = "arm" ] && ln -sv usr/lib lib32 # &>> $fulllogfile
|
|
[ "$ARCH" = "arm64" ] && ln -sv usr/lib lib64
|
|
ln -sv usr/bin bin # &>> $fulllogfile
|
|
ln -sv usr/bin sbin # &>> $fulllogfile
|
|
ln -sv var/run run
|
|
cd usr
|
|
ln -sv bin sbin # &>> $fulllogfile
|
|
[ "$ARCH" = "arm" ] && ln -sv lib lib32 # &>> $fulllogfile
|
|
[ "$ARCH" = "arm64" ] && ln -sv lib lib64
|
|
ln -sv bin libexec
|
|
cd ..
|
|
# tar -xvf $root/downloads/20250110-1.tar.gz
|
|
# cp -rv initscripts/* .
|
|
# rm -rv initscripts
|
|
ln -sv /proc/mounts etc/mtab # &>> $fulllogfile
|
|
|
|
cat <<EOF > $rootfspath/etc/os-release
|
|
NAME="$distro_name"
|
|
PRETTY_NAME="$distro_pretty_name"
|
|
ID="$distro_id"
|
|
BUILD_ID="$distro_build_id"
|
|
EOF
|
|
|
|
busybox_rootfs
|
|
# cp -v $build/busybox/busybox-${BUSYBOX_VERSION}/busybox $rootfspath/usr/bin # &>> $fulllogfile
|
|
# cd $rootfspath/usr/bin
|
|
# for i in $(cat $BUSYBOX_LIST_FILE); do ln -sv busybox $i; done
|
|
# cp -v $root/rootfs/init.in $rootfspath/init
|
|
kernel_headers
|
|
uclibc
|
|
# kernel
|
|
# kernel_modules
|
|
if [ "$FINIT_INIT_ENABLE" = "y" ]; then
|
|
finit_init
|
|
# cp -rv $root/rootfs/overlay/* $rootfspath
|
|
# rm $rootfspath/init
|
|
ln -sv usr/bin/finit $rootfspath/init
|
|
fi
|
|
[ "$ZLIB_ENABLE" = "y" ] && zlib
|
|
[ "$OPENSSL_ENABLE" = "y" ] && openssl
|
|
[ "$DNSMASQ_ENABLE" = "y" ] && dnsmasq
|
|
[ "$DROPBEAR_ENABLE" = "y" ] && dropbear
|
|
[ "$SFTP_SERVER_ENABLE" = "y" ] && sftp_server
|
|
[ "$CURL_ENABLE" = "y" ] && curl
|
|
[ "$BASH_ENABLE" = "y" ] && bash
|
|
[ "$GIT_ENABLE" = "y" ] && git_build
|
|
[ "$GITEA_ENABLE" = "y" ] && gitea
|
|
[ "$LIBNL_ENABLE" = "y" ] && libnl
|
|
[ "$IW_ENABLE" = "y" ] && iw
|
|
[ "$WPA_SUPPLICANT_ENABLE" = "y" ] && build_wpa_supplicant
|
|
[ "$HOSTAPD_ENABLE" = "y" ] && hostapd
|
|
[ "$IPTABLES_ENABLE" = "y" ] && iptables
|
|
[ "$KO8821AU_ENABLE" = "y" ] && ko8821au
|
|
[ "$LIBSQLITE3_ENABLE" = "y"] && libsqlite3
|
|
[ "$LM_SENSORS_ENABLE" = "y" ] && lm_sensors
|
|
[ "$LRZSZ_ENABLE" = "y" ] && lrzsz-build
|
|
[ "$TCC_C_COMPILER_ENABLE" = "y" ] && tcc_build
|
|
|
|
if [ ! -z "$DEFAULT_HOSTNAME" ]; then
|
|
echo "$DEFAULT_HOSTNAME" > $rootfspath/etc/hostname
|
|
cat << EOF > $rootfspath/etc/hosts
|
|
127.0.0.1 localhost
|
|
::1 localhost
|
|
127.0.1.1 $DEFAULT_HOSTNAME.localdomain $DEFAULT_HOSTNAME
|
|
EOF
|
|
cat << EOF > $rootfspath/etc/issue
|
|
$DEFAULT_HOSTNAME $KERNEL_VERSION (\l)
|
|
EOF
|
|
fi
|
|
|
|
[ ! -z "$ROOTFS_OVERLAY" ] && cp -rv $ROOTFS_OVERLAY/* $rootfspath
|
|
|
|
chmod 640 $rootfspath/etc/shadow #$rootfspath/etc/inittab
|
|
chmod 755 $rootfspath/usr/share/udhcpc/default.script
|
|
chmod 644 $rootfspath/etc/{passwd,group,hostname,hosts,fstab,shells,issue} $rootfspath/etc/network/interfaces
|
|
|
|
check $? "Build rootfs"
|
|
cleanup_rootfs
|
|
kernel
|
|
kernel_modules
|
|
if [ "${board}" = "orangepi_pc" ] && [ "${TCC_C_COMPILER_ENABLE}" = "y" ]
|
|
then
|
|
cd $rootfspath
|
|
patch -p1 < $root/board/board/uclibc-1.0.56-byteswap-common.h.patch
|
|
cd -
|
|
fi
|
|
} # rootfs
|
|
#--------------------------------------------------
|