Skip to content

Commit

Permalink
Added check to prevent input of invalid repo as main argument (#3728)
Browse files Browse the repository at this point in the history
* Added check to prevent input of invalid repo as main argument

* typos removal Update makejdk-any-platform.1

Co-authored-by: Martijn Verburg <martijnverburg@gmail.com>

* Update makejdk-any-platform.1 from typo

Co-authored-by: Martijn Verburg <martijnverburg@gmail.com>

* added space sbin/common/common.sh

Co-authored-by: Martijn Verburg <martijnverburg@gmail.com>

* typos fixed in sbin/common/common.sh

Co-authored-by: Martijn Verburg <martijnverburg@gmail.com>

* Update sbin/common/common.sh

Co-authored-by: Martijn Verburg <martijnverburg@gmail.com>

* Update sbin/common/common.sh

Co-authored-by: Martijn Verburg <martijnverburg@gmail.com>

* Update sbin/common/common.sh

Co-authored-by: Martijn Verburg <martijnverburg@gmail.com>

---------

Co-authored-by: Martijn Verburg <martijnverburg@gmail.com>
  • Loading branch information
judovana and karianna authored Apr 26, 2024
1 parent b1f8de0 commit c3c4a96
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions makejdk-any-platform.1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ that you are building for further details.

This will start a Docker container and build you the latest Java 8 Temurin
binary from the source at https://github.com/adoptium/openjdk-jdk8u
Note that the main argument, in this case jdk8, is compared and enforced
against an enumeration - jdk8, jdk8u, ... jdk21, jdk21u, ...jdk. Nothing else.
You can workaround this by \-\-version switch.

Please visit https://www.adoptium.net for further support

Expand Down
11 changes: 11 additions & 0 deletions sbin/common/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
function setOpenJdkVersion() {
local forest_name=$1

# The argument passed here have actually very strict format of jdk8, jdk8u..., jdk
# the build may fail later if this is not honoured.
# If your repository has a different name, you can use --version or build from dir/snapshot
local forest_name_check=0
echo "$forest_name" | grep -q -e "^jdk$" -e "^jdk[0-9]\\{1,3\\}[u]\\{0,1\\}$" || forest_name_check=$?
if [ ${forest_name_check} -ne 0 ]; then
echo "The mandatory repo argument has a very strict format 'jdk[0-9]{1,3}[u]{0,1}' or just plain 'jdk' for tip. '$forest_name' does not match."
echo "This can be worked around by using '--version jdkXYu'. If set (and matching) then the main argument can have any value."
exit 1
fi

# Derive the openjdk_core_version from the forest name.
local openjdk_core_version=${forest_name}
if [[ ${forest_name} == *u ]]; then
Expand Down

0 comments on commit c3c4a96

Please sign in to comment.