diff options
| author | Mhd Sulhan <ms@kilabit.info> | 2015-11-20 01:20:08 +0700 |
|---|---|---|
| committer | Mhd Sulhan <ms@kilabit.info> | 2015-11-20 01:20:08 +0700 |
| commit | fa259627bf7c99a79cb48f27d57203fdc9e3df11 (patch) | |
| tree | 6e89b60e750ca61b42bebbef65ae8c2cc7bbfb9c /scripts/bootstrap.sh | |
| parent | bba5a1c7f072f24c9e3a1c4e8db885ae0fdf065c (diff) | |
| download | arch-docker-fa259627bf7c99a79cb48f27d57203fdc9e3df11.tar.xz | |
Modularize build script.
All process to create rootfs and bootstrap are grouped into several
functions.
* scripts/rootfs.sh is for creating rootfs and installing packages.
* scripts/bootstrap.sh is for bootstraping rootfs and cleaning.
Diffstat (limited to 'scripts/bootstrap.sh')
| -rwxr-xr-x | scripts/bootstrap.sh | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh new file mode 100755 index 0000000..ceb68f5 --- /dev/null +++ b/scripts/bootstrap.sh @@ -0,0 +1,91 @@ +#!/bin/bash + +export LANG=C.UTF-8 +export HOSTNAME="arch-base" +export BOOT_LANG=en_GB.UTF-8 +export PKG_REMOVED=() + +strip_bin() { + find /usr/bin -type f \( -perm -0100 \) -print | + xargs file | + sed -n '/executable .*not stripped/s/: TAB .*//p' | + xargs -rt strip --strip-unneeded +} + +strip_lib() { + find /usr/lib -type f \( -perm -0100 \) -print | + xargs file | + sed -n '/executable .*not stripped/s/: TAB .*//p' | + xargs -rt strip --strip-unneeded +} + +bootstrap_clean_common() { + echo "==> cleaning ..." + strip_bin + strip_lib + rm -rf /usr/share/doc/* + rm -rf /usr/share/licenses/* + rm -rf /usr/share/locale/* + rm -rf /usr/share/man/* + rm -rf /usr/share/info/* + rm -rf /var/cache/pacman/pkg/* + rm -rf /var/log/* + rm -f /bootstrap.sh + rm -f /run_bootstrap.sh +} + +bootstrap_hostname() { + echo "==> set hostname ..." + echo ${HOSTNAME} > /etc/hostname +} + +bootstrap_timezone() { + echo "==> set timezone to UTC ..." + cp /usr/share/zoneinfo/UTC /etc/localtime +} + +bootstrap_locales() { + echo "==> set locales ..." + echo "en_GB.UTF-8 UTF-8" > /etc/locale.gen + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen + + echo "==> generate locale ..." + /usr/bin/locale-gen + + echo "==> set locale preferences ..." + echo "LANG=${BOOT_LANG}" > "$rootfs"/etc/locale.conf + echo "LC_MESSAGES=C" >> "$rootfs"/etc/locale.conf +} + +bootstrap_remove_packages() { + echo "==> remove unneeded packages ..." + for pkg in ${PKGS_REMOVED[@]}; do + echo " removing $pkg" + pacman -Rdd --noconfirm $pkg + done +} + +bootstrap_clean_base() { + echo "==> cleaning base ..." + ## Remove all charmaps except UTF-8. + find /usr/share/i18n/charmaps/ \! -name "UTF-8.gz" -delete + ## Remove all locales except en_GB and en_US. + find /usr/share/i18n/locales/ \! -name "en_GB" \! -name "en_US" -delete + ## Remove all terminfo excetp ansi,cygwin,linux,screen-256color,vt100,vt220, + ## and xterm. + find /usr/share/terminfo/ \ + \! -name ansi \ + \! -name cygwin \ + \! -name linux \ + \! -name screen-256color \ + \! -name vt100 \ + \! -name vt220 \ + \! -name xterm \ + -delete + ## Remove all unneeded doc. + rm -rf /usr/share/texinfo/* + rm -rf /usr/share/zoneinfo/* + rm -rf /usr/share/iana-etc/* + rm -rf /usr/share/gtk-doc/* + rm -rf /usr/share/readline/* +} |
