pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/fetch Add USE_GITLAB, based on github.mk, to make g...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/cb5d5ad01f54
branches:  trunk
changeset: 379823:cb5d5ad01f54
user:      nikita <nikita%pkgsrc.org@localhost>
date:      Mon May 23 21:45:45 2022 +0000

description:
Add USE_GITLAB, based on github.mk, to make gitlab MASTER_SITE
handling less repetitive.

 To use, set in Makefile:
 DISTNAME=     exampleproject-1.2
 MASTER_SITES= ${MASTER_SITE_GITLAB:=accountname/}

 The following variables alter gitlab.mk behavior:

 GITLAB_PROJECT        defaults to PKGBASE
 GITLAB_TAG            defaults to PKGVERSION_NOREV
                       sometimes you want to override with v${PKGVERSION_NOREV}
                       SHA-1 commit ids are also acceptable
 GITLAB_RELEASE        defaults to not defined, set this to ${DISTNAME}
                       when packaging a release not based on a git tag.
 GITLAB_SUBMODULES     manually set submodule information:
                       values should be:
                       GitLab_user GitLab_project tag_or_hash submodule_path
 GITLAB_TYPE           overrides the autodetected MASTER_SITE URL scheme:

diffstat:

 mk/fetch/bsd.fetch-vars.mk |  12 +++++-
 mk/fetch/bsd.fetch.mk      |   3 +-
 mk/fetch/gitlab.mk         |  99 ++++++++++++++++++++++++++++++++++++++++++++++
 mk/fetch/sites.mk          |   5 +-
 4 files changed, 116 insertions(+), 3 deletions(-)

diffs (170 lines):

diff -r 1784997c708e -r cb5d5ad01f54 mk/fetch/bsd.fetch-vars.mk
--- a/mk/fetch/bsd.fetch-vars.mk        Mon May 23 21:08:53 2022 +0000
+++ b/mk/fetch/bsd.fetch-vars.mk        Mon May 23 21:45:45 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.fetch-vars.mk,v 1.25 2021/03/30 16:47:03 ryoon Exp $
+# $NetBSD: bsd.fetch-vars.mk,v 1.26 2022/05/23 21:45:45 nikita Exp $
 #
 # This Makefile fragment is included separately by bsd.pkg.mk and
 # defines some variables which must be defined earlier than where
@@ -54,6 +54,11 @@
 # distfile name. It would be better to use ${_GITHUB_DEFAULT_DISTFILES} here,
 # but that gets assigned much later.
 DEFAULT_DISTFILES=     ${DISTNAME}-${GITHUB_TAG}${EXTRACT_SUFX}
+.  elif defined(GITLAB_TAG) && !empty(GITLAB_TAG:M[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]*)
+# If the gitlab tag is a git hash (7 or more hex digits), encode it in the
+# distfile name. It would be better to use ${_GITLAB_DEFAULT_DISTFILES} here,
+# but that gets assigned much later.
+DEFAULT_DISTFILES=     ${DISTNAME}-${GITLAB_TAG}${EXTRACT_SUFX}
 .  else
 DEFAULT_DISTFILES=     ${DISTNAME}${EXTRACT_SUFX}
 .  endif
@@ -66,6 +71,11 @@
 .  endfor
 .endif
 
+.if !empty(GITLAB_SUBMODULES)
+.  for _GITLAB_SM_USER _GITLAB_SM_PROJECT _GITLAB_SM_TAG _GITLAB_SM_PLACE in ${GITLAB_SUBMODULES}
+DISTFILES+=                    ${_GITLAB_SM_USER}-${_GITLAB_SM_PROJECT}-${_GITLAB_SM_TAG}${EXTRACT_SUFX}
+.  endfor
+.endif
 
 # File lists, defined early to allow tool dependencies.
 ALLFILES?=     ${DISTFILES} ${PATCHFILES}
diff -r 1784997c708e -r cb5d5ad01f54 mk/fetch/bsd.fetch.mk
--- a/mk/fetch/bsd.fetch.mk     Mon May 23 21:08:53 2022 +0000
+++ b/mk/fetch/bsd.fetch.mk     Mon May 23 21:45:45 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.fetch.mk,v 1.10 2015/07/06 05:03:33 rodent Exp $
+# $NetBSD: bsd.fetch.mk,v 1.11 2022/05/23 21:45:45 nikita Exp $
 #
 # This Makefile fragment is included by bsd.pkg.mk and defines the
 # relevant variables and targets for the "fetch" step.
@@ -39,4 +39,5 @@
 .include "fetch-list.mk"
 .include "distclean.mk"
 .include "github.mk"
+.include "gitlab.mk"
 .include "pypi.mk"
diff -r 1784997c708e -r cb5d5ad01f54 mk/fetch/gitlab.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/fetch/gitlab.mk        Mon May 23 21:45:45 2022 +0000
@@ -0,0 +1,99 @@
+# $NetBSD: gitlab.mk,v 1.1 2022/05/23 21:45:45 nikita Exp $
+#
+# gitlab.com master site handling
+#
+# To use, set in Makefile:
+#
+# DISTNAME=    exampleproject-1.2
+# MASTER_SITES=        ${MASTER_SITE_GITLAB:=accountname/}
+#
+# The following variables alter gitlab.mk behavior:
+#
+# GITLAB_PROJECT       defaults to PKGBASE
+# GITLAB_TAG           defaults to PKGVERSION_NOREV
+#                      sometimes you want to override with v${PKGVERSION_NOREV}
+#                      SHA-1 commit ids are also acceptable
+# GITLAB_RELEASE       defaults to not defined, set this to ${DISTNAME}
+#                      when packaging a release not based on a git tag.
+# GITLAB_SUBMODULES    manually set submodule information:
+#                      values should be:
+#                      GitLab_user GitLab_project tag_or_hash submodule_path
+# GITLAB_TYPE          overrides the autodetected MASTER_SITE URL scheme:
+#
+# "tag"
+# This is the default when GITLAB_RELEASE is not defined. Example URL:
+# https://gitlab.com/acct/${GITLAB_PROJECT}/-/archive/${GITLAB_TAG}/${GITLAB_PROJECT}-${GITLAB_TAG}.tar.gz
+#
+# "release"
+# This is the default when GITLAB_RELEASE is set. Example URL:
+# https://gitlab.com/acct/${GITLAB_PROJECT}/-/archive/${GITLAB_RELEASE}/${DISTNAME}.tar.gz
+#
+# Keywords: gitlab
+
+.if defined(MASTER_SITES) && !empty(MASTER_SITES:C,^https\://gitlab.com/[-a-zA-Z0-9]*/$,match,:Mmatch)
+_USE_GITLAB=           YES
+.elif defined(MASTER_SITES) && !empty(MASTER_SITES:C,^https\://gitlab.com/[-a-zA-Z0-9]*/[-a-zA-Z0-9]*/$,match,:Mmatch)
+_USE_GITLAB=           YES
+.endif
+
+.if (defined(GITLAB_TAG) || defined(GITLAB_RELEASE)) && !defined(_USE_GITLAB)
+PKG_FAIL_REASON+=      "MASTER_SITES must match https://gitlab.com/account/";   \
+                       "when GITLAB_TAG or GITLAB_RELEASE is in use."          \
+                       "For more information: make help topic=gitlab"
+.endif
+
+.if defined(_USE_GITLAB) && !empty(_USE_GITLAB:M[yY][eE][sS])
+
+GITLAB_PROJECT?=       ${PKGBASE}
+GITLAB_TAG?=           ${PKGVERSION_NOREV}
+
+.  if !empty(GITLAB_TAG:Mmaster)
+PKG_FAIL_REASON+=      "master is not a valid tag name, use an explicit commit hash"
+.  endif
+
+.  if !defined(GITLAB_TYPE)
+.    if defined(GITLAB_RELEASE) && !empty(GITLAB_RELEASE)
+GITLAB_TYPE=   release
+.    else
+GITLAB_TYPE=   tag
+.    endif
+.  endif
+
+.  if !empty(GITLAB_TYPE:Mtag) && !empty(GITLAB_TAG:M[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]*)
+# If the gitlab tag is a git hash (7 or more hex digits), encode it in the
+# distfile name.
+_GITLAB_DEFAULT_DISTFILES=     ${DISTNAME}-${GITLAB_TAG}${EXTRACT_SUFX}
+.  else
+_GITLAB_DEFAULT_DISTFILES=     ${DISTNAME}${EXTRACT_SUFX}
+.  endif
+
+.  if !empty(GITLAB_TYPE:Mrelease)
+SITES.${_GITLAB_DEFAULT_DISTFILES}=    ${MASTER_SITES:=${GITLAB_PROJECT}/-/archive/${GITLAB_RELEASE}/}
+.  endif
+
+.  if !empty(GITLAB_TYPE:Mtag)
+SITES.${_GITLAB_DEFAULT_DISTFILES}=    -${MASTER_SITES:=${GITLAB_PROJECT}/-/archive/${GITLAB_TAG}/${GITLAB_PROJECT}-${GITLAB_TAG}${EXTRACT_SUFX}}
+.  endif
+
+.endif
+
+.if !empty(GITLAB_SUBMODULES)
+.  for _GITLAB_SM_USER _GITLAB_SM_PROJECT _GITLAB_SM_TAG _GITLAB_SM_PLACE in ${GITLAB_SUBMODULES}
+_GITLAB_SM_DISTFILE=                   ${_GITLAB_SM_USER}-${_GITLAB_SM_PROJECT}-${_GITLAB_SM_TAG}${EXTRACT_SUFX}
+_GITLAB_DEFAULT_DISTFILES+=            ${_GITLAB_SM_USER}-${_GITLAB_SM_PROJECT}-${_GITLAB_SM_TAG}${EXTRACT_SUFX}
+SITES.${_GITLAB_SM_DISTFILE}=          -${MASTER_SITE_GITLAB:=${_GITLAB_SM_USER}/${_GITLAB_SM_PROJECT}/-/archive/${_GITLAB_SM_TAG}/${_GITLAB_SM_PROJECT}-${_GITLAB_SM_TAG}${EXTRACT_SUFX}}
+EXTRACT_DIR.${_GITLAB_SM_DISTFILE}=    ${WRKSRC}/${_GITLAB_SM_PLACE}
+EXTRACT_OPTS_TAR.${_GITLAB_SM_DISTFILE}=       --strip-components=1
+.  endfor
+.endif
+
+_VARGROUPS+=           gitlab
+_PKG_VARS.gitlab=      GITLAB_PROJECT DISTNAME GITLAB_TYPE GITLAB_TAG \
+                       GITLAB_RELEASE MASTER_SITES EXTRACT_SUFX \
+                       GITLAB_SUBMODULES
+_DEF_VARS.gitlab=      _USE_GITLAB _GITLAB_DEFAULT_DISTFILES
+.for f in ${_GITLAB_DEFAULT_DISTFILES}
+_DEF_VARS.gitlab+=     SITES.${f}
+.endfor
+_USE_VARS.gitlab=      PKGBASE PKGVERSION_NOREV
+_LISTED_VARS.gitlab=   SITES.*
diff -r 1784997c708e -r cb5d5ad01f54 mk/fetch/sites.mk
--- a/mk/fetch/sites.mk Mon May 23 21:08:53 2022 +0000
+++ b/mk/fetch/sites.mk Mon May 23 21:45:45 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: sites.mk,v 1.178 2022/05/21 00:44:58 gutteridge Exp $
+# $NetBSD: sites.mk,v 1.179 2022/05/23 21:45:45 nikita Exp $
 #
 # This Makefile fragment defines read-only MASTER_SITE_* variables
 # representing some well-known master distribution sites for software.
@@ -21,6 +21,9 @@
 MASTER_SITE_GITHUB+=    \
        https://github.com/
 
+MASTER_SITE_GITLAB+=   \
+       https://gitlab.com/
+
 MASTER_SITE_GNUSTEP+=   \
        ftp://ftp.gnustep.org/pub/gnustep/
 



Home | Main Index | Thread Index | Old Index