moved more stuff around

This commit is contained in:
Armin Briegel
2021-04-21 12:24:47 +02:00
parent 248c90bec7
commit fbc6b61add
9 changed files with 752 additions and 3865 deletions

View File

@@ -2,4 +2,65 @@
Since the Installomator.sh script has grown to over 3000 lines, its management on git has become very unwieldy. Because of that we have split the main script into multiple text files which are easier to manage. Having multiple files results in less merge conflicts.
The full script is assembled using the `utils/assemble.sh` tool. For convenience, there is a symbolic link in the root of the repository.
The full script is assembled using the `utils/assemble.sh` tool. For convenience, there is a symbolic link in the root of the repository.
## assemble.sh Usage
```
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>...
```
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`.)
### Adding custom labels
```
assemble.sh --labels path/to/labels_dir
```
Text files from this directory will be added _in addition to_ the default labels directory `fragments/labels`. The custom labels will be inserted in the script _before_ the default labels, so custom labels will override default labels. You can add multiple `--labels` arguments:
```
assemble.sh --labels ../my_labels/test --labels ../my_labels/production
```
In this case the labels from `../my_labels/test` will be inserted first, then the labels from `../my_labels/production` and then the labels from `fragments/labels`
### Building for Release
```
assemble.sh --script
```
This will build the full script and place it in the root of the repo.
```
assemble.sh --pkg
```
Build the full script, disable Debug mode and build an installer pkg.
```
assemble.sh --notarize
```
Build the full script, disable Debug mode, sign it, build a signed pkg, and send it to notarization.
## The Fragments
These are the fragments in the order they are assembled:
- header.txt
- version.txt
- functions.txt
- arguments.txt
- all labels from locations given with the ``--labels` argument
- labels/*.txt
- main.txt

48
utils/assemble.sh Normal file → Executable file
View File

@@ -1,14 +1,54 @@
#!/bin/zsh
destination_file="Installomator_assembled.sh"
fragments_dir="fragments"
#setup some folders
script_dir=$(dirname ${0:A})
repo_dir=$(dirname $script_dir)
build_dir="$repo_dir/build"
destination_file="$build_dir/Installomator.sh"
fragments_dir="$repo_dir/fragments"
labels_dir="$fragments_dir/labels"
# read the header
fragment_files=( header.txt version.txt functions.txt arguments.txt main.txt )
# check if fragment files exist (and are readable)
for fragment in $fragment_files; do
if [[ ! -e $fragments_dir/$fragment ]]; then
echo "$fragments_dir/$fragment not found!"
exit 1
fi
done
if [[ ! -d $labels_dir ]]; then
echo "$labels_dir not found!"
exit 1
fi
# create $build_dir when necessary
mkdir -p $build_dir
# add the header
cat "$fragments_dir/header.txt" > $destination_file
# read the version.txt
version=$(cat "$fragments_dir/version.txt")
versiondate=$(date +%F)
echo "VERSION=\"$version\"" >> $destination_file
echo "VERSIONDATE=\"$versiondate\"" >> $destination_file
echo >> $destination_file
# add the functions.txt
cat "$fragments_dir/functions.txt" >> $destination_file
# add the arguments.txt
cat "$fragments_dir/arguments.txt" >> $destination_file
# all the labels
cat "$labels_dir"/*.txt >> $destination_file
# add the footer
cat "$fragments_dir/footer.txt" >> $destination_file
cat "$fragments_dir/main.txt" >> $destination_file
# set the executable bit
chmod +x $destination_file

0
utils/extractLabels.sh Normal file → Executable file
View File