From 0ad6dbf3a90c5631846e0e47a70d195a62b6ed89 Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sat, 14 Jan 2023 00:24:36 +0100 Subject: [PATCH] Second commit --- bin/pkgbuilder | 26 ++++++++++++++++++++++++++ plugins/github-branch | 7 ++----- plugins/github-release | 15 +++------------ plugins/github-tag | 15 +++------------ plugins/manual | 9 +-------- 5 files changed, 35 insertions(+), 37 deletions(-) diff --git a/bin/pkgbuilder b/bin/pkgbuilder index 35038cd..e90a3ce 100755 --- a/bin/pkgbuilder +++ b/bin/pkgbuilder @@ -64,6 +64,16 @@ getPluginFile() { # $1=PKGDIR $2=PKGNAME $3=PLUGINDIR echo "${PLUGINDIR}"/"${PLUGIN}" fi } +updatePkgSums() { # $1=FILES + local -r FILES=${1} + local TMPDIR="" + TMPDIR=$(mktemp -d) + cp -r "${FILES}/*" "${TMPDIR}" + chown -R pkgbuilder "${TMPDIR}" + sudo -u pkgbuilder updpkgsums "${TMPDIR}"/PKGBUILD + cp -r "${TMPDIR}"/PKGBUILD "${FILES}/" + rm -rf "${TMPDIR}" +} notify() { if [ ${NOTIFY} == 0 ]; then return 0 @@ -127,6 +137,10 @@ pkgBuild() { # $1=PKGNAME if ! PLUGINFILE=$(getPluginFile "${PKGDIR}" "${PKGNAME}" "${PLUGINDIR}"); then return 1 fi + # shellcheck disable=SC2034 # Variable for plugin + local -r PKGSETTINGS=${PKGDIR}/${PKGNAME}/settings + # shellcheck disable=SC2034 # Variable for plugin + local -r PKGBUILD="${PKGDIR}/${PKGNAME}/files/PKGBUILD" . "${PLUGINFILE}" local PKGFILES="" if ! PKGFILES=$(plugin_getpkgfiles "${PKGDIR}" "${PKGNAME}"); then @@ -243,6 +257,10 @@ pkgBump() { # $1=PKGNAME if ! PLUGINFILE=$(getPluginFile "${PKGDIR}" "${PKGNAME}" "${PLUGINDIR}"); then return 1 fi + # shellcheck disable=SC2034 # Variable for plugin + local -r PKGSETTINGS=${PKGDIR}/${PKGNAME}/settings + # shellcheck disable=SC2034 # Variable for plugin + local -r PKGBUILD="${PKGDIR}/${PKGNAME}/files/PKGBUILD" . "${PLUGINFILE}" if ! plugin_isbumpable; then return 1 @@ -262,6 +280,10 @@ pkgCheckUpdate() { # $1=PKGNAME if ! PLUGINFILE=$(getPluginFile "${PKGDIR}" "${PKGNAME}" "${PLUGINDIR}"); then return 1 fi + # shellcheck disable=SC2034 # Variable for plugin + local -r PKGSETTINGS=${PKGDIR}/${PKGNAME}/settings + # shellcheck disable=SC2034 # Variable for plugin + local -r PKGBUILD="${PKGDIR}/${PKGNAME}/files/PKGBUILD" . "${PLUGINFILE}" local -r PKGVERSION=$(readSetting "${PKGDIR}"/"${PKGNAME}"/settings "version" "0") local -r PKGPLUGIN=$(readSetting "${PKGDIR}"/"${PKGNAME}"/settings "plugin" "") @@ -310,6 +332,10 @@ pkgUpdate() { # $1=PKGNAME if ! PLUGINFILE=$(getPluginFile "${PKGDIR}" "${PKGNAME}" "${PLUGINDIR}"); then return 1 fi + # shellcheck disable=SC2034 # Variable for plugin + local -r PKGSETTINGS=${PKGDIR}/${PKGNAME}/settings + # shellcheck disable=SC2034 # Variable for plugin + local -r PKGBUILD="${PKGDIR}/${PKGNAME}/files/PKGBUILD" . "${PLUGINFILE}" if ! plugin_isupdatable; then return 1 diff --git a/plugins/github-branch b/plugins/github-branch index c4aaf8a..d2a8865 100644 --- a/plugins/github-branch +++ b/plugins/github-branch @@ -13,12 +13,11 @@ plugin_getpkgfiles() { } plugin_bump() { - local -r PKGREL=$(readSetting "${PKGDIR}"/"${PKGNAME}"/files/PKGBUILD "pkgrel" 0) - sed -i "s/pkgrel=.*/pkgrel=$((PKGREL+1))/" "${PKGDIR}"/"${PKGNAME}"/files/PKGBUILD + local -r PKGREL=$(readSetting "${PKGBUILD}" "pkgrel" 0) + sed -i "s/pkgrel=.*/pkgrel=$((PKGREL+1))/" "${PKGBUILD}" } plugin_getlatestversion() { - local -r PKGSETTINGS=${PKGDIR}/${PKGNAME}/settings local -r GITHUBUSER=$(readSetting "${PKGSETTINGS}" "githubuser" "") local -r GITHUBREPO=$(readSetting "${PKGSETTINGS}" "githubrepo" "") local -r GITBRANCH=$(readSetting "${PKGSETTINGS}" "gitbranch" "") @@ -40,7 +39,6 @@ plugin_getlatestversion() { } plugin_update() { - local -r PKGSETTINGS=${PKGDIR}/${PKGNAME}/settings local -r GITHUBUSER=$(readSetting "${PKGSETTINGS}" "githubuser" "") local -r GITHUBREPO=$(readSetting "${PKGSETTINGS}" "githubrepo" "") local -r GITBRANCH=$(readSetting "${PKGSETTINGS}" "gitbranch" "") @@ -60,7 +58,6 @@ plugin_update() { writeSetting "${PKGSETTINGS}" "pkgrev" "$((PKGREVISION + 1))" writeSetting "${PKGSETTINGS}" "pkgrel" "1" - local -r PKGBUILD="${PKGDIR}/${PKGNAME}/files/PKGBUILD" writeSetting "${PKGBUILD}" "_githubuser" "${GITHUBUSER}" writeSetting "${PKGBUILD}" "_githubrepo" "${GITHUBREPO}" writeSetting "${PKGBUILD}" "_gitcommit" "${ONLINECOMMIT}" diff --git a/plugins/github-release b/plugins/github-release index a750262..83aaec7 100644 --- a/plugins/github-release +++ b/plugins/github-release @@ -13,12 +13,11 @@ plugin_getpkgfiles() { } plugin_bump() { - local -r PKGREL=$(readSetting "${PKGDIR}"/"${PKGNAME}"/files/PKGBUILD "pkgrel" 0) - sed -i "s/pkgrel=.*/pkgrel=$((PKGREL+1))/" "${PKGDIR}"/"${PKGNAME}"/files/PKGBUILD + local -r PKGREL=$(readSetting "${PKGBUILD}" "pkgrel" 0) + sed -i "s/pkgrel=.*/pkgrel=$((PKGREL+1))/" "${PKGBUILD}" } plugin_getlatestversion() { - local -r PKGSETTINGS=${PKGDIR}/${PKGNAME}/settings local -r GITHUBUSER=$(readSetting "${PKGSETTINGS}" "githubuser" "") local -r GITHUBREPO=$(readSetting "${PKGSETTINGS}" "githubrepo" "") local GITHUBTAGNAME="" @@ -44,7 +43,6 @@ plugin_getlatestversion() { } plugin_update() { - local -r PKGSETTINGS=${PKGDIR}/${PKGNAME}/settings local -r GITHUBUSER=$(readSetting "${PKGSETTINGS}" "githubuser" "") local -r GITHUBREPO=$(readSetting "${PKGSETTINGS}" "githubrepo" "") local GITHUBTAGNAME="" @@ -68,7 +66,6 @@ plugin_update() { writeSetting "${PKGSETTINGS}" "pkgrel" "1" - local -r PKGBUILD="${PKGDIR}/${PKGNAME}/files/PKGBUILD" writeSetting "${PKGBUILD}" "_githubuser" "${GITHUBUSER}" writeSetting "${PKGBUILD}" "_githubrepo" "${GITHUBREPO}" writeSetting "${PKGBUILD}" "_pkgtagname" "${GITHUBTAGNAME}" @@ -76,11 +73,5 @@ plugin_update() { writeSetting "${PKGBUILD}" "pkgrel" "1" writeSetting "${PKGBUILD}" "pkgver" "${GITHUBVERSION}" - local TMPDIR="" - TMPDIR=$(mktemp -d) - cp -r "${PKGDIR}"/"${PKGNAME}"/files/* "${TMPDIR}" - chown -R pkgbuilder "${TMPDIR}" - sudo -u pkgbuilder updpkgsums "${TMPDIR}"/PKGBUILD - cp -r "${TMPDIR}"/PKGBUILD "${PKGDIR}/${PKGNAME}/files/" - rm -rf "${TMPDIR}" + updatePkgSums "${PKGDIR}"/"${PKGNAME}"/files } \ No newline at end of file diff --git a/plugins/github-tag b/plugins/github-tag index e713892..c92b053 100644 --- a/plugins/github-tag +++ b/plugins/github-tag @@ -13,12 +13,11 @@ plugin_getpkgfiles() { } plugin_bump() { - local -r PKGREL=$(readSetting "${PKGDIR}"/"${PKGNAME}"/files/PKGBUILD "pkgrel" 0) - sed -i "s/pkgrel=.*/pkgrel=$((PKGREL+1))/" "${PKGDIR}"/"${PKGNAME}"/files/PKGBUILD + local -r PKGREL=$(readSetting "${PKGBUILD}" "pkgrel" 0) + sed -i "s/pkgrel=.*/pkgrel=$((PKGREL+1))/" "${PKGBUILD}" } plugin_getlatestversion() { - local -r PKGSETTINGS=${PKGDIR}/${PKGNAME}/settings local -r GITHUBUSER=$(readSetting "${PKGSETTINGS}" "githubuser" "") local -r GITHUBREPO=$(readSetting "${PKGSETTINGS}" "githubrepo" "") local GITHUBTAGNAME="" @@ -44,7 +43,6 @@ plugin_getlatestversion() { } plugin_update() { - local -r PKGSETTINGS=${PKGDIR}/${PKGNAME}/settings local -r GITHUBUSER=$(readSetting "${PKGSETTINGS}" "githubuser" "") local -r GITHUBREPO=$(readSetting "${PKGSETTINGS}" "githubrepo" "") local GITHUBTAGNAME="" @@ -68,7 +66,6 @@ plugin_update() { writeSetting "${PKGSETTINGS}" "pkgrel" "1" - local -r PKGBUILD="${PKGDIR}/${PKGNAME}/files/PKGBUILD" writeSetting "${PKGBUILD}" "_githubuser" "${GITHUBUSER}" writeSetting "${PKGBUILD}" "_githubrepo" "${GITHUBREPO}" writeSetting "${PKGBUILD}" "_pkgtagname" "${GITHUBTAGNAME}" @@ -76,11 +73,5 @@ plugin_update() { writeSetting "${PKGBUILD}" "pkgrel" "1" writeSetting "${PKGBUILD}" "pkgver" "${GITHUBVERSION}" - local TMPDIR="" - TMPDIR=$(mktemp -d) - cp -r "${PKGDIR}"/"${PKGNAME}"/files/* "${TMPDIR}" - chown -R pkgbuilder "${TMPDIR}" - sudo -u pkgbuilder updpkgsums "${TMPDIR}"/PKGBUILD - cp -r "${TMPDIR}"/PKGBUILD "${PKGDIR}/${PKGNAME}/files/" - rm -rf "${TMPDIR}" + updatePkgSums "${PKGDIR}"/"${PKGNAME}"/files } \ No newline at end of file diff --git a/plugins/manual b/plugins/manual index dd78434..ae2b28a 100644 --- a/plugins/manual +++ b/plugins/manual @@ -9,14 +9,7 @@ plugin_isbumpable() { } plugin_getpkgfiles() { - local TMPDIR="" - TMPDIR=$(mktemp -d) - cp -r "${PKGDIR}"/"${PKGNAME}"/files/* "${TMPDIR}" - chown -R pkgbuilder "${TMPDIR}" - sudo -u pkgbuilder updpkgsums "${TMPDIR}"/PKGBUILD - cp -r "${TMPDIR}"/PKGBUILD "${PKGDIR}/${PKGNAME}/files/" - rm -rf "${TMPDIR}" - echo "${PKGDIR}/${PKGNAME}/files" + updatePkgSums "${PKGDIR}"/"${PKGNAME}"/files } plugin_bump() {