summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2022-08-16 07:15:33 -0400
committerbill-auger <mr.j.spam.me@gmail.com>2022-08-17 06:37:01 -0400
commita491beb48ba15ea85a2b38fc8ecc31cb2e8fbc91 (patch)
tree0be11f938fc4b2cdd898823ed02e333430e15ade
parent3741a9c3b9a50c1b7e88cf4b6b78595bf9b8aece (diff)
extract constants into separate file
-rw-r--r--.gitignore1
-rw-r--r--chroot-login.sh1
-rw-r--r--constants.sh.inc94
-rwxr-xr-xinstall.sh15
-rw-r--r--session-common.sh.inc50
5 files changed, 96 insertions, 65 deletions
diff --git a/.gitignore b/.gitignore
index 45402a3..b13f1fa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
!chroot-environment.sh
!chroot-login.sh
!chroot-services.sh
+!constants.sh.inc
!install.sh
!KEYMAPS_VT
!KEYMAPS_X
diff --git a/chroot-login.sh b/chroot-login.sh
index 62fb06d..775fa08 100644
--- a/chroot-login.sh
+++ b/chroot-login.sh
@@ -33,7 +33,6 @@
source /root/session-common.sh.inc
-readonly WHEEL_SUDOERS_SED_CMD='s|[#] [%]wheel ALL=[(]ALL[)] ALL|%wheel ALL=(ALL) ALL|'
readonly USER_LOGIN=$(GetStateVar 'USER_LOGIN')
readonly USER_PASS=$( GetStateVar 'USER_PASS' )
readonly KEYMAP=$( GetStateVar 'XKBMAP' )
diff --git a/constants.sh.inc b/constants.sh.inc
new file mode 100644
index 0000000..7d114f5
--- /dev/null
+++ b/constants.sh.inc
@@ -0,0 +1,94 @@
+# Parabola Install Wizard - common constants
+#
+# Copyright (C) 2020,2022 bill-auger <bill-auger@programmer.net>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of Parabola Install Wizard.
+#
+# Parabola Install Wizard is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Parabola Install Wizard is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Parabola Install Wizard. If not, see <http://www.gnu.org/licenses/>.
+
+
+# environment
+readonly THIS_DIR="$(cd $(dirname ${BASH_SOURCE[0]}) ; pwd)"
+
+# config
+readonly SWAP_MB=1000
+
+# defaults
+readonly DEF_KEYMAP='us'
+readonly DEF_LANG='en_US.UTF-8'
+readonly DEF_TRKEY='en'
+readonly DEF_INSTALL='offline'
+readonly DEF_PKG_SET='standard'
+readonly DEF_INIT='systemd'
+readonly DEF_WMDE='lxde'
+readonly DEF_HOSTNAME='parabola'
+readonly DEF_TIMEZONE='UTC'
+
+# per-stage state vars
+readonly STATEVARS_LOGINS=( 'ROOT_PASS' 'USER_LOGIN' 'USER_PASS' )
+readonly STATEVARS_BASE=( 'INSTALL' 'BASE' 'INIT' )
+readonly STATEVARS_BOOT=( 'BOOT' )
+readonly STATEVARS_DEFAUILTS=( 'INSTALL' 'BASE' 'INIT' \
+ 'WMDE' \
+ 'LANG' 'HOSTNAME' 'TIMEZONE' 'KEYMAP' 'LOCALES' \
+ 'XKBMAP' 'LANG' )
+readonly STATEVARS_WMDE=( 'WMDE' )
+readonly STATEVARS_ENV=( 'LANG' 'HOSTNAME' 'TIMEZONE' 'KEYMAP' 'LOCALES' )
+readonly STATEVARS_PARTITION=( 'DEVICE_N' 'DEVICE' 'PART_METHOD' )
+readonly STATEVARS_READY=( 'ROOT_PART' 'BOOT_PART' 'HOME_PART' )
+readonly STATEVARS_CHROOTENV=( 'LANG' 'HOSTNAME' 'TIMEZONE' 'KEYMAP' 'LOCALES' \
+ 'BOOT' 'WMDE' 'DEVICE' )
+readonly STATEVARS_CHROOTLOGIN=( 'ROOT_PASS' 'USER_LOGIN' 'USER_PASS' 'XKBMAP' 'WMDE' )
+readonly STATEVARS_CHROOTSERVICES=( 'INIT' 'WMDE' )
+STATEVARS_PRESET=( ${STATEVARS_LOGINS[*]} \
+ ${STATEVARS_BASE[*]} \
+ ${STATEVARS_BOOT[*]} \
+ ${STATEVARS_WMDE[*]} \
+ ${STATEVARS_ENV[*]} \
+ ${STATEVARS_PARTITION[*]} \
+ ${STATEVARS_READY[*]} \
+ ${STATEVARS_CHROOTENV[*]} \
+ ${STATEVARS_CHROOTLOGIN[*]} \
+ ${STATEVARS_CHROOTSERVICES[*]} )
+readarray -td '' STATEVARS_PRESET < <( sort -zu < <(printf "%s\0" "${STATEVARS_PRESET[@]}") )
+readonly STATEVARS_PRESET
+
+# sanity checks
+readonly IN_CHROOT=$( main_script="${BASH_SOURCE[$(( ${#BASH_SOURCE[@]} - 1 ))]}" \
+ [[ "${main_script}" =~ ^/root/chroot-.*\.sh$ ]] ; echo $((!$?)) )
+readonly DIALOG_ERR_MSG="ERROR: can not find the \`dialog\` program"
+readonly PRIVILEGE_ERR_MSG="ERROR: this program requires superuser privilege"
+readonly STATEFILE_ERR_MSG="ERROR: can not write to state file"
+
+# install.sh
+declare -r -A KEYRINGS=( [armv7l]='archlinux-keyring parabola-keyring archlinuxarm-keyring' \
+ [i686]=' archlinux-keyring parabola-keyring archlinux32-keyring' \
+ [x86_64]='archlinux-keyring parabola-keyring' )
+declare -r -A BASE_PACKAGES=( [core]='base' \
+ [standard]='base parabola-base' )
+declare -r -A BOOT_PACKAGES=( [grub]='grub grub2-theme-gnuaxiom' )
+declare -r -A GUI_PACKAGES=( [lxde]='parabola-desktop-lxde' \
+ [mate]='parabola-desktop-mate' ) # TODO: parabola-desktop NYI
+readonly PACCONF_NONSYSTEMD_REGEX='s|^_NONSYSTEMD_$|[nonsystemd]\nInclude = /etc/pacman.d/mirrorlist\n|'
+readonly PACCONF_SYSTEMD_REGEX='s|^_NONSYSTEMD_$|#[nonsystemd]\n#Include = /etc/pacman.d/mirrorlist\n|'
+readonly ONLINE_CHECK_URL=https://repo.parabola.nu/check_network_status.txt
+readonly CURL_CMD=(curl --silent --write-out '%{http_code}' ${ONLINE_CHECK_URL} -o /dev/null)
+
+# chroot-env.sh
+readonly GRUB_THEME_SED_RX="s|^#GRUB_THEME=.*|GRUB_THEME=/boot/grub/themes/_THEME_DIR_/theme.txt|"
+
+# chroot-login.sh
+readonly WHEEL_SUDOERS_SED_RX='s|[#] [%]wheel ALL=[(]ALL[)] ALL|%wheel ALL=(ALL) ALL|'
diff --git a/install.sh b/install.sh
index 1b11449..fc34944 100755
--- a/install.sh
+++ b/install.sh
@@ -39,21 +39,6 @@
source $(cd $(dirname ${BASH_SOURCE[0]}) ; pwd)/session-common.sh.inc # sets: $Lang
-declare -r -A KEYRINGS=( [armv7l]='archlinux-keyring parabola-keyring archlinuxarm-keyring' \
- [i686]=' archlinux-keyring parabola-keyring archlinux32-keyring' \
- [x86_64]='archlinux-keyring parabola-keyring' )
-declare -r -A BASE_PACKAGES=( [core]='base' \
- [standard]='base parabola-base' )
-declare -r -A BOOT_PACKAGES=( [grub]='grub grub2-theme-gnuaxiom' )
-declare -r -A GUI_PACKAGES=( [lxde]='parabola-desktop-lxde' \
- [mate]='parabola-desktop-mate' ) # TODO: parabola-desktop NYI
-readonly PACCONF_NONSYSTEMD_REGEX='s|^_NONSYSTEMD_$|[nonsystemd]\nInclude = /etc/pacman.d/mirrorlist\n|'
-readonly PACCONF_SYSTEMD_REGEX='s|^_NONSYSTEMD_$|#[nonsystemd]\n#Include = /etc/pacman.d/mirrorlist\n|'
-readonly ONLINE_CHECK_URL=https://repo.parabola.nu/check_network_status.txt
-readonly CURL_CMD=(curl --silent --write-out '%{http_code}' ${ONLINE_CHECK_URL} -o /dev/null)
-readonly GRUB_THEME_SED_CMD='s|^#GRUB_THEME=.*|GRUB_THEME=/boot/grub/themes/parabola-laf/theme.txt|'
-
-
NoticeIntro()
{
# checks to skip this notice per preset config
diff --git a/session-common.sh.inc b/session-common.sh.inc
index 4a732a7..a67e3bc 100644
--- a/session-common.sh.inc
+++ b/session-common.sh.inc
@@ -20,59 +20,11 @@
# along with Parabola Install Wizard. If not, see <http://www.gnu.org/licenses/>.
-readonly THIS_DIR="$(cd $(dirname ${BASH_SOURCE[0]}) ; pwd)"
-
-# config
-readonly SWAP_MB=1000
-
-# defaults
-readonly DEF_KEYMAP='us'
-readonly DEF_LANG='en_US.UTF-8'
-readonly DEF_TRKEY='en'
-readonly DEF_INSTALL='offline'
-readonly DEF_PKG_SET='standard'
-readonly DEF_INIT='systemd'
-readonly DEF_WMDE='cli'
-readonly DEF_HOSTNAME='parabola'
-readonly DEF_TIMEZONE='UTC'
-
-# per-stage state vars
-readonly STATEVARS_LOGINS=( 'ROOT_PASS' 'USER_LOGIN' 'USER_PASS' )
-readonly STATEVARS_BASE=( 'INSTALL' 'BASE' 'INIT' )
-readonly STATEVARS_BOOT=( 'BOOT' )
-readonly STATEVARS_DEFAUILTS=( 'INSTALL' 'BASE' 'INIT' \
- 'WMDE' \
- 'LANG' 'HOSTNAME' 'TIMEZONE' 'KEYMAP' 'LOCALES' \
- 'XKBMAP' 'LANG' )
-readonly STATEVARS_WMDE=( 'WMDE' )
-readonly STATEVARS_ENV=( 'LANG' 'HOSTNAME' 'TIMEZONE' 'KEYMAP' 'LOCALES' )
-readonly STATEVARS_PARTITION=( 'DEVICE_N' 'DEVICE' 'PART_METHOD' )
-readonly STATEVARS_READY=( 'ROOT_PART' 'BOOT_PART' 'HOME_PART' )
-readonly STATEVARS_CHROOTENV=( 'HOSTNAME' 'TIMEZONE' 'KEYMAP' 'LOCALES' \
- 'LANG' 'BOOT' 'DEVICE' )
-readonly STATEVARS_CHROOTLOGIN=( 'ROOT_PASS' 'USER_LOGIN' 'USER_PASS' 'XKBMAP' 'WMDE' )
-readonly STATEVARS_CHROOTSERVICES=( 'INIT' 'WMDE' )
-STATEVARS_PRESET=( ${STATEVARS_LOGINS[*]} \
- ${STATEVARS_BASE[*]} \
- ${STATEVARS_BOOT[*]} \
- ${STATEVARS_WMDE[*]} \
- ${STATEVARS_ENV[*]} \
- ${STATEVARS_PARTITION[*]} \
- ${STATEVARS_READY[*]} \
- ${STATEVARS_CHROOTENV[*]} \
- ${STATEVARS_CHROOTLOGIN[*]} \
- ${STATEVARS_CHROOTSERVICES[*]} )
-readarray -td '' STATEVARS_PRESET < <( sort -zu < <(printf "%s\0" "${STATEVARS_PRESET[@]}") )
-readonly STATEVARS_PRESET
+source $(cd $(dirname ${BASH_SOURCE[0]}) ; pwd)/constants.sh.inc
## sanity checks ##
-readonly DIALOG_ERR_MSG="ERROR: can not find the \`dialog\` program"
-readonly PRIVILEGE_ERR_MSG="ERROR: this program requires superuser privilege"
-readonly STATEFILE_ERR_MSG="ERROR: can not write to state file"
-readonly IN_CHROOT=$( main_script="${BASH_SOURCE[$(( ${#BASH_SOURCE[@]} - 1 ))]}" \
- [[ "${main_script}" =~ ^/root/chroot-.*\.sh$ ]] ; echo $((!$?)) )
if (( ! IN_CHROOT ))
then which dialog &> /dev/null || ! echo "${DIALOG_ERR_MSG}" || exit
(( ! $EUID )) || ! echo "${PRIVILEGE_ERR_MSG}" || exit