Skip to content

Commit

Permalink
feat: add bugs variable (pacstall#1167)
Browse files Browse the repository at this point in the history
Co-authored-by: oklopfer <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 4, 2024
1 parent 47412dd commit 724b90d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 20 deletions.
58 changes: 40 additions & 18 deletions misc/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,36 @@ function is_builddep_arch() {
fi
}

# This function is used to undo a raw repo URL into its base components.
# It is sort of flawed because for self-hosted instances, it might not catch the name that it needs
# in order to parse, and if that eventually comes up, we'll deal with it then.
function parse_repo_unraw() {
{ ignore_stack=false; set -o pipefail; trap stacktrace ERR RETURN; }
local rep="${1}"
case "${rep}" in
*"githubusercontent"*)
pURL="${rep/'raw.githubusercontent.com'/'github.com'}"
pURL="${pURL%/*}"
export pURL pBRANCH="${rep##*/}" pISSUES="${pURL}/issues" branch="yes"
;;
*"gitlab"*)
pURL="${rep%/-/raw/*}"
export pURL pBRANCH="${rep##*/-/raw/}" pISSUES="${pURL}/-/issues" branch="yes"
;;
*"git.sr.ht"*)
pURL="${rep%/blob*}"
export pURL pBRANCH="${rep##*/}" pISSUES="https://lists.sr.ht/~${pURL#*~}" branch="yes"
;;
*"codeberg"*)
pURL="${rep%raw/branch/*}"
export pURL pBRANCH="${rep##*/}" pISSUES="${pURL}/issues" branch="yes"
;;
*)
export pURL="$rep" branch="no"
;;
esac
}

function makedeb() {
{ ignore_stack=false; set -o pipefail; trap stacktrace ERR RETURN; }
# It looks weird for it to say: `Packaging foo as foo`
Expand Down Expand Up @@ -418,6 +448,15 @@ function makedeb() {
deblog "Priority" "${priority:-optional}"
fi

if [[ -n ${bugs} ]]; then
deblog "Bugs" "${bugs}"
else
parse_repo_unraw "$REPO"
if [[ -n ${pISSUES} ]]; then
deblog "Bugs" "${pISSUES}"
fi
fi

if [[ $pacname == *-git ]]; then
parse_source_entry "${source[0]}"
# shellcheck disable=SC2031
Expand Down Expand Up @@ -871,24 +910,7 @@ function meta_log() {
{ ignore_stack=false; set -o pipefail; trap stacktrace ERR RETURN; }
# Origin repo info parsing
if [[ ${local} == "no" ]]; then
# shellcheck disable=SC2153
case $REPO in
*"github"*)
pURL="${REPO/'raw.githubusercontent.com'/'github.com'}"
pURL="${pURL%/*}"
pBRANCH="${REPO##*/}"
branch="yes"
;;
*"gitlab"*)
pURL="${REPO%/-/raw/*}"
pBRANCH="${REPO##*/-/raw/}"
branch="yes"
;;
*)
pURL="$REPO"
branch="no"
;;
esac
parse_repo_unraw "$REPO"
fi

# Metadata writing
Expand Down
14 changes: 13 additions & 1 deletion misc/scripts/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,18 @@ function lint_mask() {
{ ignore_stack=true; return "${ret}"; }
}

function lint_bugs() {
{ ignore_stack=false; set -o pipefail; trap stacktrace ERR RETURN; }
local ret=0
if [[ -n ${bugs} ]]; then
if [[ ${bugs} != *"://"* ]]; then
fancy_message error "'bugs' is improperly formatted"
ret=1
fi
fi
{ ignore_stack=true; return "${ret}"; }
}

function lint_priority() {
{ ignore_stack=false; set -o pipefail; trap stacktrace ERR RETURN; }
shopt -s extglob
Expand Down Expand Up @@ -700,7 +712,7 @@ function lint_license() {

function checks() {
{ ignore_stack=false; set -o pipefail; trap stacktrace ERR RETURN; }
local ret=0 check linting_checks=(lint_pacname lint_gives lint_pkgrel lint_epoch lint_version lint_source lint_pkgdesc lint_maintainer lint_deps lint_ppa lint_relations lint_fields lint_hash lint_incompatible lint_arch lint_mask lint_priority lint_license)
local ret=0 check linting_checks=(lint_pacname lint_gives lint_pkgrel lint_epoch lint_version lint_source lint_pkgdesc lint_maintainer lint_deps lint_ppa lint_relations lint_fields lint_hash lint_incompatible lint_arch lint_mask lint_priority lint_license lint_bugs)
for check in "${linting_checks[@]}"; do
"${check}" || ret=1
done
Expand Down
2 changes: 1 addition & 1 deletion pacstall
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function decl_scriptvars() {
pacstallvars=(pkgbase pkgname repology pkgver git_pkgver epoch source_url source depends makedepends checkdepends conflicts
breaks replaces gives pkgdesc hash optdepends ppa arch maintainer pacdeps NOBUILDDEP provides incompatible
compatible srcdir url backup pkgrel mask pac_functions repo priority noextract nosubmodules _archive license
bwrapenv safeenv external_connection enhances recommends custom_fields makeconflicts checkconflicts)
bwrapenv safeenv external_connection enhances recommends custom_fields makeconflicts checkconflicts bugs)
mapfile -t distros < <(awk -F ',' -v current_date="$(date +'%Y-%m-%d')" '
BEGIN {
is_first = 1
Expand Down

0 comments on commit 724b90d

Please sign in to comment.