mirror of
https://github.com/mtan93/Installomator.git
synced 2026-03-08 05:31:53 +00:00
implemented the --labels option and assemble script now runs the assembled Installomator.sh with remaining arguments
This commit is contained in:
@@ -13,8 +13,8 @@ assemble.sh
|
||||
This will put together the fragments and labels from the default location (`fragments` and `fragments/labels`) and write it to `build/Installomator.sh`
|
||||
|
||||
```
|
||||
assemble.sh -- <label>
|
||||
assemnle.sh -- <label> <VAR=value>...
|
||||
assemble.sh <label>
|
||||
assemnle.sh <label> <VAR=value>...
|
||||
```
|
||||
|
||||
This will put together the fragments and labels from the default location, create the script in `build/Installomator.sh` and immediately run it with the given arguments. (Note: the script will run in debug mode, unless you specifically override this with `DEBUG=0`.)
|
||||
|
||||
@@ -1,5 +1,35 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# parse arguments
|
||||
|
||||
zparseopts -D -E -a opts s -script p -pkg n -notarize h -help -labels+:=label_args l+:=label_args
|
||||
|
||||
if (( ${opts[(I)(-h|--help)]} )); then
|
||||
echo "usage: assemble.sh [--script|--pkg|--notarize] [-labels path/to/labels ...] [arguments...]"
|
||||
echo
|
||||
echo "builds and runs the installomator script from the fragements."
|
||||
echo "additional arguments are passed into the Installomator script for testing."
|
||||
exit
|
||||
fi
|
||||
|
||||
if (( ${opts[(I)(-s|--script)]} )); then
|
||||
buildScript=1
|
||||
fi
|
||||
|
||||
if (( ${opts[(I)(-p|--pkg)]} )); then
|
||||
buildScript=1
|
||||
buildPkg=1
|
||||
fi
|
||||
|
||||
if (( ${opts[(I)(-n|--notarize)]} )); then
|
||||
buildScript=1
|
||||
buildPkg=1
|
||||
notarizePkg=1
|
||||
fi
|
||||
|
||||
label_flags=( -l --labels )
|
||||
# array substraction
|
||||
label_paths=${label_args:|label_flags}
|
||||
|
||||
#setup some folders
|
||||
script_dir=$(dirname ${0:A})
|
||||
@@ -9,6 +39,9 @@ destination_file="$build_dir/Installomator.sh"
|
||||
fragments_dir="$repo_dir/fragments"
|
||||
labels_dir="$fragments_dir/labels"
|
||||
|
||||
# add default labels_dir to label_paths
|
||||
label_paths+=$labels_dir
|
||||
|
||||
fragment_files=( header.txt version.txt functions.txt arguments.txt main.txt )
|
||||
|
||||
# check if fragment files exist (and are readable)
|
||||
@@ -44,7 +77,13 @@ cat "$fragments_dir/functions.txt" >> $destination_file
|
||||
cat "$fragments_dir/arguments.txt" >> $destination_file
|
||||
|
||||
# all the labels
|
||||
cat "$labels_dir"/*.txt >> $destination_file
|
||||
for lpath in $label_paths; do
|
||||
if [[ -d $lpath ]]; then
|
||||
cat "$lpath"/*.txt >> $destination_file
|
||||
else
|
||||
echo "$lpath not a directory, skipping..."
|
||||
fi
|
||||
done
|
||||
|
||||
# add the footer
|
||||
cat "$fragments_dir/main.txt" >> $destination_file
|
||||
@@ -52,3 +91,13 @@ cat "$fragments_dir/main.txt" >> $destination_file
|
||||
# set the executable bit
|
||||
chmod +x $destination_file
|
||||
|
||||
# run script with remaining arguments
|
||||
$destination_file "$@"
|
||||
|
||||
# TODO: build copy the script to root of repo when flag is set
|
||||
|
||||
# TODO: build a pkg when flag is set
|
||||
|
||||
# TODO: notarize when flag is set
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user