blob: 18475232c60348d3c8242f2dd838eac84bbf8d65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#!/bin/bash
set -euo pipefail
readonly REPO_URL="https://api.github.com/repos/Voxelum/x-minecraft-launcher/releases/latest"
readonly RELEASE_URL="https://github.com/Voxelum/x-minecraft-launcher/releases"
log() {
printf "\e[%sm%s\e[0m\n" "$1" "$2"
}
fetch_latest_version() {
curl --silent "$REPO_URL" | jq -r '.tag_name'
}
update_package_info() {
log "35" "Updating $1..."
local version="${2#v}"
# Create temporary file
local tmp_file=$(mktemp)
# Process PKGBUILD line by line
while IFS= read -r line; do
if [[ $line =~ ^pkgver= ]]; then
echo "pkgver=${version}"
else
echo "$line"
fi
done < "$1" > "$tmp_file"
# Replace original file with modified content
mv "$tmp_file" "$1"
}
create_srcinfo() {
[ -f "./.SRCINFO" ] && rm "./.SRCINFO"
log "35" "Updating .SRCINFO..."
local version="${1#v}"
cat > .SRCINFO << EOF
pkgbase = xmcl-launcher
pkgdesc = X Minecraft Launcher - A modern Minecraft launcher
pkgver = ${version}
pkgrel = 1
url = https://xmcl.app/
arch = x86_64
arch = aarch64
license = MIT
optdepends = jre8-openjdk: Minimum requirement for launching older game versions
optdepends = jre11-openjdk: Recommended Java version for launching versions 1.12-1.17
optdepends = jre17-openjdk: Recommended Java version for launching version 1.17 and above
optdepends = jre22-openjdk: Recommended Java version for launching version 1.20.5+ and above
provides = xmcl
conflicts = xmcl-launcher-bin
source = ${RELEASE_URL}/v${version}
pkgname = xmcl-launcher
EOF
}
main() {
latest_version=$(fetch_latest_version)
log "33" "Latest version: ${latest_version}"
update_package_info "PKGBUILD" "$latest_version"
create_srcinfo "$latest_version"
log "32" "Updated to version ${latest_version}"
read -p "Do you want to build the package? (y/N) " response
if [[ "$response" =~ ^[Yy]$ ]]; then
makepkg -s
fi
}
main
|