From ff1761f5c86715694a8723b36dabe946a9a5feed Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii Date: Tue, 7 Jun 2022 18:33:58 +0000 Subject: [PATCH] Update SigScript Co-authored-by: sigonasr2 --- Java/scripts/build.sh | 6 ++-- Java/scripts/clean.sh | 4 +-- Java/scripts/commit.sh | 1 + Java/scripts/jar.sh | 8 ++++-- Java/scripts/release.sh | 14 ++++++++++ Java/scripts/update.sh | 3 ++ utils/define.sh | 3 +- utils/main.sh | 4 +-- utils/search.sh | 61 +++++++++++++++++++++++++++++++++-------- 9 files changed, 81 insertions(+), 23 deletions(-) create mode 100644 Java/scripts/release.sh create mode 100644 Java/scripts/update.sh diff --git a/Java/scripts/build.sh b/Java/scripts/build.sh index a9eba68..613d20e 100755 --- a/Java/scripts/build.sh +++ b/Java/scripts/build.sh @@ -1,9 +1,9 @@ #Builds and runs the project. #Java -rm -Rf out/* -javac -Xlint:unchecked -cp ${PROJECT_DIR}/.. -d ${OUT_DIR} ${PROJECT_DIR}/*.java +source ${LANGUAGE}/scripts/version_info +javac -source ${SOURCE_VERSION} -target ${TARGET_VERSION} -Xlint:unchecked -cp ${CLASS_PATH} -d ${OUT_DIR} ${PROJECT_DIR}/*.java printf "\n\n\nRunning Program...\n\n" ORIGINAL_LOC=$(pwd) cd $OUT_DIR -java ${MAIN_CLASS} "$@" +java -cp .:../lib/bin -Djava.library.path="${LIBRARY_PATH}" ${MAIN_CLASS} "$@" ${ORIGINAL_LOC}/${LANGUAGE}/scripts/clean.sh \ No newline at end of file diff --git a/Java/scripts/clean.sh b/Java/scripts/clean.sh index 55f2398..0963522 100755 --- a/Java/scripts/clean.sh +++ b/Java/scripts/clean.sh @@ -1,4 +1,4 @@ #Cleans up and removes unused files. #Java -find . -type f -name *.class -delete -find . -type f -name manifest -delete \ No newline at end of file +find -type f -name *.class -delete +find -type f -name manifest -delete \ No newline at end of file diff --git a/Java/scripts/commit.sh b/Java/scripts/commit.sh index 689cc0b..36b45b5 100755 --- a/Java/scripts/commit.sh +++ b/Java/scripts/commit.sh @@ -1,6 +1,7 @@ #Adds a commit message and pushes project to github repository. #Java COMMIT_MESSAGE="$*" +FIRST_LINE=true while IFS= read -r line do if [ "$FIRST_LINE" = true ]; then diff --git a/Java/scripts/jar.sh b/Java/scripts/jar.sh index 532ab48..d201c59 100755 --- a/Java/scripts/jar.sh +++ b/Java/scripts/jar.sh @@ -1,7 +1,8 @@ #Builds a runnable jar file using ${MAIN_CLASS} as an entry point and then runs the newly generated jar. #Java +source ${LANGUAGE}/scripts/version_info rm -Rf bin/* -javac -Xlint:unchecked -cp src -d bin ${PROJECT_DIR}/${PROJECT_NAME}.java +javac -source ${SOURCE_VERSION} -target ${TARGET_VERSION} -Xlint:unchecked -cp ${CLASS_PATH} -d ${OUT_DIR} ${PROJECT_DIR}/${PROJECT_NAME}.java printf "\n\n\nGenerating Manifest...\n\n" touch manifest echo "Main-Class: ${MAIN_CLASS}" >> manifest @@ -9,7 +10,8 @@ printf "\n\n\nCreating Jar...\n\n" ORIGINAL_LOC=$(pwd) cd ${OUT_DIR} jar cfm ${PROJECT_NAME}.jar ${ORIGINAL_LOC}/manifest sig +jar uf ${PROJECT_NAME}.jar -C ../lib/bin/ . printf "\n\n\nRunning Program...\n\n" -java -jar ${PROJECT_NAME}.jar "$@" +java -cp .:../lib/bin -Djava.library.path="${LIBRARY_PATH}" -jar ${PROJECT_NAME}.jar "$@" +../${LANGUAGE}/scripts/clean.sh cd .. -./${LANGUAGE}/scripts/clean.sh diff --git a/Java/scripts/release.sh b/Java/scripts/release.sh new file mode 100644 index 0000000..0f7389c --- /dev/null +++ b/Java/scripts/release.sh @@ -0,0 +1,14 @@ +#Creates a zip file containing all project contents. +#Java +source ${LANGUAGE}/scripts/version_info +TARGET_FILE="${PROJECT_NAME}_${RELEASE_VERSION}.zip" +FILES=$(cat ${LANGUAGE}/scripts/.package.files) +echo "Creating Package $TARGET_FILE..." +for f in $FILES +do + zip -ur $TARGET_FILE $f +done +echo "Complete!" +echo "" +echo "" +echo "" \ No newline at end of file diff --git a/Java/scripts/update.sh b/Java/scripts/update.sh new file mode 100644 index 0000000..517be05 --- /dev/null +++ b/Java/scripts/update.sh @@ -0,0 +1,3 @@ +#Pulls the latest version of the repository. +#Java +git pull \ No newline at end of file diff --git a/utils/define.sh b/utils/define.sh index 39a23d7..1dc7f41 100755 --- a/utils/define.sh +++ b/utils/define.sh @@ -8,10 +8,11 @@ function define() { eval export "$1"='$value' } -if [[ $(pwd) != *"SigScript" ]]; then +if [[ $(pwd) != *"SigScript" && $AUTO_UPDATE = "true" ]]; then source utils/search.sh find . -type f -name md5 -delete + find . -type f -name filelist -delete #Check for hashes FILES=$(cat utils/.updateDirectories) diff --git a/utils/main.sh b/utils/main.sh index b04ffab..d299d6b 100644 --- a/utils/main.sh +++ b/utils/main.sh @@ -13,10 +13,10 @@ if [ -z "$1" ] echo "" echo "" echo " Command List:" - FILES=$(ls -1A ./$LANGUAGE/scripts | sed -e 's/\.sh$//' | sed -e 's/^/ /') + FILES=$(ls -1A ./$LANGUAGE/scripts 2>/dev/null | sed -e 's/\.sh$//' | sed -e 's/^/ /') for f in $FILES do - if [ $f != "md5" ]; then + if [ -f "./$LANGUAGE/scripts/$f.sh" ]; then DESC="$(head -n1 ./$LANGUAGE/scripts/$f.sh)" printf "\n\t%-15s%-65s" $f "${DESC:1}" fi diff --git a/utils/search.sh b/utils/search.sh index 13307c4..99a69b3 100644 --- a/utils/search.sh +++ b/utils/search.sh @@ -1,5 +1,5 @@ function search() { - FILES2=$(ls -A $1) + FILES2=$(ls -A $1 2>/dev/null) for g in $FILES2 do if [ -d $1$g ]; @@ -8,11 +8,14 @@ function search() { search $1$g/ else echo "$1$g is a file" - if [ $g != "md5" ]; then - SUM=$(md5sum < $1$g) - echo "$g:$SUM" >> $1md5 + if [ $g != "md5" ] && [ $g != "filelist" ] && [ $g != ".package.files" ]; then + if [ $g != ".coauthors" ] && [ $g != "version_info" ]; then + SUM=$(md5sum < $1$g) + echo "$g:$SUM" >> $1md5 + fi + echo "$g" >> $1filelist else - echo " md5 file, ignoring..." + echo " ignoring $g..." fi fi done @@ -20,11 +23,11 @@ function search() { function check() { echo "Check $1" - FILES2=$(ls -A $1) + FILES2=$(ls -A $1 2>/dev/null) if [ -f "$1/md5" ]; then echo " md5: https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1md5" - curl -H 'Cache-Control: no-cache, no-store' -s https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1md5 --output /tmp/out + curl -H 'Cache-Control: no-cache, no-store' -s "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1md5" --output /tmp/out cmp -s $1/md5 /tmp/out if [ "$?" -ne 0 ] then @@ -35,21 +38,55 @@ function check() { IFS=':' read -ra split <<< $line g="${split[0]}" echo "LINE -- $g" - if [ "$g" != "md5" ]; then + if [ "$g" != "md5" ] && [ "$g" != "filelist" ] && [ "$g" != ".package.files" ]; then + if [ -f $1$g ]; + then + if [ "$g" != ".coauthors" ] && [ "$g" != "version_info" ]; then + echo "++Redownload $1$g..." + if [ -f "$1$g" ]; then + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g + else + echo "===Could not find directory, assuming regular scripts directory exists." + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $LANGUAGE/scripts/$g + fi + fi + else + echo "++==Downloading $1$g..." + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g + fi + fi + done < /tmp/out + fi + fi + if [ -f "$1/filelist" ]; + then + echo " filelist: https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1filelist" + curl -H 'Cache-Control: no-cache, no-store' -s "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1filelist" --output /tmp/out + cmp -s $1/filelist /tmp/out + if [ "$?" -ne 0 ] + then + echo " Differences detected!" + cat /tmp/out + while IFS= read -r line + do + IFS=':' read -ra split <<< $line + g="${split[0]}" + echo "LINE -- $g" + if [ "$g" != "md5" ] && [ "$g" != "filelist" ] && [ "$g" != ".package.files" ]; then if [ -f $1$g ]; then - if [ "$g" != ".coauthors" ]; then + if [ "$g" != ".coauthors" ] && [ "$g" != "version_info" ]; then echo "++Redownload $1$g..." if [ -f "$1$g" ]; then - curl -H 'Cache-Control: no-cache, no-store' https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g --output $1$g + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g else echo "===Could not find directory, assuming regular scripts directory exists." - curl -H 'Cache-Control: no-cache, no-store' https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g --output $LANGUAGE/scripts/$g + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $LANGUAGE/scripts/$g fi fi else echo "++==Downloading $1$g..." - curl -H 'Cache-Control: no-cache, no-store' https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g --output $1$g + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g fi fi done < /tmp/out