Skip to content

Commit

Permalink
OPENDINGUX: Lighten build process by not building useless packages
Browse files Browse the repository at this point in the history
  • Loading branch information
lephilousophe committed Jan 30, 2022
1 parent d30904e commit f0dd658
Showing 1 changed file with 81 additions and 4 deletions.
85 changes: 81 additions & 4 deletions toolchains/opendingux-beta/packages/toolchain/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,91 @@ num_cpus=$(nproc || grep -c ^processor /proc/cpuinfo || echo 1)
MAKEOPTS="-j${num_cpus}"
NICEOPTS="-n0"

# We will cleanup defconfig to have a small build just enough for us
WHITELIST=$(cat <<-"EOF"
BUSYBOX.*
FLAC
FLUIDSYNTH
MESA3D.*
SDL
SDL_KMSDRM
SDL_NET
SDL2
SDL2_KMSDRM
SDL2_OPENGLES
SDL2_NET
ALSA_LIB.*
LIBMAD
LIBVORBIS
TREMOR
FREETYPE
JPEG
LIBDRM
LIBPNG
TSLIB
LIBTHEORA
NCURSES.*
READLINE
UTIL_LINUX_LIBMOUNT
LIBJPEG8
EOF
)

lighten() {
local full orig target dest

target=$1

full=$(mktemp -d)
orig=$(mktemp)
dest="configs/od_${target}_defconfig"

# Create the standard config to know which libraries are really present in the full toolchain
make "od_${target}_defconfig" BR2_EXTERNAL=board/opendingux O="$full"

cp "$dest" "$orig"

# Remove all packages
grep -v '^BR2_PACKAGE' "$orig" > "$dest"
# Remove some other settings
sed -i '/^BR2_TARGET_ROOTFS_SQUASHFS=y/d' "$dest"

# Add whitelisted packages which are already enabled
echo "$WHITELIST" | while read pkg; do
grep "^BR2_PACKAGE_$pkg=" "$full/.config" >> "$dest" || true
done

# Disable now useless scripts
sed -i '/^BR2_ROOTFS_POST_BUILD_SCRIPT=/s|board/opendingux/[^/]\+/cleanup-rootfs.sh||' "$dest"
sed -i '/^BR2_ROOTFS_POST_BUILD_SCRIPT=/s|board/opendingux/create-modules-fs.sh||' "$dest"
# Remove all blanks
sed -i '/^BR2_ROOTFS_POST_BUILD_SCRIPT=/s| \+| |g' "$dest"
sed -i '/^BR2_ROOTFS_POST_BUILD_SCRIPT=/s|=" *|="|' "$dest"
sed -i '/^BR2_ROOTFS_POST_BUILD_SCRIPT=/s| *"$|"|' "$dest"

# Don't build a kernel, only headers
sed -i 's/^BR2_LINUX_KERNEL=y$/# BR2_LINUX_KERNEL is not set/' "$dest"
echo "BR2_PACKAGE_LINUX_HEADERS=y" >> "$dest"
# Move kernel configuration to headers (not perfect but good enough)
sed -i 's/^BR2_LINUX_KERNEL_/BR2_KERNEL_HEADERS_/' "$dest"

# Disable buildroot default settings
echo '# BR2_PACKAGE_EUDEV_ENABLE_HWDB is not set' >> "$dest"
echo '# BR2_PACKAGE_URANDOM_SCRIPTS is not set' >> "$dest"

# Enable ccache (this will help a little between targets)
echo 'BR2_CCACHE=y' >> "$dest"
echo 'BR2_CCACHE_DIR="$(TOPDIR)/ccache"' >> "$dest"

rm "$orig"
rm -rf "$full"
}

mkdir -p "${OPENDINGUX_ROOT}/"
for target in $TARGETS; do

# Lighten build process by removing useless packages for us
for conf in BR2_PACKAGE_HOST_GDB BR2_PACKAGE_VALGRIND BR2_PACKAGE_GDB BR2_PACKAGE_GDB_SERVER BR2_PACKAGE_GDB_DEBUGGER \
BR2_PACKAGE_STRACE BR2_PACKAGE_STRESS BR2_PACKAGE_APITRACE; do
sed -i -e "s/^${conf}=.*$/# ${conf} is not set/" configs/od_${target}_defconfig
done
lighten "$target"

CONFIG=$target ./rebuild.sh
tar -C "${OPENDINGUX_ROOT}/" -xJf output/$target/images/opendingux-$target-toolchain.*.tar.xz
Expand Down

0 comments on commit f0dd658

Please sign in to comment.