Add gitea-branch

This commit is contained in:
MatMoul 2024-03-16 21:03:29 +01:00
parent 8954617b90
commit 7a877ca4ae
3 changed files with 118 additions and 0 deletions

View File

@ -0,0 +1,30 @@
# Maintainer: user <user at the google email domain which is .com>
_giteaurl=
_giteauser=
_gitearepo=
_gitcommit=
pkgname=
pkgver=0
pkgrel=0
pkgdesc='Desc'
arch=('any')
url="${_giteaurl}/${_giteauser}/${_gitearepo}"
#license=('GPL3')
#depends=()
makedepends=('git')
#optdepends=()
#install="${pkgname}.install"
#provides=()
#backup=()
source=("git+${_giteaurl}/${_giteauser}/${_gitearepo}.git#commit=${_gitcommit}")
sha256sums=('SKIP')
build() {
cd "${_gitearepo}"
}
package() {
cd "${_gitearepo}"
}

View File

@ -0,0 +1,12 @@
plugin=gitea-branch
target=local-test
giteaurl=
giteauser=
gitearepo=
gitbranch=
gitcommit=
pkgrev=0
pkgver=0
version=0
pkgrel=1
#aursshkey=

76
plugins/gitea-branch Normal file
View File

@ -0,0 +1,76 @@
#!/bin/bash
plugin_isupdatable() {
return 0
}
plugin_isbumpable() {
return 0
}
plugin_ispushabletoaur() {
return 0
}
plugin_getpkgfiles() {
echo "${PKGDIR}/${PKGNAME}/files"
}
plugin_bump() {
local -r PKGREL=$(readSetting "${PKGBUILD}" "pkgrel" 0)
sed -i "s/pkgrel=.*/pkgrel=$((PKGREL+1))/" "${PKGBUILD}"
}
plugin_getlatestversion() {
local -r GITEABASEURL=$(readSetting "${PKGSETTINGS}" "giteaurl" "")
local -r GITEAUSER=$(readSetting "${PKGSETTINGS}" "giteauser" "")
local -r GITEAREPO=$(readSetting "${PKGSETTINGS}" "gitearepo" "")
local -r GITBRANCH=$(readSetting "${PKGSETTINGS}" "gitbranch" "")
local -r GITCOMMIT=$(readSetting "${PKGSETTINGS}" "gitcommit" "")
local -r GITEAURL="${GITEABASEURL}/${GITEAUSER}/${GITEAREPO}.git"
local -r ONLINECOMMIT=$(git ls-remote "${GITEAURL}" | grep "${GITBRANCH}$" | cut -f 1)
if [[ "${ONLINECOMMIT}" == "" ]]; then
echo "Error in Gitea API"
return 1
fi
if [[ "${GITCOMMIT}" == "${ONLINECOMMIT}" ]]; then
readSetting "${PKGSETTINGS}" "version" "0"
else
local -r PKGVERSION=$(readSetting "${PKGSETTINGS}" "pkgver" "0")
local -r PKGREVISION=$(readSetting "${PKGSETTINGS}" "pkgrev" "0")
local -r PKGNEWREVISION=$((PKGREVISION + 1))
echo "${PKGVERSION}.r${PKGNEWREVISION}.${ONLINECOMMIT:0:7}-1"
fi
}
plugin_update() {
local -r GITEABASEURL=$(readSetting "${PKGSETTINGS}" "giteaurl" "")
local -r GITEAUSER=$(readSetting "${PKGSETTINGS}" "giteauser" "")
local -r GITEAREPO=$(readSetting "${PKGSETTINGS}" "gitearepo" "")
local -r GITBRANCH=$(readSetting "${PKGSETTINGS}" "gitbranch" "")
local -r GITCOMMIT=$(readSetting "${PKGSETTINGS}" "gitcommit" "")
local -r GITEAURL="${GITEABASEURL}/${GITEAUSER}/${GITEAREPO}.git"
local -r ONLINECOMMIT=$(git ls-remote "${GITEAURL}" | grep "${GITBRANCH}$" | cut -f 1)
if [[ "${ONLINECOMMIT}" == "" ]]; then
echo "Error in Gitea API"
return 1
fi
if [[ "${GITCOMMIT}" == "${ONLINECOMMIT}" ]]; then
return 0
fi
writeSetting "${PKGSETTINGS}" "gitcommit" "${ONLINECOMMIT}"
local -r PKGREVISION=$(readSetting "${PKGSETTINGS}" "pkgrev" "0")
writeSetting "${PKGSETTINGS}" "pkgrev" "$((PKGREVISION + 1))"
writeSetting "${PKGSETTINGS}" "pkgrel" "1"
writeSetting "${PKGBUILD}" "_giteaurl" "${GITEABASEURL}"
writeSetting "${PKGBUILD}" "_giteauser" "${GITEAUSER}"
writeSetting "${PKGBUILD}" "_gitearepo" "${GITEAREPO}"
writeSetting "${PKGBUILD}" "_gitcommit" "${ONLINECOMMIT}"
writeSetting "${PKGBUILD}" "pkgname" "${PKGNAME}"
writeSetting "${PKGBUILD}" "pkgrel" "1"
local -r PKGVERSION=$(readSetting "${PKGSETTINGS}" "pkgver" "0")
local -r PKGNEWREVISION=$((PKGREVISION + 1))
writeSetting "${PKGBUILD}" "pkgver" "${PKGVERSION}.r${PKGNEWREVISION}.${ONLINECOMMIT:0:7}"
}