This commit is contained in:
MatMoul 2023-01-14 15:55:17 +01:00
parent 998913c5a2
commit 4af301a7a2
12 changed files with 76 additions and 3 deletions

View File

@ -14,6 +14,7 @@ showHelp() {
echo " checkupdateall Check all packages update"
echo " update pkgname Update package"
echo " updateall Update all packages"
echo " pushtoaur pkgname Push package to AUR"
echo ""
echo "args :"
echo " --cnf configfile"
@ -142,7 +143,7 @@ pkgBuild() { # $1=PKGNAME
# shellcheck disable=SC2034 # Variable for plugin
local -r PKGBUILD="${PKGDIR}/${PKGNAME}/files/PKGBUILD"
. "${PLUGINFILE}"
local PKGFILES=""
local -r PKGFILES="${PKGDIR}/${PKGNAME}/files"
if ! PKGFILES=$(plugin_getpkgfiles "${PKGDIR}" "${PKGNAME}"); then
if [[ "${DRYRUN}" == "0" ]]; then
writeSetting "${PKGDIR}"/"${PKGNAME}"/settings "lastbuildstatus" "Error - No PKG files provided"
@ -367,6 +368,48 @@ pkgUpdateAll() {
pkgUpdate "${PKGNAME}"
done
}
pkgPushToAUR() { # $1=PKGNAME
local -r PKGNAME=${1}
local PLUGINFILE=""
if ! PLUGINFILE=$(getPluginFile "${PKGDIR}" "${PKGNAME}" "${PLUGINDIR}"); then
return 1
fi
. "${PLUGINFILE}"
if ! plugin_ispushabletoaur; then
return 1
fi
local -r AURSSHKEY=$(readSetting "${PKGDIR}"/"${PKGNAME}"/settings "aursshkey" "")
if [ "${AURSSHKEY}" == "" ]; then
return 1
fi
local -r PKGVERSION=$(readSetting "${PKGDIR}"/"${PKGNAME}"/settings "version" "0")
local -r PKGFILES="${PKGDIR}/${PKGNAME}/files"
local TMPDIR=""
TMPDIR=$(mktemp -d)
cd "${TMPDIR}" || return 1
if ! git clone ssh://aur@aur.archlinux.org/"${PKGNAME}".git --config core.sshCommand="ssh -i ${AURSSHKEY}"; then
return 1
fi
cd "${PKGNAME}" || return 1
git rm -rf ".*"
git rm -rf "*"
cp -r "${PKGFILES}"/* .
chown -R pkgbuilder "${TMPDIR}"
# shellcheck disable=SC2024
sudo -u pkgbuilder makepkg --printsrcinfo > .SRCINFO
git add -A
git commit -a -m "Version ${PKGVERSION}"
#if ! git push --config core.sshCommand="ssh -i ${AURSSHKEY}"; then
# rm -rf "${TMPDIR}"
# return 1
#fi
#rm -rf "${TMPDIR}"
}
CNFFILE="/etc/pkgbuilder/config"
ARGCMD=""
@ -382,7 +425,7 @@ while [[ ${#} -gt 0 ]]; do
case ${1} in
--help) showHelp; exit 0;;
list | checkupdateall | updateall) ARGCMD="${1}"; shift;;
infos | build | bump | checkupdate | update) ARGCMD="${1}"; ARGPKG="${2}"; shift; shift;;
infos | build | bump | checkupdate | update | pushtoaur) ARGCMD="${1}"; ARGPKG="${2}"; shift; shift;;
create) ARGCMD="${1}"; ARGMDL="${2}"; ARGPKG="${3}"; shift; shift;;
--cnf) CNFFILE="${2}"; shift; shift;;
--notify) NOTIFY=1; shift;;
@ -410,5 +453,6 @@ case ${ARGCMD} in
checkupdateall) pkgCheckUpdateAll;;
update) pkgUpdate "${ARGPKG}";;
updateall) pkgUpdateall;;
pushtoaur) pkgPushToAUR "${ARGPKG}";;
*) showHelp; exit 1;;
esac

View File

@ -5,7 +5,11 @@ plugin_isupdatable() {
}
plugin_isbumpable() {
return 0
return 1
}
plugin_ispushabletoaur() {
return 1
}
plugin_getpkgfiles() {

View File

@ -1,2 +1,3 @@
plugin=custom
target=local-test
#aursshkey=

View File

@ -8,3 +8,4 @@ pkgrev=0
pkgver=0
version=0
pkgrel=1
#aursshkey=

View File

@ -2,3 +2,4 @@ plugin=github-release
target=local-test
githubuser=
githubrepo=
#aursshkey=

View File

@ -2,3 +2,4 @@ plugin=github-tag
target=local-test
githubuser=
githubrepo=
#aursshkey=

View File

@ -1,2 +1,3 @@
plugin=manual
target=local-test
#aursshkey=

View File

@ -8,6 +8,10 @@ plugin_isbumpable() {
return 1
}
plugin_ispushabletoaur() {
return 1
}
plugin_getpkgfiles() {
if [ -d "${PKGDIR}"/"${PKGNAME}"/files ]; then
if ! rm -r "${PKGDIR}"/"${PKGNAME}"/files; then

View File

@ -8,6 +8,10 @@ plugin_isbumpable() {
return 0
}
plugin_ispushabletoaur() {
return 0
}
plugin_getpkgfiles() {
echo "${PKGDIR}/${PKGNAME}/files"
}

View File

@ -8,6 +8,10 @@ plugin_isbumpable() {
return 0
}
plugin_ispushabletoaur() {
return 0
}
plugin_getpkgfiles() {
echo "${PKGDIR}/${PKGNAME}/files"
}

View File

@ -8,6 +8,10 @@ plugin_isbumpable() {
return 0
}
plugin_ispushabletoaur() {
return 0
}
plugin_getpkgfiles() {
echo "${PKGDIR}/${PKGNAME}/files"
}

View File

@ -8,6 +8,10 @@ plugin_isbumpable() {
return 0
}
plugin_ispushabletoaur() {
return 0
}
plugin_getpkgfiles() {
updatePkgSums "${PKGDIR}/${PKGNAME}/files"
echo "${PKGDIR}/${PKGNAME}/files"