Files
tms-java1.8-pkg/PKGBUILD
2026-01-13 20:46:32 +08:00

79 lines
2.8 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Maintainer: zj <1052308357@qq.com>
pkgname=tms-oracle-jdk8
pkgver=8.471 # 对应 8u471
pkgrel=3
pkgdesc="Oracle Java Development Kit 8 (JDK 8) - A development environment for building applications, applets, and components using the Java programming language."
arch=('x86_64')
url="https://www.oracle.com/java/technologies/downloads/"
license=('Oracle Binary Code License Agreement for Java SE')
# options=('!strip')
# 运行时依赖无特定运行时依赖因为它是一个自包含的JDK
# depends=('archlinux-java') # 需要 archlinux-java 来管理 Java 版本
makedepends=('tar' 'gzip')
source=("jdk-${pkgver/./u}-linux-x64.tar.gz"
"java.security"
)
sha256sums=('5cddefbe9e10551d7149153a416111d1cbd177afaa7873f61b3168de104f13d8'
'0469f036a608e0372ec12557097df6a7c3ca6b9c18e1b3e63684f5fbb26f2d7e')
_jdk_dir_name="jdk1.8.0_471"
_install_path="/usr/local/oracle-jdk-8"
prepare() {
# 1. 检查 JDK 压缩包是否存在
if [ ! -f "$srcdir/jdk-${pkgver/./u}-linux-x64.tar.gz" ]; then
error "JDK source archive 'jdk-${pkgver/./u}-linux-x64.tar.gz' not found."
error "Please download it manually from Oracle's website and place it in the PKGBUILD directory."
error "URL: https://www.oracle.com/java/technologies/downloads/archive-downloads/jdk8-downloads.html (requires Oracle account login)"
exit 1
fi
# 2. 生成 java.sh 脚本内容 (使用你提供的详细内容)
# 这个脚本将设置 JAVA_HOME, JRE_HOME, CLASSPATH 和 PATH
cat > "$srcdir/java.sh" << EOF
# /etc/profile.d/java.sh for Oracle JDK 8
export JAVA_HOME="${_install_path}"
export JRE_HOME="\${JAVA_HOME}/jre"
export CLASSPATH=".:\${JAVA_HOME}/lib:\${JRE_HOME}/lib:\$CLASSPATH"
export JAVA_PATH="\${JAVA_HOME}/bin:\${JRE_HOME}/bin"
export PATH="\$PATH:\${JAVA_PATH}"
EOF
chmod 644 "$srcdir/java.sh"
}
build() {
# Oracle JDK是预编译的二进制文件无需构建
return 0
}
package() {
# 1. 创建 JDK 目标安装目录
install -d "$pkgdir${_install_path}"
# 2. 将解压后的 JDK 文件复制到目标目录
echo "Extracting and copying JDK to ${_install_path}..."
cp -r "$srcdir/${_jdk_dir_name}/"* "$pkgdir${_install_path}/"
install -m 644 "$srcdir/java.security" "$pkgdir${_install_path}/jre/lib/security/java.security"
# 3. 设置 JDK 文件的权限
# 通常 JDK 文件由 root 拥有,权限为 755
chmod -R 755 "$pkgdir${_install_path}"
chown -R root:root "$pkgdir${_install_path}"
# 4. 安装 java.sh 脚本到 /etc/profile.d/
echo "Installing java.sh to /etc/profile.d/..."
install -d "$pkgdir/etc/profile.d/"
install -m 644 "$srcdir/java.sh" "$pkgdir/etc/profile.d/java.sh"
}
post_remove() {
echo "Unregistering Oracle JDK 8 from archlinux-java..."
rm -rf "${_install_path}"
rm -rf "/etc/profile.d/java.sh"
}