summaryrefslogtreecommitdiff
path: root/autopkg-common.mk
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-08-24 18:34:01 +0200
committerKarel Kočí <cynerd@email.cz>2018-08-24 18:34:01 +0200
commit041418da93ee5c4711f5cff53d0c419ae4654765 (patch)
treecd83835d9b107a9739debcf85001f0a09e93f8ac /autopkg-common.mk
parent18c54a7a09959277b31c7671d87f94162da116af (diff)
downloadopenwrt-personal-pkgs-041418da93ee5c4711f5cff53d0c419ae4654765.tar.gz
openwrt-personal-pkgs-041418da93ee5c4711f5cff53d0c419ae4654765.tar.bz2
openwrt-personal-pkgs-041418da93ee5c4711f5cff53d0c419ae4654765.zip
Add autopkg machinery
Diffstat (limited to 'autopkg-common.mk')
-rw-r--r--autopkg-common.mk37
1 files changed, 37 insertions, 0 deletions
diff --git a/autopkg-common.mk b/autopkg-common.mk
new file mode 100644
index 0000000..73cff51
--- /dev/null
+++ b/autopkg-common.mk
@@ -0,0 +1,37 @@
+ifndef AUTOPKG_VARIANT
+ $(error "Don't include autopkg-common.mk directly!")
+endif
+
+ifndef PKG_NAME
+$(error You have to define PKG_NAME before pkgauto.mk include)
+endif
+ifndef PKG_SOURCE_URL
+$(error You have to define PKG_SOURCE_URL before pkgauto.mk include)
+endif
+
+TMP_REPO_PATH=$(DL_DIR)/autopkg/$(PKG_NAME)
+GIT_ARGS=--git-dir='$(TMP_REPO_PATH)' --bare
+
+# Clone/update git history to bare repository
+# TODO it is possible that this won't fetch when there is force push to repository
+$(shell \
+ if [ ! -d "$(TMP_REPO_PATH)" ]; then \
+ git clone --bare "$(PKG_SOURCE_URL)" "$(TMP_REPO_PATH)"; \
+ else \
+ git $(GIT_ARGS) fetch --prune --prune-tags --force "$(PKG_SOURCE_URL)"; \
+ fi)
+
+
+define AUTOPKG_TAIL
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
+HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)
+
+undefine TMP_REPO_PATH
+undefine GIT_ARGS
+undefine AUTOPKG_TAIL
+
+endef