Updated build script
This commit is contained in:
parent
512cf90fc4
commit
91d99239d6
55
build.sh
55
build.sh
@ -28,7 +28,7 @@ rm -f "${target_zip}"
|
|||||||
# doc_dir: cd here before building.
|
# doc_dir: cd here before building.
|
||||||
# main_file: build this tex file. Usually main.tex
|
# main_file: build this tex file. Usually main.tex
|
||||||
function build() {
|
function build() {
|
||||||
local target_dir="${1}"
|
local b_target_dir="${1}"
|
||||||
local job_name="${2}"
|
local job_name="${2}"
|
||||||
local doc_dir="${3}"
|
local doc_dir="${3}"
|
||||||
local main_file="${4}"
|
local main_file="${4}"
|
||||||
@ -41,7 +41,6 @@ function build() {
|
|||||||
--web-bundle "https://static.betalupi.com/tectonic/texlive2023.tar"
|
--web-bundle "https://static.betalupi.com/tectonic/texlive2023.tar"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Build handout
|
# Build handout
|
||||||
echo "\\def\\argNoSolutions{1}\\input{${main_file}}" | \
|
echo "\\def\\argNoSolutions{1}\\input{${main_file}}" | \
|
||||||
tectonic \
|
tectonic \
|
||||||
@ -49,13 +48,13 @@ function build() {
|
|||||||
--outfmt pdf \
|
--outfmt pdf \
|
||||||
-
|
-
|
||||||
|
|
||||||
stat=$?
|
handout_stat=$?
|
||||||
|
|
||||||
if [[ $stat == 0 ]]; then
|
if [[ $handout_stat == 0 ]]; then
|
||||||
mkdir -p "${target_dir}"
|
mkdir -p "${b_target_dir}"
|
||||||
mv texput.pdf "${target_dir}/${job_name}.pdf"
|
mv texput.pdf "${b_target_dir}/${job_name}.pdf"
|
||||||
else
|
else
|
||||||
rmdir --ignore-fail-on-non-empty "${target_dir}"
|
rmdir --ignore-fail-on-non-empty "${b_target_dir}"
|
||||||
rm -f texput.pdf
|
rm -f texput.pdf
|
||||||
echo "|> Handout build failed"
|
echo "|> Handout build failed"
|
||||||
echo ""
|
echo ""
|
||||||
@ -69,30 +68,46 @@ function build() {
|
|||||||
--outfmt pdf \
|
--outfmt pdf \
|
||||||
-
|
-
|
||||||
|
|
||||||
stat=$?
|
solution_stat=$?
|
||||||
|
|
||||||
if [[ $stat == 0 ]]; then
|
if [[ $solution_stat == 0 ]]; then
|
||||||
mkdir -p "${target_dir}"
|
mkdir -p "${b_target_dir}"
|
||||||
mv texput.pdf "${target_dir}/${job_name}.sols.pdf"
|
mv texput.pdf "${b_target_dir}/${job_name}.sols.pdf"
|
||||||
else
|
else
|
||||||
rmdir --ignore-fail-on-non-empty "${target_dir}"
|
rmdir --ignore-fail-on-non-empty "${b_target_dir}"
|
||||||
rm -f texput.pdf
|
rm -f texput.pdf
|
||||||
echo "|> Solution build failed"
|
echo "|> Solution build failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean up if files contents are identical
|
# Clean up if files contents are identical
|
||||||
if cmp --silent -- "${target_dir}/${job_name}.sols.pdf" "${target_dir}/${job_name}.pdf"; then
|
#if [[ $(cmp -bl "${b_target_dir}/${job_name}.sols.pdf" "${b_target_dir}/${job_name}.pdf" | wc -l) < 200 ]]; then
|
||||||
echo "|> Versions identical, removing ${job_name}.sols.pdf"
|
# echo "|> Versions identical, removing ${job_name}.sols.pdf"
|
||||||
rm "${target_dir}/${job_name}.sols.pdf"
|
# rm "${b_target_dir}/${job_name}.sols.pdf"
|
||||||
fi
|
# solution_stat=1;
|
||||||
|
#fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
if [[ $handout_stat == 0 ]]; then
|
||||||
|
(
|
||||||
|
echo -n "{"
|
||||||
|
echo -n "\"title\": \"${job_name}\"",
|
||||||
|
echo -n "\"type\": \"$(realpath --relative-to="${target_dir}" "${b_target_dir}")\"",
|
||||||
|
echo -n "\"description\": \"${job_name}\"",
|
||||||
|
echo -n "\"handout\": \"https://static.betalupi.com/ormc/$(realpath --relative-to="${target_dir}" "${b_target_dir}")/${job_name}.pdf\","
|
||||||
|
if [[ $solution_stat == 0 ]]; then
|
||||||
|
echo -n "\"solutions\": \"https://static.betalupi.com/ormc/$(realpath --relative-to="${target_dir}" "${b_target_dir}")/${job_name}.sols.pdf\""
|
||||||
|
fi
|
||||||
|
echo -n "},"
|
||||||
|
) >> "$target_dir/index.json"
|
||||||
|
fi
|
||||||
cd "${run_dir}"
|
cd "${run_dir}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mkdir -p "${target_dir}"
|
||||||
|
echo -n "[" > "$target_dir/index.json"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -127,7 +142,11 @@ for d in "${run_dir}/Intermediate"/*/ ; do
|
|||||||
"main.tex"
|
"main.tex"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo -n "{}]" >> "$target_dir/index.json"
|
||||||
|
|
||||||
|
|
||||||
# cd so paths in zip are relative
|
# cd so paths in zip are relative
|
||||||
cd "${target_dir}"
|
cd "${target_dir}"
|
||||||
zip -FSr "${target_zip}" .
|
|
||||||
|
zip -FSr "${target_zip}" .
|
||||||
|
zip -d "${target_zip}" "index.json" # We don't need this in the zip
|
Loading…
x
Reference in New Issue
Block a user