qq2clone/gen_all.bash

59 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Generate all files that need to be generated
declare -a inst_arc_files=( qq2clone qq2clone.1 qq2clone_completion.bash )
declare -a req_files=( "${arc_files[@]}" inst_fragment.bash "lv_api_do.c"
man.pandoc )
# Check for required files
has_req=1
for file in "${req_files[@]}"; do
if [[ ! -e "$file" ]]; then
[[ "$file" == "lv_api_do" ]] && continue
has_req=0
echo "Current working directory missing file '$file'"
fi
done
((has_req)) || exit 1
# Compile lv_api_do
echo "Compiling lv_api_do"
gcc lv_api_do.c -o lv_api_do -lvirt
# Generate qq2clone
echo "Generating qq2clone"
while IFS= read -r line; do
if [[ "$line" == "#REPLACE WITH ARCHIVE#" ]]; then
echo "archive='"
tar -cz lv_api_do | base64
echo "'"
else
echo "$line"
fi
done < qq2clone_noarchive > qq2clone
# Generate installer
echo "Generating installer script"
{
echo "#!/bin/bash"
echo
echo "# This script generated automatically by gen_installer.bash"
echo
echo "archive='"
tar -cz "${inst_arc_files[@]}" | base64
echo "'"
echo
cat inst_fragment.bash
} > qq2clone_installer.bash
chmod +x qq2clone_installer.bash
# Generate manual from pandoc source in two formats
echo "Generating manual"
pandoc -s -f markdown -t markdown_strict -o man.md man.pandoc
pandoc -s -f markdown -t man -o qq2clone.1 man.pandoc