jw-pkg/make/git-submod.mk
Jan Lindemann ab872fe334 git-submod.mk: Add support for USE_USER_URL
Signed-off-by: Jan Lindemann <jan@janware.com>
2019-02-28 16:12:31 +00:00

33 lines
1.2 KiB
Makefile

# - Clone remote repo into <mydir>/<myrepo>
# - Add the following to <mydir>/Makefile:
# - SUBMOD_SRC_DIR = ./<myrepo>
# - include <path-to-this-makefile>
# - run git-init-submod-remote
ifeq ($(USE_USER_URL),)
JANWARE_USER_PREFIX = $(JANWARE_USER)@
endif
GIT_SRV_ADMIN_SH = ssh $(JANWARE_USER_PREFIX)git.janware.com /opt/jw-build/bin/git-srv-admin.sh
GIT_REPO_URL = ssh://$(JANWARE_USER_PREFIX)git.janware.com/srv/git/$(JANWARE_USER)/contrib/$(PROJECT_DIRNAME)
SUBMOD_PATH = $(patsubst $(abspath $(TOPDIR))/%,%,$(abspath $(shell $(CWD))/$(SUBMOD_SRC_DIR)))
SUBMOD_SRC_DIR ?= .
SUB_GIT = git -C $(SUBMOD_SRC_DIR)
all:
install:
clean:
distclean:
git-init-submod-remote:
$(GIT_SRV_ADMIN_SH) -F contrib create-repo $(PROJECT_DIRNAME)
$(SUB_GIT) remote rename origin upstream
$(SUB_GIT) remote set-url --push upstream no-push
$(SUB_GIT) remote add origin $(GIT_REPO_URL)
$(SUB_GIT) config branch.master.remote origin
$(SUB_GIT) config branch.master.merge refs/heads/master
$(SUB_GIT) push origin master
git -C $(TOPDIR) submodule add -f $(GIT_REPO_URL) $(SUBMOD_PATH)
git submodule init
git commit -m "Add git submodule $(SUBMOD_PATH)" $(SUBMOD_SRC_DIR) $(TOPDIR)/.gitmodules