Skip to content

Commit

Permalink
Simplify config saving.
Browse files Browse the repository at this point in the history
Instead of hardcoding defaults in saveSample.sh.in, have the same
defaults in config. Then we can just remove them when saving the
config.
  • Loading branch information
stilor committed Jan 20, 2017
1 parent 955f5bc commit 3e4d487
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
3 changes: 1 addition & 2 deletions config/global/logging.in
Expand Up @@ -5,8 +5,7 @@ comment "Logging"
choice
bool
prompt "Maximum log level to see:"
default LOG_INFO if !DEBUG_CT
default LOG_DEBUG if DEBUG_CT
default LOG_EXTRA

config LOG_ERROR
bool
Expand Down
4 changes: 2 additions & 2 deletions config/global/paths.in
Expand Up @@ -5,7 +5,7 @@ comment "Paths"
config LOCAL_TARBALLS_DIR
string
prompt "Local tarballs directory" if ! BACKEND
default ""
default "${HOME}/src"
help
If you have previously downloaded the tarballs, enter the PATH where
you stored them here.
Expand All @@ -14,7 +14,7 @@ config SAVE_TARBALLS
bool
prompt "Save new tarballs" if ! BACKEND
depends on LOCAL_TARBALLS_DIR != "" || BACKEND
default y if BACKEND
default y
help
If you say 'y' here, new downloaded tarballs will be saved in the
directory you entered above.
Expand Down
19 changes: 11 additions & 8 deletions scripts/saveSample.sh.in
Expand Up @@ -40,14 +40,17 @@ esac
samp_dir="samples/${samp_name}"
mkdir -p "${samp_dir}"

# Tweak the .config file.
cp .config .defconfig
"${sed}" -r -e 's|^(CT_PREFIX_DIR)=.*|\1="${HOME}/x-tools/${CT_TARGET}"|;' \
-e 's|^# CT_LOG_TO_FILE is not set$|CT_LOG_TO_FILE=y|;' \
-e 's|^# CT_LOG_FILE_COMPRESS is not set$|CT_LOG_FILE_COMPRESS=y|;' \
-e 's|^(CT_LOCAL_TARBALLS_DIR)=.*|\1="${HOME}/src"|;' \
<.config \
>.defconfig
# Tweak the .config file: remove the options that we want to keep
# at default setting in samples.
force_default_opts=( \
PREFIX_DIR LOG_TO_FILE LOG_FILE_COMPRESS \
LOCAL_TARBALLS_DIR SAVE_TARBALLS \
LOG_ERROR LOG_WARN LOG_INFO LOG_EXTRA LOG_ALL LOG_DEBUG \
LOG_PROGRESS_BAR
)
regexp=${force_default_opts[*]}
regexp=${regexp// /|}
grep -v -E '^(# )?CT_('"${regexp}"')' .config > .defconfig

# Function to copy a file to the sample directory
# Needed in case the file is already there (think of a previously available sample)
Expand Down

0 comments on commit 3e4d487

Please sign in to comment.