Finished converting build.sh

This commit is contained in:
Storm Dragon 2019-12-12 10:18:42 -05:00
parent 059d94b125
commit 7e4f67ce47

View File

@ -86,7 +86,7 @@ eval set -- "$options"
# Declare the overrides that will replace configuration file variables with command line options # Declare the overrides that will replace configuration file variables with command line options
declare -A overrides=() declare -A overrides=()
while test $# -gt 0; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
-d|--work-directory) overrides[workdir]="$2"; shift 2 ;; -d|--work-directory) overrides[workdir]="$2"; shift 2 ;;
-H|--hostname) overrides[hostname]="$2"; shift 2 ;; -H|--hostname) overrides[hostname]="$2"; shift 2 ;;
@ -115,7 +115,7 @@ while test $# -gt 0; do
-w|--wifi-password) overrides[wifipass]="$2"; shift 2 ;; -w|--wifi-password) overrides[wifipass]="$2"; shift 2 ;;
(--) shift ;; (--) shift ;;
(*) (*)
if test -f "$1"; then if [[ -f "$1" ]]; then
source "$1" source "$1"
else else
echo "Invalid configuration file specified." | log echo "Invalid configuration file specified." | log
@ -127,15 +127,34 @@ while test $# -gt 0; do
done done
# Replace configuration variables using the overrides gathered from command line options # Replace configuration variables using the overrides gathered from command line options
test "${overrides[workdir]}" && workdir="${overrides[workdir]}" if [[ "${overrides[workdir]}" ]]; then
test "${overrides[hostname]}" && hostname="${overrides[hostname]}" workdir="${overrides[workdir]}"
test "${overrides[networkname]}" && networkname="${overrides[networkname]}" fi
test "${overrides[imagename]}" && imagename="${PWD}/${overrides[imagename]}" if [[ "${overrides[hostname]}" ]]; then
test "${overrides[userpass]}" && userpass="${overrides[userpass]}" hostname="${overrides[hostname]}"
test "${overrides[rootpass]}" && rootpass="${overrides[rootpass]}" fi
test "${overrides[imagesize]}" && imagesize="${overrides[imagesize]}" if [[ "${overrides[networkname]}" ]]; then
test "${overrides[username]}" && username="${overrides[username]}" networkname="${overrides[networkname]}"
test "${overrides[wifipass]}" && wifipass="${overrides[wifipass]}" fi
if [[ "${overrides[imagename]}" ]]; then
imagename="${PWD}/${overrides[imagename]}"
fi
if [[ "${overrides[userpass]}" ]]; then
userpass="${overrides[userpass]}"
fi
if [[ "${overrides[rootpass]}" ]]; then
rootpass="${overrides[rootpass]}"
fi
if [[ "${overrides[imagesize]}" ]]; then
imagesize="${overrides[imagesize]}"
fi
if [[ "${overrides[username]}" ]]; then
username="${overrides[username]}"
fi
if [[ "${overrides[wifipass]}" ]]; then
wifipass="${overrides[wifipass]}"
fi
# export workdir so it is available in subshells. # export workdir so it is available in subshells.
export workdir export workdir
@ -155,7 +174,7 @@ check_deps
if [ -d "$workdir" ]; then if [ -d "$workdir" ]; then
clean_up "$workdir" || true clean_up "$workdir" || true
# Don't remove an otherwise empty work directory if a pacman cache is present # Don't remove an otherwise empty work directory if a pacman cache is present
[ -d "${workdir}/pacman-cache" ] || rm -Rv "$workdir" |& log [[ -d "${workdir}/pacman-cache" ]] || rm -Rv "$workdir" |& log
fi fi
# Start by creating an empty image and mounting it. # Start by creating an empty image and mounting it.
@ -184,22 +203,17 @@ add_groups "${workdir}/root" |& log
add_user "${workdir}/root" "${username}" |& log add_user "${workdir}/root" "${username}" |& log
set_password "${workdir}/root" "${username}" "${userpass}" |& log set_password "${workdir}/root" "${username}" "${userpass}" |& log
# Install packages from the AUR
# This is optional, and will only run if an AUR package list is set in the config file passed to this script.
test $aurlist && ./aur-install -l "$aurlist" "${workdir}/root" |& log
# Copy any override files into the new system. This overrides any system and user configuration files or scripts installed with packages. # Copy any override files into the new system. This overrides any system and user configuration files or scripts installed with packages.
# Remove any stale temporary files related to the file and content repositories # Remove any stale temporary files related to the file and content repositories
rm -Rfv /tmp/files-F123Light /tmp/content-F123Light |& log rm -Rfv /tmp/stormux |& log
# Start by cloning the files-F123Light and content-F123Light repositories. # Start by cloning the stormux repository to /tmp
git clone -b $(git branch | grep \* | cut -f2 -d \ ) --recurse-submodules https://gitlab.com/F123/files-F123Light.git /tmp/files-F123Light |& log git clone -b $(git branch | grep \* | cut -f2 -d \ ) --recurse-submodules https://gitlab.com/stormux/stormux.git /tmp/stormux |& log
git clone https://gitlab.com/F123/content-F123Light.git /tmp/content-F123Light |& log
# Copy in the files. # Copy in the files.
cp -Rv /tmp/files-F123Light/files/* "${workdir}/root/" |& log cp -Rv /tmp/stormux/files/files/* "${workdir}/root/" |& log
# Generate translations: # Generate translations:
find /tmp/files-F123Light/locales -type f -iname '*.po' -exec bash -c ' find /tmp/stormux/locales -type f -iname '*.po' -exec bash -c '
for i ; do for i ; do
# i is in file, o is outfile. # i is in file, o is outfile.
language="$(grep "^\"Language: .*\\n" "${i}" | cut -d " " -f2 | cut -d "\\" -f1)" language="$(grep "^\"Language: .*\\n" "${i}" | cut -d " " -f2 | cut -d "\\" -f1)"
@ -212,13 +226,7 @@ find /tmp/files-F123Light/locales -type f -iname '*.po' -exec bash -c '
msgfmt "$i" -o "${workdir}/root/usr/share/locale/${language}/LC_MESSAGES/${o}" msgfmt "$i" -o "${workdir}/root/usr/share/locale/${language}/LC_MESSAGES/${o}"
done' _ {} + done' _ {} +
mkdir -p "${workdir}/root/usr/share/doc/stormux" |& log mkdir -p "${workdir}/root/usr/share/doc/stormux" |& log
cp -Rv /tmp/content-F123Light/F123/* "${workdir}/root/usr/share/doc/F123/" |& log cp -Rv /tmp/stormux/content/stormux/* "${workdir}/root/usr/share/doc/stormux/" |& log
# remove the temporary files again.
rm -Rv /tmp/files-F123Light /tmp/content-F123Light |& log
# Now copy any override files from this repository.
cp -Rv ../files/* "${workdir}/root/" || true |& log
# Set the system locale and generate all other locales specified in the configuration file. # Set the system locale and generate all other locales specified in the configuration file.
# The default system locale must be set before we can copy user files to $HOME. # The default system locale must be set before we can copy user files to $HOME.
@ -242,12 +250,10 @@ systemd-nspawn -a -q -D $workdir/root\
download_package_databases $workdir/root |& log download_package_databases $workdir/root |& log
set_fake_hwclock $workdir/root |& log set_fake_hwclock $workdir/root |& log
# Set gsettings keys to enable Orca
# This is optional, and cannot run on a text only system.
[ $gsettings ] && ./gsettings "${workdir}/root" |& log
# Configure wifi if network information is present in the configuration file. # Configure wifi if network information is present in the configuration file.
test $networkname && setup_wifi $workdir/root wlan0 $networkname $wifipass |& log if [[ -n "$networkname" ]]; then
setup_wifi $workdir/root wlan0 $networkname $wifipass |& log
fi
# Touch the firstboot file. It will be deleted by the firstboot script that looks for it. # Touch the firstboot file. It will be deleted by the firstboot script that looks for it.
systemd-nspawn -a -q -D $workdir/root\ systemd-nspawn -a -q -D $workdir/root\
@ -256,12 +262,14 @@ systemd-nspawn -a -q -D $workdir/root\
# Write a system timestamp. # Write a system timestamp.
# This timestamp will determine which incremental updates apply to this image # This timestamp will determine which incremental updates apply to this image
echo "$(date +%y%m%d%H%M)" > $workdir/root/etc/timestamp-f123light echo "$(date +%y%m%d%H%M)" > $workdir/root/etc/timestamp-stormux
# Unmount the image file # Unmount the image file
clean_up "$workdir" |& log clean_up "$workdir" |& log
# Keep the work directory if a pacman cache exists, otherwise remove it # Keep the work directory if a pacman cache exists, otherwise remove it
[ -d "${workdir}/pacman-cache" ] || rm -Rv "$workdir" |& log if [[ ! -d "${workdir}/pacman-cache" ]]; then
rm -Rv "$workdir" |& log
fi
# Once all scripts have completed, come back to the directory from which this script was launched. # Once all scripts have completed, come back to the directory from which this script was launched.
cd $current && echo "cd $current" |& log cd $current && echo "cd $current" |& log