Skip to content

Commit

Permalink
test compilation of openjdk-17
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxython committed Jun 20, 2024
1 parent 2072b96 commit 67926df
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 42 deletions.
58 changes: 16 additions & 42 deletions packages/openjdk-17/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Java development kit and runtime"
TERMUX_PKG_LICENSE="GPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=17.0
TERMUX_PKG_REVISION=32
TERMUX_PKG_REVISION=33
_COMMIT=82234f890786d49c49cf4ecbcb09c47bd9bea7ed
TERMUX_PKG_SRCURL=https://github.com/openjdk/mobile/archive/$_COMMIT.tar.gz
TERMUX_PKG_SHA256=5b298148a26e754120c6dfe699056d0609fc6ed92bfc858dc2ba4909ef6e791b
Expand Down Expand Up @@ -50,12 +50,12 @@ termux_step_configure() {
OBJDUMP="$OBJDUMP" \
STRIP="$STRIP" \
CXXFILT="llvm-cxxfilt" \
BUILD_CC="/usr/bin/clang-16" \
BUILD_CXX="/usr/bin/clang++-16" \
BUILD_NM="/usr/bin/llvm-nm-16" \
BUILD_AR="/usr/bin/llvm-ar-16" \
BUILD_OBJCOPY="/usr/bin/llvm-objcopy-16" \
BUILD_STRIP="/usr/bin/llvm-strip-16"
BUILD_CC="/usr/bin/clang-17" \
BUILD_CXX="/usr/bin/clang++-17" \
BUILD_NM="/usr/bin/llvm-nm-17" \
BUILD_AR="/usr/bin/llvm-ar-17" \
BUILD_OBJCOPY="/usr/bin/llvm-objcopy-17" \
BUILD_STRIP="/usr/bin/llvm-strip-17"
}

termux_step_make() {
Expand Down Expand Up @@ -83,41 +83,15 @@ termux_step_post_make_install() {
}

termux_step_create_debscripts() {
local binaries="$(find $TERMUX_PREFIX/lib/jvm/java-17-openjdk/bin -executable -type f | xargs -I{} basename "{}" | xargs echo)"
local manpages="$(find $TERMUX_PREFIX/lib/jvm/java-17-openjdk/man/man1 -name "*.1.gz" | xargs -I{} basename "{}" | xargs echo)"
cat <<-EOF >./postinst
#!$TERMUX_PREFIX/bin/sh
if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --install $TERMUX_PREFIX/etc/profile.d/java.sh java-profile $TERMUX_PREFIX/lib/jvm/java-17-openjdk/etc/profile.d/java.sh 40
for tool in $binaries; do
update-alternatives --install \
$TERMUX_PREFIX/bin/\$tool \$tool \
$TERMUX_PREFIX/lib/jvm/java-17-openjdk/bin/\$tool 40
done
binaries="$(find $TERMUX_PREFIX/lib/jvm/java-17-openjdk/bin -executable -type f | xargs -I{} basename "{}" | xargs echo)"
manpages="$(find $TERMUX_PREFIX/lib/jvm/java-17-openjdk/man/man1 -name "*.1.gz" | xargs -I{} basename "{}" | xargs echo)"

for manpage in $manpages; do
update-alternatives --install \
$TERMUX_PREFIX/share/man/man1/\$manpage \$manpage \
$TERMUX_PREFIX/lib/jvm/java-17-openjdk/man/man1/\$manpage 60
done
fi
fi
EOF
cp $TERMUX_PKG_BUILDER_DIR/hooks/$TERMUX_PACKAGE_FORMAT/{postinst,prerm} .
sed -i -e "s|@TERMUX_PREFIX@|${TERMUX_PREFIX}|g" \
-e "s|@binaries@|${binaries}|g" \
-e "s|@manpages@|${manpages}|g" ./{postinst,prerm}

cat <<-EOF >./prerm
#!$TERMUX_PREFIX/bin/sh
if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --remove java-profile $TERMUX_PREFIX/etc/profile.d/java.sh
for tool in $binaries; do
update-alternatives --remove \$tool $TERMUX_PREFIX/bin/\$tool
done
for manpage in $manpages; do
update-alternatives --remove \$manpage $TERMUX_PREFIX/share/man/man1/\$manpage
done
fi
fi
EOF
if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ]; then
echo "post_install" > postupg
fi
}
18 changes: 18 additions & 0 deletions packages/openjdk-17/hooks/debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!@TERMUX_PREFIX@/bin/sh

if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
if [ -x "@TERMUX_PREFIX@/bin/update-alternatives" ]; then
update-alternatives --install @TERMUX_PREFIX@/etc/profile.d/java.sh java-profile @TERMUX_PREFIX@/lib/jvm/java-17-openjdk 40
for tool in @binaries@; do
update-alternatives --install \
@TERMUX_PREFIX@/bin/$tool $tool \
@TERMUX_PREFIX@/lib/jvm/java-17-openjdk/bin/$tool 40
done

for manpage in @manpages@; do
update-alternatives --install \
@TERMUX_PREFIX@/share/man/man1/$manpage $manpage \
@TERMUX_PREFIX@/lib/jvm/java-17-openjdk/man/man1/$manpage 60
done
fi
fi
14 changes: 14 additions & 0 deletions packages/openjdk-17/hooks/debian/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!@TERMUX_PREFIX@/bin/sh

if [ "$1" != "upgrade" ]; then
if [ -x "@TERMUX_PREFIX@/bin/update-alternatives" ]; then
update-alternatives --remove java-profile @TERMUX_PREFIX@/etc/profile.d/java.sh
for tool in @binaries@; do
update-alternatives --remove $tool @TERMUX_PREFIX@/bin/$tool
done

for manpage in @manpages@; do
update-alternatives --remove $manpage @TERMUX_PREFIX@/share/man/man1/$manpage
done
fi
fi
25 changes: 25 additions & 0 deletions packages/openjdk-17/hooks/pacman/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!@TERMUX_PREFIX@/bin/sh

if [ -f @TERMUX_PREFIX@/etc/profile.d/java.sh ]; then
raelpath=$(readlink @TERMUX_PREFIX@/etc/profile.d/java.sh)
sp_raelpath=(${raelpath//// })
if [ "${sp_raelpath[-4]}" != "java-17-openjdk" ]; then
echo "==> Attention, the commands will be reconfigured to openjdk-17. If you want to stay on \"${sp_raelpath[-4]}\" then reinstall the package"
fi
fi

echo "==> Setting up the openjdk-17 package..."

for i in @binaries@; do
ln -sfr "@TERMUX_PREFIX@/lib/jvm/java-17-openjdk/bin/${i}" "@TERMUX_PREFIX@/bin/${i}"
done

mkdir -p @TERMUX_PREFIX@/share/man/man1
for i in @manpages@; do
ln -sfr "@TERMUX_PREFIX@/lib/jvm/java-17-openjdk/man/man1/${i}" "@TERMUX_PREFIX@/share/man/man1/${i}"
done

mkdir -p @TERMUX_PREFIX@/etc/profile.d
ln -sfr @TERMUX_PREFIX@/lib/jvm/java-17-openjdk/etc/profile.d/java.sh @TERMUX_PREFIX@/etc/profile.d/java.sh

echo "==> Done"
19 changes: 19 additions & 0 deletions packages/openjdk-17/hooks/pacman/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!@TERMUX_PREFIX@/bin/sh

if [ -f @TERMUX_PREFIX@/etc/profile.d/java.sh ]; then
raelpath=$(readlink @TERMUX_PREFIX@/etc/profile.d/java.sh)
sp_raelpath=(${raelpath//// })
if [ "${sp_raelpath[-4]}" != "java-17-openjdk" ]; then
return
fi
fi

for i in @binaries@; do
rm "@TERMUX_PREFIX@/bin/${i}"
done

for i in @manpages@; do
rm "@TERMUX_PREFIX@/share/man/man1/${i}"
done

rm @TERMUX_PREFIX@/etc/profile.d/java.sh

0 comments on commit 67926df

Please sign in to comment.