mirror of
https://codeberg.org/privacy1st/arch-installer
synced 2024-12-23 02:16:05 +01:00
feat: specify cfg location; create single executable file
This commit is contained in:
parent
2febea18d1
commit
9e474ffade
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
/.idea/
|
||||
/arch-installer/
|
||||
/de-p1st-installer-*-any.pkg.tar.zst
|
||||
/*-binary.sh
|
14
Makefile
14
Makefile
@ -3,3 +3,17 @@ all: test
|
||||
|
||||
test:
|
||||
shellcheck --check-sourced --external-sources de-p1st-installer.sh
|
||||
|
||||
SINGLE_FILE_CFG := example-vbox.cfg
|
||||
SINGLE_FILE_DST := example-vbox-binary.sh
|
||||
single-file: # Creates a single, executable .sh file a given configuration file.
|
||||
py-replace --text 'main "' --repl '# main "' --count 1 \
|
||||
< de-p1st-installer.sh \
|
||||
> single-file-temp.sh
|
||||
chmod +x single-file-temp.sh
|
||||
bash -v ./single-file-temp.sh example-vbox.cfg 2>&1 | \
|
||||
py-regex-replace --pattern '^\s*source\s+.+$$' --repl ': # sourced file included below:' --count '-1' | \
|
||||
py-replace --text '# main "' --repl 'main "' --count 1 \
|
||||
> ${SINGLE_FILE_DST}
|
||||
rm single-file-temp.sh
|
||||
chmod +x ${SINGLE_FILE_DST}
|
||||
|
@ -4,16 +4,18 @@ set -e
|
||||
# Exit on undefined variable reference.
|
||||
set -u
|
||||
|
||||
# Check if run from installation or locally (development setup).
|
||||
# -> Print commands before they get executed (set -v).
|
||||
# -> Determine library directory.
|
||||
script_dir="$(dirname "${BASH_SOURCE[0]}")" || exit 1
|
||||
if [ "${script_dir}" = '/usr/bin' ]; then
|
||||
# This script has been installed.
|
||||
script_dir="$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
function script_is_installed(){
|
||||
# Check if this script is run installed or locally (development setup).
|
||||
[ "${script_dir}" = '/usr/bin' ]
|
||||
}
|
||||
|
||||
if script_is_installed; then
|
||||
lib_dir='/usr/lib/de-p1st-installer'
|
||||
else
|
||||
# This script is run locally (development setup).
|
||||
lib_dir='./lib'
|
||||
# Print commands before they get executed.
|
||||
set -v
|
||||
fi
|
||||
|
||||
@ -25,9 +27,23 @@ source "${lib_dir}"/user-input.sh
|
||||
# shellcheck source=lib/block-device.sh
|
||||
source "${lib_dir}"/block-device.sh
|
||||
|
||||
# Get path of configuration file.
|
||||
if [ $# -eq 0 ]; then
|
||||
# No arguments given.
|
||||
if script_is_installed; then
|
||||
cfg_file=/etc/de-p1st-installer/installer.cfg
|
||||
else
|
||||
cfg_file="${script_dir}"/installer.cfg
|
||||
fi
|
||||
else
|
||||
# >= 1 arguments given.
|
||||
# First argument is the configuration file!
|
||||
cfg_file="${1}"
|
||||
fi
|
||||
|
||||
# Source the configuration file.
|
||||
# shellcheck source=installer.cfg
|
||||
source /etc/de-p1st-installer/installer.cfg
|
||||
source "${cfg_file}"
|
||||
|
||||
function main() {
|
||||
# @pre
|
||||
|
Loading…
Reference in New Issue
Block a user