updated build system
authorMikhail Kobuk <[email protected]>
Sat, 13 Apr 2024 04:17:27 +0000 (07:17 +0300)
committerMikhail Kobuk <[email protected]>
Sat, 13 Apr 2024 04:17:27 +0000 (07:17 +0300)
Makefile
build.sh
mksite.sh [new file with mode: 0755]

index bb3ccd3c26ed4b8e64d7f0bcdd29c588e0ac192e..1d93d289bec45ab79ad339b7177eb165af118cd5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,14 +4,20 @@ PD_FORMAT=-f markdown -t html
 PD_STANDALONE=--standalone --embed-resources
 
 # SRC = $(wildcard ./lab*/*.md)
+SRC_INTRO = index.md
+OUT_INTRO = $(patsubst %.md,%.html, $(SRC_INTRO))
 SRC = $(wildcard ./lab*)
-SRC += Linux_labs_0_Introduction.md
+SRC += $(SRC_INTRO)
 
 default: all
 
 all: build
 
 build: prerequisites
+       ./build.sh "$(PANDOC)" "$(PD_FLAGS)" "$(PD_FORMAT)" $(SRC)
+       mkdir -pv ./LinuxLabs
+       ./mksite.sh $(SRC)
+       tar -czvf LinuxLabs.tar.gz LinuxLabs/
 
 standalone: prerequisites
        ./build.sh "$(PANDOC)" "$(PD_FLAGS) $(PD_STANDALONE)" "$(PD_FORMAT)" $(SRC)
@@ -20,6 +26,9 @@ clean:
        rm -rf easy-pandoc-templates
        rm -f ./*.html
 
+clear:
+       rm -f ./*.html
+
 prerequisites: easy-pandoc-templates $(SRC)
 
 easy-pandoc-templates:
index 0067dac585daee78416da044328b8f34a5eff7cc..33c85769339c4962fa3676e7b9ac74267888f934 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -36,7 +36,7 @@ for src in ${sources}; do
        elif [ -f ${src} ] && [ "${src##*.}" == "md" ]; then
                printf "\tfound md file: ${src}\n"
 
-               printf "\t${panexec} ${panflags} ${src} ${panformat} -o ${src%.*}.html"
+               printf "\t${panexec} ${panflags} ${src} ${panformat} -o ${src%.*}.html\n"
                ${panexec} ${panflags} ${src} ${panformat} -o ${src%.*}.html
        else
                printf "Unknown source (%s) - skipping\n" "$src"
diff --git a/mksite.sh b/mksite.sh
new file mode 100755 (executable)
index 0000000..c0bbc8f
--- /dev/null
+++ b/mksite.sh
@@ -0,0 +1,48 @@
+#! /bin/bash
+
+# USE: ./build.sh <pandoc> <pandoc_flags> <pandoc_format> [sources]
+
+sources=${@}
+echo "sources: ${sources}"
+
+function process_dir() {
+               pushd .
+               arg_dir=$1
+
+               cd ${arg_dir}
+               indir_src="$(find . -name '*.md')"
+               indir_out="${indir_src##*/}"
+               ${panexec} ${panflags} ${indir_src} ${panformat} -o ../${indir_out%.*}.html
+
+               mkdir ../site/${arg_dir}
+
+               cp -v ./*.png ../site/${arg_dir}
+               mv -v ../${indir_out%.*}.html ../site/${arg_dir}/index.html
+
+               popd
+}
+
+for src in ${sources}; do
+       if [ -d ${src} ]; then
+               printf "\tfound dir: ${src}\n"
+
+               if [ "$(find ${src} -name '*.md' | wc -l)" != "1" ]; then
+                       printf "\tToo many files in dir. Won't build. Skipping.\n"
+                       continue
+               fi
+
+               process_dir ${src}
+
+       elif [ -f ${src} ] && [ "${src##*.}" == "md" ]; then
+               printf "\tfound md file: ${src}\n"
+
+               printf "\tmv -v ${src%.*}.html ../site/${src%.*}.html\n"
+               mv -v ${src%.*}.html site/
+       else
+               printf "Unknown source (%s) - skipping\n" "$src"
+       fi
+done
+
+#for lab in $(find . -maxdepth 1 -name "lab*" -type d); do
+#      echo "Found directory ${lab}"
+#done

Powered by Git