From 72bf327cfd98b4ede03c6a269faed9f90aa7ed2f Mon Sep 17 00:00:00 2001 From: Gerard Jongerhuis Date: Tue, 5 Dec 2023 14:23:06 +0100 Subject: [PATCH 1/2] Adapt script for python3 and https://central.sonatype.com/ --- make-pom.sh | 79 +++++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/make-pom.sh b/make-pom.sh index 4cd30b9..4f0cc39 100755 --- a/make-pom.sh +++ b/make-pom.sh @@ -3,33 +3,34 @@ if [ "$1" == "" ]; then echo "Error: You did not specify the path of the directory to process" echo "Syntax: $0 /path/to/project/lib/containing/jar/files" - exit 1; + exit 1 fi cd "$1" -for file in `find -name "*.jar" | sed "s/^\.\///g"`; do +for file in $(find -name "*.jar" | sed "s/^\.\///g"); do -VERSION=`unzip -p - $file META-INF/maven/*/*/pom.properties 2>/dev/null | grep "^version" | cut -d '=' -f 2 | sed -e 's/[[:space:]]*$//'` -ART=`unzip -p - $file META-INF/maven/*/*/pom.properties 2>/dev/null | grep "^artifactId" | cut -d '=' -f 2 | sed -e 's/[[:space:]]*$//'` -GROUP=`unzip -p - $file META-INF/maven/*/*/pom.properties 2>/dev/null | grep "^groupId" | cut -d '=' -f 2 | sed -e 's/[[:space:]]*$//'` + VERSION=$(unzip -p - $file META-INF/maven/*/*/pom.properties 2>/dev/null | grep "^version" | cut -d '=' -f 2 | sed -e 's/[[:space:]]*$//') + ART=$(unzip -p - $file META-INF/maven/*/*/pom.properties 2>/dev/null | grep "^artifactId" | cut -d '=' -f 2 | sed -e 's/[[:space:]]*$//') + GROUP=$(unzip -p - $file META-INF/maven/*/*/pom.properties 2>/dev/null | grep "^groupId" | cut -d '=' -f 2 | sed -e 's/[[:space:]]*$//') -echo "" >> pom.xml + echo "" >>pom.xml -if [ "$VERSION" != "" ]; then - echo "$file found dep info in jar" - echo "" >> pom.xml - echo " $GROUP" >> pom.xml - echo " $ART" >> pom.xml - echo " $VERSION" >> pom.xml - echo "" >> pom.xml - echo "" >> pom.xml -else - SHA1=`sha1sum $file` - #LOOKUPINFO=`lookup-jar.py $file $SHA1` + if [ "$VERSION" != "" ]; then + echo "$file found dep info in jar" + echo "" >>pom.xml + echo " $GROUP" >>pom.xml + echo " $ART" >>pom.xml + echo " $VERSION" >>pom.xml + echo "" >>pom.xml + echo "" >>pom.xml + else + SHA1=$(sha1sum $file) + #LOOKUPINFO=`lookup-jar.py $file $SHA1` - # call python script to lookup jar by SHA1 checksum on search.maven.org - LOOKUPINFO=$(python - $file $SHA1 << END + # call python script to lookup jar by SHA1 checksum on search.maven.org + LOOKUPINFO=$( + python - $file $SHA1 <> pom.xml - else - # did not find on search.maven.org so add info from MANIFEST.MF - echo "$file ***** dep info not found *****" - MFHEAD=`unzip -p - $file META-INF/MANIFEST.MF | head -n 15` - VERSION=`unzip -p - $file META-INF/MANIFEST.MF | head -n 15 | grep "Implementation-Version" | cut -d ':' -f 2 | sed -e 's/[[:space:]]*//' | tr -d "\r"` - echo "" >> pom.xml - echo "" >> pom.xml - echo " $file" >> pom.xml - echo " $file" >> pom.xml - echo " $VERSION" >> pom.xml - echo "" >> pom.xml - echo "" >> pom.xml + ) + + if [ "$LOOKUPINFO" != "" ]; then + echo $file found dep info at search.maven.org + echo $LOOKUPINFO >>pom.xml + else + # did not find on search.maven.org so add info from MANIFEST.MF + echo "$file ***** dep info not found *****" + MFHEAD=$(unzip -p - $file META-INF/MANIFEST.MF | head -n 15) + VERSION=$(unzip -p - $file META-INF/MANIFEST.MF | head -n 15 | grep "Implementation-Version" | cut -d ':' -f 2 | sed -e 's/[[:space:]]*//' | tr -d "\r") + echo "" >>pom.xml + echo "" >>pom.xml + echo " $file" >>pom.xml + echo " $file" >>pom.xml + echo " $VERSION" >>pom.xml + echo "" >>pom.xml + echo "" >>pom.xml + fi fi -fi done From da94c7b0468f29138dc88170ca209a40b98de444 Mon Sep 17 00:00:00 2001 From: Gerard Jongerhuis Date: Tue, 5 Dec 2023 14:39:40 +0100 Subject: [PATCH 2/2] Adapt script for python3 and https://central.sonatype.com/ --- make-pom.sh | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/make-pom.sh b/make-pom.sh index 4f0cc39..44f2e85 100755 --- a/make-pom.sh +++ b/make-pom.sh @@ -8,7 +8,7 @@ fi cd "$1" -for file in $(find -name "*.jar" | sed "s/^\.\///g"); do +for file in $(gfind -name "*.jar" | sed "s/^\.\///g"); do VERSION=$(unzip -p - $file META-INF/maven/*/*/pom.properties 2>/dev/null | grep "^version" | cut -d '=' -f 2 | sed -e 's/[[:space:]]*$//') ART=$(unzip -p - $file META-INF/maven/*/*/pom.properties 2>/dev/null | grep "^artifactId" | cut -d '=' -f 2 | sed -e 's/[[:space:]]*$//') @@ -25,32 +25,33 @@ for file in $(find -name "*.jar" | sed "s/^\.\///g"); do echo "" >>pom.xml echo "" >>pom.xml else - SHA1=$(sha1sum $file) + SHA1=$(shasum $file) + shas=($SHA1) #LOOKUPINFO=`lookup-jar.py $file $SHA1` # call python script to lookup jar by SHA1 checksum on search.maven.org LOOKUPINFO=$( - python - $file $SHA1 <\r\n" - jarinfo = data["response"]["docs"][0] - print '\r\n' - print ' '+jarinfo["g"]+'\r\n' - print ' '+jarinfo["a"]+'\r\n' - print ' '+jarinfo["v"]+'\r\n' - print '\r\n' - print '\r\n' + print("\r\n") + jarinfo = data["response"]["docs"][0] + print('\r\n') + print(' '+jarinfo["g"]+'\r\n') + print(' '+jarinfo["a"]+'\r\n') + print(' '+jarinfo["v"]+'\r\n') + print('\r\n') + print('\r\n') END ) @@ -76,3 +77,4 @@ END fi done +