Files
2026-03-16 15:30:35 +07:00

123 lines
3.5 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
. ./scripts/nginx.sh
. ./scripts/duf_bin.sh
. ./scripts/mtd-utils.sh
. ./scripts/iana-etc.sh
#----------- Building rootfs ----------------------
rootfs() {
print_info "** Building rootfs"
if [ ! -d $rootfspath ]; then
mkdir -pv $rootfspath
cd $rootfspath
mkdir -pv $(cat $rootfsfile)
ln -sv usr/lib lib
[ "$ARCH" = "arm" ] && ln -sv usr/lib lib32
[ "$ARCH" = "arm64" ] && ln -sv usr/lib lib64
ln -sv usr/bin bin
ln -sv usr/bin sbin
ln -sv var/run run
cd usr
ln -sv bin sbin
[ "$ARCH" = "arm" ] && ln -sv lib lib32
[ "$ARCH" = "arm64" ] && ln -sv lib lib64
ln -sv bin libexec
cd ..
ln -sv /proc/mounts etc/mtab
cat << EOF > $rootfspath/etc/os-release
NAME="$distro_name"
PRETTY_NAME="$distro_pretty_name"
ID="$distro_id"
BUILD_ID="$distro_build_id"
EOF
fi
iana-etc
busybox_rootfs
kernel_headers
uclibc
if [ "$FINIT_INIT_ENABLE" = "y" ]; then
finit_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
[ "$LIBSQLITE3_ENABLE" = "y"] && libsqlite3
[ "$LM_SENSORS_ENABLE" = "y" ] && lm_sensors
[ "$LRZSZ_ENABLE" = "y" ] && lrzsz-build
[ "$TCC_C_COMPILER_ENABLE" = "y" ] && tcc_build
[ "$NGINX_ENABLE" = "y" ] && nginx_build
[ "$DUF_BIN_ENABLE" = "y" ] && duf_bin
[ "$CONFIG_MTD_UTILS" = "y" ] && mtd-utils
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
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
[ "$KO8821AU_ENABLE" = "y" ] && ko8821au
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
#--------------------------------------------------