summaryrefslogtreecommitdiff
path: root/autopkg-branch.mk
blob: 25e25e9cfa34c36304a7382d8bdde7b1de46849e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Autopkg tracking given branch
AUTOPKG_VARIANT:=branch
$(call include_mk, autopkg-common.mk)

ifndef PKG_SOURCE_BRANCH
$(error You have to define PKG_SOURCE_BRANCH before pkgauto.mk include)
endif

# Explicitly fetch branch
$(shell git $(GIT_ARGS) fetch --prune --prune-tags --force "$(PKG_SOURCE_URL)" "$(PKG_SOURCE_BRANCH):$(PKG_SOURCE_BRANCH)")

PKG_SOURCE_VERSION:=$(shell git $(GIT_ARGS) rev-parse "$(PKG_SOURCE_BRANCH)")
PKG_VERSION:=$(shell git $(GIT_ARGS) describe --abbrev=0 --tags "$(PKG_SOURCE_BRANCH)")

ifeq ($(PKG_VERSION),)
# Count commits since initial commit.
PKG_RELEASE:=$(shell git $(GIT_ARGS) rev-list --count "$(PKG_SOURCE_VERSION)")
# No previous version found (no tag) so we use 9999 instead
PKG_VERSION:=9999
else
# Count commits since last version tag
PKG_RELEASE:=$(shell git $(GIT_ARGS) rev-list --count "$(PKG_VERSION)..$(PKG_SOURCE_VERSION)")
# .9999 is appended to not collide with possible existing package versions in repository
PKG_VERSION:=$(PKG_VERSION:v%=%).9999
endif

$(eval $(call AUTOPKG_TAIL))