From 3c1ed3735563c5e7c5b5eee09c9a8fe2a3b46f95 Mon Sep 17 00:00:00 2001 From: zrh535 <87528776+zrh535@users.noreply.github.com> Date: Thu, 14 Sep 2023 07:57:36 -0400 Subject: [PATCH] prefix / to support building on a windows host --- tools/genappendix.sh | 5 +++++ tools/genpdf.sh | 5 +++++ tools/interactive.sh | 7 ++++++- tools/mike.sh | 5 +++++ tools/run-in-container/genappendix_b_table.awk | 17 ++++++++--------- tools/run-in-container/genpdf.sh | 2 +- tools/serve-ghpages.sh | 5 +++++ tools/serve.sh | 7 ++++++- 8 files changed, 41 insertions(+), 12 deletions(-) diff --git a/tools/genappendix.sh b/tools/genappendix.sh index 026b43a0..b2478440 100755 --- a/tools/genappendix.sh +++ b/tools/genappendix.sh @@ -1,4 +1,9 @@ #!/bin/bash DATA_DIR="$(cd "$(dirname "${0}")/.." && pwd)" +## windows hosts require leading // instead of / +case "$OSTYPE" in + msys*) DATA_DIR="/${DATA_DIR}" ;; + cygwin*) DATA_DIR="/${DATA_DIR}" ;; +esac docker run -v ${DATA_DIR}:/data --rm -it trivadis/mktools bash -c "cd /data; ./tools/run-in-container/genappendix.sh docs/9-appendix/appendix.md" diff --git a/tools/genpdf.sh b/tools/genpdf.sh index 1cd3c850..d63a495d 100755 --- a/tools/genpdf.sh +++ b/tools/genpdf.sh @@ -1,4 +1,9 @@ #!/bin/bash DATA_DIR="$(cd "$(dirname "${0}")/.." && pwd)" +## windows hosts require leading // instead of / +case "$OSTYPE" in + msys*) DATA_DIR="/${DATA_DIR}" ;; + cygwin*) DATA_DIR="/${DATA_DIR}" ;; +esac docker run -v ${DATA_DIR}:/data --rm -it trivadis/mktools bash -c "cd /data; ./tools/run-in-container/genpdf.sh" diff --git a/tools/interactive.sh b/tools/interactive.sh index 8a78ce30..728b2efb 100755 --- a/tools/interactive.sh +++ b/tools/interactive.sh @@ -1,4 +1,9 @@ #!/bin/bash DATA_DIR="$(cd "$(dirname "${0}")/.." && pwd)" -docker run -v ${DATA_DIR}:/data -p 8000:8000 --rm -it trivadis/mktools bash \ No newline at end of file +## windows hosts require leading // instead of / +case "$OSTYPE" in + msys*) DATA_DIR="/${DATA_DIR}" ;; + cygwin*) DATA_DIR="/${DATA_DIR}" ;; +esac +docker run -v ${DATA_DIR}:/data -p 8000:8000 --rm -it trivadis/mktools bash diff --git a/tools/mike.sh b/tools/mike.sh index 3e7f8b3f..4afc48f9 100755 --- a/tools/mike.sh +++ b/tools/mike.sh @@ -1,6 +1,11 @@ #!/bin/bash DATA_DIR="$(cd "$(dirname "${0}")/.." && pwd)" +## windows hosts require leading // instead of / +case "$OSTYPE" in + msys*) DATA_DIR="/${DATA_DIR}" ;; + cygwin*) DATA_DIR="/${DATA_DIR}" ;; +esac GIT_USERNAME="$(git config user.name)" GIT_EMAIL="$(git config user.email)" COMMAND="/data/tools/run-in-container/mike.sh '${GIT_USERNAME}' '${GIT_EMAIL}' $1 $2 $3 $4" diff --git a/tools/run-in-container/genappendix_b_table.awk b/tools/run-in-container/genappendix_b_table.awk index 56d9d666..60b87d73 100755 --- a/tools/run-in-container/genappendix_b_table.awk +++ b/tools/run-in-container/genappendix_b_table.awk @@ -22,15 +22,15 @@ BEGIN { text=$0; # We just remove the # G-: from the beginning of the text dummy=sub(/^# G-[[:digit:]]+: /,"",text); - + # Get the second of the 4 lines and ignore it, it's empty getline; - + # Get the third of the 4 lines getline; # Retrieve the severity field from the third line severity=substr($3,2,length($3)-2); - + # Get the fourth and last of the 4 lines getline; # If the char array was filled from the last iteration, we need to empty it here @@ -42,7 +42,7 @@ BEGIN { char[6]=""; char[7]=""; char[8]=""; - + # The fourth line is a comma-separated list of characteristics - split them into an array no_of_characteristics=split($0,characteristics,","); for (i in characteristics) { @@ -55,7 +55,7 @@ BEGIN { if (characteristics[i] ~ /Reusability/ ) {char[6]="✘"} if (characteristics[i] ~ /Security/ ) {char[7]="✘"} if (characteristics[i] ~ /Testability/ ) {char[8]="✘"} - + # If the characteristics value is something other than these 8 values, we output an error in the text so it'll be noticed if (!(characteristics[i] ~ /Changeability/ || \ characteristics[i] ~ /Efficiency/ || \ @@ -66,16 +66,15 @@ BEGIN { characteristics[i] ~ /Security/ || \ characteristics[i] ~ /Testability/ )) {text="!!!CHARACTERISTIC ERROR!!!"} } - + # Output the fields of the markdown table in appendix B print old_id, new_id, text, severity, char[1], char[2], char[3], char[4], char[5], char[6], char[7], char[8]; - + # Special handling - between rule G-5040 and G-5050 we output the old rule 54 that is not mapped to any new rule if (new_id == "5040") { print "54 | n/a | Avoid use of EXCEPTION_INIT pragma for a 20nnn error. | Major | | | | | ✘ | | | "; } - + # Done handling the 4 lines of one .md file. Next 4 lines will be from another .md file and be handled in the next iteration. } } - diff --git a/tools/run-in-container/genpdf.sh b/tools/run-in-container/genpdf.sh index 49e67d15..d2701af8 100755 --- a/tools/run-in-container/genpdf.sh +++ b/tools/run-in-container/genpdf.sh @@ -12,7 +12,7 @@ function copy_resources() { cp -r ${DATA_DIR}/docs/stylesheets ${TARGET_DIR}/docs/stylesheets } -# Materials for MkDocs 5.5.14 uses CSS that leads to wkhtmltopdf 0.12.6 printing all line numbers before the code with +# Materials for MkDocs 5.5.14 uses CSS that leads to wkhtmltopdf 0.12.6 printing all line numbers before the code with # - "codehilite" plugin and "linenums: true" # - "pymdownx.highlight" plugin and "linenums_style: table" (default) # The workaround is to use "pymdownx.highlight" with "linenums_style: pymdownx-inline" and some CSS fixes diff --git a/tools/serve-ghpages.sh b/tools/serve-ghpages.sh index 8eac5cda..08db4718 100755 --- a/tools/serve-ghpages.sh +++ b/tools/serve-ghpages.sh @@ -2,4 +2,9 @@ # serves local gh-pages - use to verify deployed sites with version selector before pushing gh-pages branch DATA_DIR="$(cd "$(dirname "${0}")/.." && pwd)" +## windows hosts require leading // instead of / +case "$OSTYPE" in + msys*) DATA_DIR="/${DATA_DIR}" ;; + cygwin*) DATA_DIR="/${DATA_DIR}" ;; +esac docker run -v ${DATA_DIR}:/data -p 8000:8000 --rm -it trivadis/mktools bash -c "cd /data; mike serve -a 0.0.0.0:8000" diff --git a/tools/serve.sh b/tools/serve.sh index 9498d8c1..bb6e1746 100755 --- a/tools/serve.sh +++ b/tools/serve.sh @@ -2,4 +2,9 @@ # serves from temporary site directory - use during development for live preview of changes in docs directory DATA_DIR="$(cd "$(dirname "${0}")/.." && pwd)" -docker run -v ${DATA_DIR}:/data -p 8000:8000 --rm -it trivadis/mktools bash -c "cd /data; mkdocs serve -a 0.0.0.0:8000" \ No newline at end of file +## windows hosts require leading // instead of / +case "$OSTYPE" in + msys*) DATA_DIR="/${DATA_DIR}" ;; + cygwin*) DATA_DIR="/${DATA_DIR}" ;; +esac +docker run -v ${DATA_DIR}:/data -p 8000:8000 --rm -it trivadis/mktools bash -c "cd /data; mkdocs serve -a 0.0.0.0:8000"