first commit

This commit is contained in:
zj
2025-12-14 16:36:55 +08:00
commit c34438e880
3 changed files with 85 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/*.pkg.tar.zst
/src/
/pkg/

82
PKGBUILD Normal file
View File

@@ -0,0 +1,82 @@
# Maintainer: Your Name <your.email@example.com>
pkgname=oracle-jdk8
pkgver=8.471 # 对应 8u471
pkgrel=1
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 版本
# 构建依赖tar 和 gzip 通常是 makepkg 默认自带的
makedepends=('tar' 'gzip')
# 源文件:
# 1. jdk-8u471-linux-x64.tar.gz - 需要用户手动下载并放置在PKGBUILD同目录
# 2. java.sh - 用于设置环境变量的脚本,将在 prepare() 中生成
source=("jdk-${pkgver/./u}-linux-x64.tar.gz")
# 校验和 (请在运行 makepkg -g 后替换 'SKIP')
# 由于用户需要手动下载,这里暂时使用 'SKIP',请务必替换为实际的校验和!
sha256sums=('5cddefbe9e10551d7149153a416111d1cbd177afaa7873f61b3168de104f13d8') # java.sh 的校验和
# 定义 JDK 的安装目录和内部名称
_jdk_dir_name="jdk1.8.0_471" # 压缩包解压后的目录名
_install_path="/usr/local/oracle-jdk-8" # Arch Linux 推荐的 Java 安装路径
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}/"
# 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..."
# 从 archlinux-java 中注销此 JDK 版本
rm -rf "${_install_path}"
rm -rf "/etc/profile.d/java.sh"
}

BIN
jdk-8u471-linux-x64.tar.gz Normal file

Binary file not shown.