-
Notifications
You must be signed in to change notification settings - Fork 0
/
makepkgs.sh
executable file
·85 lines (65 loc) · 2.71 KB
/
makepkgs.sh
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
78
79
80
81
82
83
84
85
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
cd "$DIR"
REPODIR="${DIR}/repo"
[ ! -d "${REPODIR}" ] && mkdir "${REPODIR}"
for PKGDIR in ${DIR}/pkg/*; do
if [ ! -f "${PKGDIR}/PKGBUILD" ]; then
continue
fi
PKGNAME=$(cat "${PKGDIR}/PKGBUILD" | grep "^pkgname=" | awk -F'=' '{print $2}')
PKGVER=$(cat "${PKGDIR}/PKGBUILD" | grep "^pkgver=" | awk -F'=' '{print $2}')
PKGREL=$(cat "${PKGDIR}/PKGBUILD" | grep "^pkgrel=" | awk -F'=' '{print $2}')
PKGARCHES=$(grep "^arch=" "${PKGDIR}/PKGBUILD" | sed -e 's/^arch=//g' -e 's/[\(\)]//g' -e 's/'\''//g')
PKGID="${PKGNAME}-${PKGVER}-${PKGREL}"
for PKGARCH in ${PKGARCHES}; do
PACKAGE_FILE_NAME="${PKGID}-${PKGARCH}.pkg.tar.zst"
if [ ! -f "${REPODIR}/${PACKAGE_FILE_NAME}" ]; then
echo "Making ${PKGID} for ${PKGARCH}..."
cd "${PKGDIR}"
CARCH="${PKGARCH}" makepkg -Csrf --noconfirm
[ -f "${REPODIR}/${PACKAGE_FILE_NAME}" ] && rm "${REPODIR}/${PACKAGE_FILE_NAME}"
cp "${PKGDIR}/${PACKAGE_FILE_NAME}" "${REPODIR}/${PACKAGE_FILE_NAME}"
fi
done
# Remove the builds for other versions
for REPO_PACKAGE in $(find "${REPODIR}" -name "${PKGNAME}-*" | grep -v "/${PKGID}"); do
echo "Removing ${REPO_PACKAGE}..."
rm "${REPO_PACKAGE}"
done
# Remove the builds for architectures that are not supported in the current version
for REPO_PACKAGE in $(find "${REPODIR}" -name "${PKGID}-*" | grep -v "\(${PKGARCHES// /\\\|}\).pkg.tar.zst"); do
echo "Removing ${REPO_PACKAGE}..."
rm "${REPO_PACKAGE}"
done
done
REPO_NAME="hmlendea"
for ARCH in "any" "aarch64" "i686" "x86_64"; do
REPODB_NAME="${REPO_NAME}-${ARCH}"
[ "${ARCH}" == "any" ] && REPODB_NAME="${REPO_NAME}"
REPODB_PATH="${REPODIR}/${REPODB_NAME}.db"
if [ -f "${REPODB_PATH}" ]; then
echo "Cleaning the current repository database"
rm "${REPODB_PATH}"
rm "${REPODB_PATH}.tar.gz"
rm "${REPODIR}/${REPODB_NAME}.files"
rm "${REPODIR}/${REPODB_NAME}.files.tar.gz"
fi
for PKGFILE in ${REPODIR}/*-${ARCH}.pkg.tar.zst; do
echo "Registering ${PKGFILE} into ${REPODB_NAME}"
repo-add "${REPODB_PATH}.tar.gz" "${PKGFILE}"
done
rm "${REPODB_PATH}"
cp "${REPODB_PATH}.tar.gz" "${REPODB_PATH}"
if [ -f "${REPODB_PATH}.tar.gz.old" ]; then
rm "${REPODB_PATH}.tar.gz.old"
rm "${REPODIR}/${REPODB_NAME}.files.tar.gz.old"
fi
done
echo "Recommended release tag: " $(date +%Y-%m-%d_%H-%M-%S)