Configure doesn't depend on cwd now and behaves as expected relative to cwd.
This commit is contained in:
parent
3420fe4a69
commit
bc10d3293b
|
@ -18,8 +18,28 @@ function get_source_dir() {
|
||||||
echo -n "$(realpath "$(dirname "${source}")")"
|
echo -n "$(realpath "$(dirname "${source}")")"
|
||||||
}
|
}
|
||||||
|
|
||||||
GENTOO_INSTALL_REPO_DIR="$(get_source_dir)"
|
export GENTOO_INSTALL_REPO_DIR="$(get_source_dir)"
|
||||||
cd "$GENTOO_INSTALL_REPO_DIR" || { echo "Could not change into directory '$GENTOO_INSTALL_REPO_DIR'"; exit 1; }
|
export GENTOO_INSTALL_REPO_SCRIPT_ACTIVE=true
|
||||||
|
|
||||||
|
source "$GENTOO_INSTALL_REPO_DIR/scripts/utils.sh"
|
||||||
|
|
||||||
|
# Remember actual config file path
|
||||||
|
CONFIG_FILE="$(realpath "${1-"gentoo.conf"}" 2>/dev/null)"
|
||||||
|
RELA_CONFIG_FILE="$(realpath --relative-to="$(pwd)" "$CONFIG_FILE" 2>/dev/null)"
|
||||||
|
|
||||||
|
# Check if help is requested
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
""|"help"|"--help"|"-help"|"-h")
|
||||||
|
echo "Usage: $0 [config]"
|
||||||
|
echo "Starts the gentoo configurator. If no file is given, it defaults to 'gentoo.conf'."
|
||||||
|
echo "If the file doesn't exist, the configurator loads default values, otherwise, the"
|
||||||
|
echo "the configuration is loaded into the configurator."
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
# TODO check install dialog
|
# TODO check install dialog
|
||||||
echo "Please install dialog on your system to use the configurator"
|
echo "Please install dialog on your system to use the configurator"
|
||||||
|
@ -28,11 +48,11 @@ echo "Please install dialog on your system to use the configurator"
|
||||||
################################################
|
################################################
|
||||||
# Configuration storage
|
# Configuration storage
|
||||||
|
|
||||||
SAVE_AS_FILENAME="${1-"gentoo.conf"}"
|
SAVE_AS_FILENAME="$RELA_CONFIG_FILE"
|
||||||
if [[ -e "$SAVE_AS_FILENAME" ]]; then
|
if [[ -e "$CONFIG_FILE" ]]; then
|
||||||
# Load settings
|
# Load settings
|
||||||
UNSAVED_CHANGES=false
|
UNSAVED_CHANGES=false
|
||||||
source "$SAVE_AS_FILENAME"
|
source "$CONFIG_FILE" || die "Could not load given configuration."
|
||||||
else
|
else
|
||||||
# Default settings
|
# Default settings
|
||||||
UNSAVED_CHANGES=true
|
UNSAVED_CHANGES=true
|
||||||
|
@ -224,7 +244,7 @@ function menu_exit() {
|
||||||
local diag_exit="$?"
|
local diag_exit="$?"
|
||||||
if [[ $diag_exit == 0 ]]; then
|
if [[ $diag_exit == 0 ]]; then
|
||||||
# <Save>
|
# <Save>
|
||||||
save "gentoo.conf"
|
save "$CONFIG_FILE"
|
||||||
exit 0
|
exit 0
|
||||||
elif [[ $diag_exit == 1 ]]; then
|
elif [[ $diag_exit == 1 ]]; then
|
||||||
# <Discard>
|
# <Discard>
|
||||||
|
@ -273,7 +293,7 @@ function menu() {
|
||||||
|
|
||||||
local sel
|
local sel
|
||||||
sel="$(dialog --clear \
|
sel="$(dialog --clear \
|
||||||
--title "Gentoo configuration" \
|
--title "Gentoo configuration ($RELA_CONFIG_FILE)" \
|
||||||
--extra-button --extra-label "Exit" \
|
--extra-button --extra-label "Exit" \
|
||||||
--help-button \
|
--help-button \
|
||||||
--ok-label "Select" --cancel-label "Save" \
|
--ok-label "Select" --cancel-label "Save" \
|
||||||
|
|
3
install
3
install
|
@ -18,6 +18,7 @@ function get_source_dir() {
|
||||||
echo -n "$(realpath "$(dirname "${source}")")"
|
echo -n "$(realpath "$(dirname "${source}")")"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export ACTUAL_WORKING_DIRECTORY="$(realpath "$(pwd)")"
|
||||||
export GENTOO_INSTALL_REPO_DIR_ORIGINAL="$(get_source_dir)"
|
export GENTOO_INSTALL_REPO_DIR_ORIGINAL="$(get_source_dir)"
|
||||||
export GENTOO_INSTALL_REPO_DIR="$GENTOO_INSTALL_REPO_DIR_ORIGINAL"
|
export GENTOO_INSTALL_REPO_DIR="$GENTOO_INSTALL_REPO_DIR_ORIGINAL"
|
||||||
export GENTOO_INSTALL_REPO_SCRIPT_ACTIVE=true
|
export GENTOO_INSTALL_REPO_SCRIPT_ACTIVE=true
|
||||||
|
@ -66,7 +67,7 @@ while [[ $# -gt 0 ]]; do
|
||||||
"-c"|"--config")
|
"-c"|"--config")
|
||||||
[[ -f "$2" ]] \
|
[[ -f "$2" ]] \
|
||||||
|| die "Config file not found: '$2'"
|
|| die "Config file not found: '$2'"
|
||||||
CONFIG="$(realpath "$2" 2>/dev/null)"
|
CONFIG="$(cd "$ACTUAL_WORKING_DIRECTORY"; realpath --relative-to="$GENTOO_INSTALL_REPO_DIR" "$2" 2>/dev/null)"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
"-R"|"--chroot")
|
"-R"|"--chroot")
|
||||||
|
|
Loading…
Reference in New Issue