2021-07-14 05:41:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-07-16 01:56:36 +00:00
|
|
|
#------------------------------------------------------------------------#
|
|
|
|
# Copyright 2021, Jesse Gardner #
|
|
|
|
#------------------------------------------------------------------------#
|
|
|
|
# This file is part of qq2clone. #
|
|
|
|
# #
|
|
|
|
# qq2clone is free software: you can redistribute it and/or modify #
|
|
|
|
# it under the terms of the GNU General Public License as published by #
|
|
|
|
# the Free Software Foundation, either version 2 of the License, or #
|
|
|
|
# (at your option) any later version. #
|
|
|
|
# #
|
|
|
|
# qq2clone is distributed in the hope that it will be useful, #
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
|
|
# GNU General Public License for more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License #
|
|
|
|
# along with qq2clone. If not, see <https://www.gnu.org/licenses/>. #
|
|
|
|
#------------------------------------------------------------------------#
|
|
|
|
|
2021-07-14 22:08:38 +00:00
|
|
|
# Generate all files that need to be generated
|
2021-07-14 05:41:59 +00:00
|
|
|
|
2021-07-15 23:53:06 +00:00
|
|
|
declare -a inst_arc_files=( qq2clone qq2clone.1 qq2clone_completion.bash )
|
2021-07-15 01:47:47 +00:00
|
|
|
declare -a req_files=( "${arc_files[@]}" inst_fragment.bash "lv_api_do.c"
|
2021-07-16 01:56:36 +00:00
|
|
|
man.pandoc LICENSE)
|
2021-07-14 22:08:38 +00:00
|
|
|
|
|
|
|
# Check for required files
|
2021-07-14 05:41:59 +00:00
|
|
|
|
2021-07-14 19:17:33 +00:00
|
|
|
has_req=1
|
|
|
|
for file in "${req_files[@]}"; do
|
|
|
|
if [[ ! -e "$file" ]]; then
|
2021-07-14 22:08:38 +00:00
|
|
|
[[ "$file" == "lv_api_do" ]] && continue
|
2021-07-14 19:17:33 +00:00
|
|
|
has_req=0
|
|
|
|
echo "Current working directory missing file '$file'"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
((has_req)) || exit 1
|
2021-07-14 05:41:59 +00:00
|
|
|
|
2021-07-14 22:08:38 +00:00
|
|
|
# Compile lv_api_do
|
|
|
|
|
|
|
|
echo "Compiling lv_api_do"
|
|
|
|
gcc lv_api_do.c -o lv_api_do -lvirt
|
|
|
|
|
2021-07-15 23:53:06 +00:00
|
|
|
# Generate qq2clone
|
|
|
|
echo "Generating qq2clone"
|
|
|
|
while IFS= read -r line; do
|
|
|
|
if [[ "$line" == "#REPLACE WITH ARCHIVE#" ]]; then
|
|
|
|
echo "archive='"
|
2021-07-16 01:56:36 +00:00
|
|
|
tar -cz LICENSE lv_api_do | base64
|
2021-07-15 23:53:06 +00:00
|
|
|
echo "'"
|
|
|
|
else
|
|
|
|
echo "$line"
|
|
|
|
fi
|
|
|
|
done < qq2clone_noarchive > qq2clone
|
|
|
|
|
2021-07-14 22:08:38 +00:00
|
|
|
# Generate installer
|
|
|
|
|
|
|
|
echo "Generating installer script"
|
2021-07-14 05:41:59 +00:00
|
|
|
{
|
|
|
|
echo "#!/bin/bash"
|
2021-07-16 01:56:36 +00:00
|
|
|
echo
|
|
|
|
cat <<EOF
|
|
|
|
#------------------------------------------------------------------------#
|
|
|
|
# Copyright 2021, Jesse Gardner #
|
|
|
|
#------------------------------------------------------------------------#
|
|
|
|
# This file is part of qq2clone. #
|
|
|
|
# #
|
|
|
|
# qq2clone is free software: you can redistribute it and/or modify #
|
|
|
|
# it under the terms of the GNU General Public License as published by #
|
|
|
|
# the Free Software Foundation, either version 2 of the License, or #
|
|
|
|
# (at your option) any later version. #
|
|
|
|
# #
|
|
|
|
# qq2clone is distributed in the hope that it will be useful, #
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
|
|
# GNU General Public License for more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License #
|
|
|
|
# along with qq2clone. If not, see <https://www.gnu.org/licenses/>. #
|
|
|
|
#------------------------------------------------------------------------#
|
|
|
|
EOF
|
2021-07-14 05:54:05 +00:00
|
|
|
echo
|
2021-07-14 05:41:59 +00:00
|
|
|
echo "# This script generated automatically by gen_installer.bash"
|
2021-07-14 19:17:33 +00:00
|
|
|
echo
|
|
|
|
echo "archive='"
|
2021-07-15 23:53:06 +00:00
|
|
|
tar -cz "${inst_arc_files[@]}" | base64
|
2021-07-14 05:54:05 +00:00
|
|
|
echo "'"
|
|
|
|
echo
|
|
|
|
cat inst_fragment.bash
|
2021-07-14 05:41:59 +00:00
|
|
|
} > qq2clone_installer.bash
|
|
|
|
chmod +x qq2clone_installer.bash
|
2021-07-14 22:05:20 +00:00
|
|
|
|
|
|
|
# Generate manual from pandoc source in two formats
|
2021-07-14 22:08:38 +00:00
|
|
|
|
2021-07-14 22:05:20 +00:00
|
|
|
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
|