From 4af301a7a2cfaf719d7eb03c5ff163cbeb38a71f Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sat, 14 Jan 2023 15:55:17 +0100 Subject: [PATCH] dev --- bin/pkgbuilder | 48 ++++++++++++++++++++++++++++++++-- models/custom/plugin | 6 ++++- models/custom/settings | 1 + models/github-branch/settings | 1 + models/github-release/settings | 1 + models/github-tag/settings | 1 + models/manual/settings | 1 + plugins/aur | 4 +++ plugins/github-branch | 4 +++ plugins/github-release | 4 +++ plugins/github-tag | 4 +++ plugins/manual | 4 +++ 12 files changed, 76 insertions(+), 3 deletions(-) diff --git a/bin/pkgbuilder b/bin/pkgbuilder index e146949..4648311 100755 --- a/bin/pkgbuilder +++ b/bin/pkgbuilder @@ -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 diff --git a/models/custom/plugin b/models/custom/plugin index 4a616f9..1742917 100644 --- a/models/custom/plugin +++ b/models/custom/plugin @@ -5,7 +5,11 @@ plugin_isupdatable() { } plugin_isbumpable() { - return 0 + return 1 +} + +plugin_ispushabletoaur() { + return 1 } plugin_getpkgfiles() { diff --git a/models/custom/settings b/models/custom/settings index 0c87793..9f8b74c 100644 --- a/models/custom/settings +++ b/models/custom/settings @@ -1,2 +1,3 @@ plugin=custom target=local-test +#aursshkey= diff --git a/models/github-branch/settings b/models/github-branch/settings index 4be2037..7a4dc3f 100644 --- a/models/github-branch/settings +++ b/models/github-branch/settings @@ -8,3 +8,4 @@ pkgrev=0 pkgver=0 version=0 pkgrel=1 +#aursshkey= diff --git a/models/github-release/settings b/models/github-release/settings index 87a404c..46dac83 100644 --- a/models/github-release/settings +++ b/models/github-release/settings @@ -2,3 +2,4 @@ plugin=github-release target=local-test githubuser= githubrepo= +#aursshkey= diff --git a/models/github-tag/settings b/models/github-tag/settings index 397b52f..7e7572a 100644 --- a/models/github-tag/settings +++ b/models/github-tag/settings @@ -2,3 +2,4 @@ plugin=github-tag target=local-test githubuser= githubrepo= +#aursshkey= diff --git a/models/manual/settings b/models/manual/settings index 3d12019..373c205 100644 --- a/models/manual/settings +++ b/models/manual/settings @@ -1,2 +1,3 @@ plugin=manual target=local-test +#aursshkey= diff --git a/plugins/aur b/plugins/aur index 8c739d0..b8e11e7 100644 --- a/plugins/aur +++ b/plugins/aur @@ -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 diff --git a/plugins/github-branch b/plugins/github-branch index d2a8865..4fd25cf 100644 --- a/plugins/github-branch +++ b/plugins/github-branch @@ -8,6 +8,10 @@ plugin_isbumpable() { return 0 } +plugin_ispushabletoaur() { + return 0 +} + plugin_getpkgfiles() { echo "${PKGDIR}/${PKGNAME}/files" } diff --git a/plugins/github-release b/plugins/github-release index 83aaec7..20d968f 100644 --- a/plugins/github-release +++ b/plugins/github-release @@ -8,6 +8,10 @@ plugin_isbumpable() { return 0 } +plugin_ispushabletoaur() { + return 0 +} + plugin_getpkgfiles() { echo "${PKGDIR}/${PKGNAME}/files" } diff --git a/plugins/github-tag b/plugins/github-tag index c92b053..5312fac 100644 --- a/plugins/github-tag +++ b/plugins/github-tag @@ -8,6 +8,10 @@ plugin_isbumpable() { return 0 } +plugin_ispushabletoaur() { + return 0 +} + plugin_getpkgfiles() { echo "${PKGDIR}/${PKGNAME}/files" } diff --git a/plugins/manual b/plugins/manual index 3081a29..6dae560 100644 --- a/plugins/manual +++ b/plugins/manual @@ -8,6 +8,10 @@ plugin_isbumpable() { return 0 } +plugin_ispushabletoaur() { + return 0 +} + plugin_getpkgfiles() { updatePkgSums "${PKGDIR}/${PKGNAME}/files" echo "${PKGDIR}/${PKGNAME}/files"