Annotation of pkgsrc/mk/fetch/github.mk, revision 1.17
1.17 ! rillig 1: # $NetBSD: github.mk,v 1.16 2023/05/12 20:09:09 dholland Exp $
1.1 tnn 2: #
3: # github.com master site handling
4: #
5: # To use, set in Makefile:
6: #
7: # DISTNAME= exampleproject-1.2
1.5 tnn 8: # MASTER_SITES= ${MASTER_SITE_GITHUB:=accountname/}
1.1 tnn 9: #
1.5 tnn 10: # The following variables alter github.mk behavior:
1.1 tnn 11: #
1.5 tnn 12: # GITHUB_PROJECT defaults to PKGBASE
13: # GITHUB_TAG defaults to PKGVERSION_NOREV
14: # sometimes you want to override with v${PKGVERSION_NOREV}
15: # SHA-1 commit ids are also acceptable
16: # GITHUB_RELEASE defaults to not defined, set this to ${DISTNAME}
17: # when packaging a release not based on a git tag.
1.15 nia 18: # GITHUB_SUBMODULES manually set submodule information:
1.14 ryoon 19: # values should be:
20: # GitHub_user GitHub_project tag_or_hash submodule_path
1.5 tnn 21: # GITHUB_TYPE overrides the autodetected MASTER_SITE URL scheme:
1.1 tnn 22: #
23: # "tag"
1.5 tnn 24: # This is the default when GITHUB_RELEASE is not defined. Example URL:
25: # http://github.com/acct/${GITHUB_PROJECT}/archive/{GITHUB_TAG}.tar.gz
1.1 tnn 26: #
27: # "release"
1.5 tnn 28: # This is the default when GITHUB_RELEASE is set. Example URL:
29: # http://github.com/acct/${GITHUB_PROJECT}/releases/download/${GITHUB_RELEASE}/${DISTNAME}.tar.gz
1.2 tnn 30: #
31: # Keywords: github
1.1 tnn 32:
1.8 tnn 33: .if defined(MASTER_SITES) && !empty(MASTER_SITES:C,^https\://github.com/[-a-zA-Z0-9]*/$,match,:Mmatch)
1.5 tnn 34: _USE_GITHUB= YES
35: .endif
36:
37: .if (defined(GITHUB_TAG) || defined(GITHUB_RELEASE)) && !defined(_USE_GITHUB)
38: PKG_FAIL_REASON+= "MASTER_SITES must match https://github.com/account/" \
39: "when GITHUB_TAG or GITHUB_RELEASE is in use." \
40: "For more information: make help topic=github"
41: .endif
1.1 tnn 42:
1.5 tnn 43: .if defined(_USE_GITHUB) && !empty(_USE_GITHUB:M[yY][eE][sS])
1.1 tnn 44:
1.5 tnn 45: GITHUB_PROJECT?= ${PKGBASE}
46: GITHUB_TAG?= ${PKGVERSION_NOREV}
1.1 tnn 47:
1.16 dholland 48: . if !empty(GITHUB_TAG:Mmaster) || !empty(GITHUB_TAG:Mmain)
49: PKG_FAIL_REASON+= "main (or master) is not a valid tag name; use an explicit commit hash or a tag, not a branch"
1.1 tnn 50: . endif
51:
1.5 tnn 52: . if !defined(GITHUB_TYPE)
53: . if defined(GITHUB_RELEASE) && !empty(GITHUB_RELEASE)
54: GITHUB_TYPE= release
55: . else
56: GITHUB_TYPE= tag
1.1 tnn 57: . endif
58: . endif
59:
1.9 tnn 60: . if !empty(GITHUB_TYPE:Mtag) && !empty(GITHUB_TAG:M[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]*)
1.7 tnn 61: # If the github tag is a git hash (7 or more hex digits), encode it in the
62: # distfile name.
63: _GITHUB_DEFAULT_DISTFILES= ${DISTNAME}-${GITHUB_TAG}${EXTRACT_SUFX}
64: . else
65: _GITHUB_DEFAULT_DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
66: . endif
67:
1.5 tnn 68: . if !empty(GITHUB_TYPE:Mrelease)
1.7 tnn 69: SITES.${_GITHUB_DEFAULT_DISTFILES}= ${MASTER_SITES:=${GITHUB_PROJECT}/releases/download/${GITHUB_RELEASE}/}
1.5 tnn 70: . endif
1.1 tnn 71:
1.5 tnn 72: . if !empty(GITHUB_TYPE:Mtag)
1.7 tnn 73: SITES.${_GITHUB_DEFAULT_DISTFILES}= -${MASTER_SITES:=${GITHUB_PROJECT}/archive/${GITHUB_TAG}${EXTRACT_SUFX}}
1.5 tnn 74: . endif
1.1 tnn 75:
76: .endif
1.10 rillig 77:
1.17 ! rillig 78: .for user project tag place in ${GITHUB_SUBMODULES}
! 79: . for distfile in ${user}-${project}-${tag}${EXTRACT_SUFX}
! 80: _GITHUB_DEFAULT_DISTFILES+= ${distfile}
! 81: SITES.${distfile}= -${MASTER_SITE_GITHUB:=${user}/${project}/archive/${tag}${EXTRACT_SUFX}}
! 82: EXTRACT_DIR.${distfile}= ${WRKSRC}/${place}
! 83: EXTRACT_OPTS_TAR.${distfile}= --strip-components=1
1.14 ryoon 84: . endfor
1.17 ! rillig 85: .endfor
1.14 ryoon 86:
1.10 rillig 87: _VARGROUPS+= github
1.13 rillig 88: _PKG_VARS.github= GITHUB_PROJECT DISTNAME GITHUB_TYPE GITHUB_TAG \
1.14 ryoon 89: GITHUB_RELEASE MASTER_SITES EXTRACT_SUFX \
90: GITHUB_SUBMODULES
91: _DEF_VARS.github= _USE_GITHUB _GITHUB_DEFAULT_DISTFILES
92: .for f in ${_GITHUB_DEFAULT_DISTFILES}
93: _DEF_VARS.github+= SITES.${f}
94: .endfor
1.11 rillig 95: _USE_VARS.github= PKGBASE PKGVERSION_NOREV
1.12 rillig 96: _LISTED_VARS.github= SITES.*
CVSweb <webmaster@jp.NetBSD.org>