diff --git a/rwfus_include/config.sh b/rwfus_include/config.sh index 1e03878..6be96a3 100644 --- a/rwfus_include/config.sh +++ b/rwfus_include/config.sh @@ -144,11 +144,11 @@ function change_base { } function enable_testmode { - echo "Enabling test mode." + echo "Test mode active." local testdir="${1:-./test}" for value in $CF_TESTPATHS; do if [[ ! "${!value}" = *"$testdir"* ]]; then - echo "${value}: ${testdir}${!value}" + # echo "${value}: ${testdir}${!value}" export "${value}"="${testdir}${!value}" fi done @@ -221,20 +221,38 @@ function load_config { fi fi done < "$config_file" + CONFIG_LOADED=true if [ "$TESTMODE" ]; then enable_testmode ./test; fi } +# Removes a substring from a named config variable +function migrate_remove { + local name="$1" + local needle="$2" + local cf_var="cf_$name" + if [[ "${!cf_var}" =~ "$needle" ]]; then + echo "- $name ${!cf_var}" + export "$cf_var=${!cf_var/${needle}}" + export "$cf_var=${!cf_var// / }" + echo "+ $name ${!cf_var}" + fi +} + +# Migrates config to the latest version function migrate_config { - if [[ $cf_Version != $Version ]]; then - echo Changing "'Directories'" - echo "-${cf_Directories}" - cf_Directories="${cf_Directories/\/var\/lib\/pacman}" - cf_Directories="${cf_Directories// / }" - echo "+${cf_Directories}" + if [[ "${cf_Version}" != "$Version" ]]; then + echo + echo "Migrating config from '$cf_Version' to '$Version'. This will not delete any files." + + migrate_remove "Directories" "/var/lib/pacman" + + echo - cf_Version="${Version}" - save_config "$1" + cf_Version="$Version" + return 0 + else + return 1 fi } @@ -251,7 +269,7 @@ function config { save_config "$config_file" ;; m|migrate) - migrate_config "$config_file" + migrate_config ;; *) return 127 diff --git a/rwfus_include/info.sh b/rwfus_include/info.sh index ba962ef..b03e93a 100644 --- a/rwfus_include/info.sh +++ b/rwfus_include/info.sh @@ -3,4 +3,4 @@ export Name="Rwfus" export Description="Carry Pacman across SteamOS updates!" export Repository="https://github.com/ValShaped/rwfus" -export Version="0.5.0.b2" +export Version="0.5.0.b3" diff --git a/rwfus_include/manage-install.sh b/rwfus_include/manage-install.sh index c2b5427..78ca593 100644 --- a/rwfus_include/manage-install.sh +++ b/rwfus_include/manage-install.sh @@ -37,11 +37,15 @@ function setup_pacman { } function perform_install { - #? SteamOS 3.5 migration: modify config - Log -p echo "$Name $Version is only compatible with SteamOS 3.5" - confirm "Are you sure you want to install $Name $Version?" - #> SteamOS 3.5 migration: modify config - Log config migrate + #? Migrate existing config + if config migrate; then + if (confirm "Are you sure you want to update to $Version?"); then + Log config store + else + exit 1; + fi + fi + Log -p echo "Creating overlays for $cf_Directories:" if list_service > /dev/null; then