-
-
Save shibayu36/1957201 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- Makefile -*- | |
CARTON = local/carton/bin/carton | |
CARTON_LIB = local/carton/lib/perl5 | |
PERL = perl | |
CPANM = $(PERL) local/carton/cpanm | |
CPANM_ = $(CPANM) --notest --verbose -l local/carton --reinstall | |
CPANM_PATH = local/carton | |
PERL_PATH = local/dummy/path/to/perl | |
REMOTEDEV_HOST = develop.test | |
REMOTEDEV_PERL_PATH = perl | |
setupenv: setupenv-perl | |
setupenv-perl: config/perl/libs.txt | |
config/perl/libs.txt: local/carton/bin/carton local-submodules | |
mkdir -p config/perl | |
PERL5LIB=$(CARTON_LIB) PATH=$(PERL_PATH):$(CPANM_PATH):$(PATH) $(CARTON) exec -- \ | |
$(PERL) -e 'push @INC, glob "local/submodules/*/lib"; print join ":", grep /^local/, @INC' > $@ | |
local/carton/cpanm: | |
mkdir -p local/carton/ | |
wget -O $@ http://cpanmin.us | |
chmod u+x $@ | |
local/carton/bin/carton: local/carton/cpanm | |
$(CPANM_) JSON::XS | |
$(CPANM_) Carton | |
$(CPANM_) Getopt::Long | |
config/perl/modules.txt: | |
mkdir -p config/perl | |
echo Carp > $@ | |
config/perl/submodules.txt: | |
mkdir -p config/perl | |
touch $@ | |
config/perl/Makefile.submodules: config/perl/submodules.txt | |
echo "clone:" > $@ | |
cat $< | perl -n -e 'chomp; undef $$branch; $$branch = $$1 if s{\s+(\S+)\s*$$}{}; m{([^/\s]+)$$}; $$dir = $$1; print "\t(git clone $$_ || (cd $$dir && git pull))\n"; print "\tcd $$dir && (git checkout -b $$branch origin/$$branch || git checkout $$branch)\n" if $$branch' >> $@ | |
local-submodules: config/perl/Makefile.submodules | |
mkdir -p local/submodules | |
cd local/submodules && make --makefile=../../$< clone | |
carton-install: local-submodules carton.lock carton-install-main | |
carton.lock: local/carton/bin/carton config/perl/modules.txt \ | |
$(shell ls modules/*/config/perl/modules.txt local/submodules/*/config/perl/modules.txt) | |
-cat config/perl/modules.txt modules/*/config/perl/modules.txt local/submodules/*/config/perl/modules.txt | PERL5LIB=$(CARTON_LIB) PATH=$(PERL_PATH):$(CPANM_PATH):$(PATH) xargs $(CARTON) install | |
carton-update: | |
-cat config/perl/modules.txt modules/*/config/perl/modules.txt local/submodules/*/config/perl/modules.txt | PERL5LIB=$(CARTON_LIB) PATH=$(PERL_PATH):$(CPANM_PATH):$(PATH) xargs $(CARTON) install | |
carton-install-main: | |
PERL5LIB=$(CARTON_LIB) PATH=$(PERL_PATH):$(CPANM_PATH):$(PATH) $(CARTON) install --deployment | |
local/remotedev/remote-directory-name.txt: | |
mkdir -p local/remotedev | |
ssh $(REMOTEDEV_HOST) "perl -MFile::Temp=tempdir -e 'print tempdir'" > $@ | |
config/remotedev/getreponame.pl: | |
mkdir -p config/remotedev | |
echo 'my $$repo = `git config --get remote.origin.url` or die "No origin URL";' > $@ | |
echo 'print $$repo;' >> $@ | |
remotedev-upload: local/remotedev/remote-directory-name.txt config/remotedev/getreponame.pl | |
ssh $(REMOTEDEV_HOST) "cd $(shell cat local/remotedev/remote-directory-name.txt) && ((git clone $(shell $(PERL) config/remotedev/getreponame.pl) repo && cd repo && git checkout -b $(shell git name-rev --name-only HEAD) origin/$(shell git name-rev --name-only HEAD) && git submodule update --init) || (cd repo && (git checkout -b $(shell git name-rev --name-only HEAD) origin/$(shell git name-rev --name-only HEAD) || git checkout $(shell git name-rev --name-only HEAD)) && git pull && git submodule update --init))"; | |
remotedev-setup: remotedev-upload | |
ssh $(REMOTEDEV_HOST) "cd $(shell cat local/remotedev/remote-directory-name.txt)/repo && make Makefile.setupenv PERL_PATH=$(REMOTEDEV_PERL_PATH) && make --makefile Makefile.setupenv carton-install PERL_PATH=$(REMOTEDEV_PERL_PATH)"; | |
remotedev-reset: | |
rm local/remotedev/remote-directory-name.txt | |
remotedev-reset-setupenv: | |
ssh $(REMOTEDEV_HOST) "cd $(shell cat local/remotedev/remote-directory-name.txt)/repo && rm Makefile.setupenv" | |
remotedev-test: remotedev-setup | |
ssh $(REMOTEDEV_HOST) "cd $(shell cat local/remotedev/remote-directory-name.txt)/repo && make test PERL_PATH=$(REMOTEDEV_PERL_PATH)" | |
# Add following to your Makefile: | |
# | |
#REMOTEDEV_HOST = remotedev.host.example | |
#REMOTEDEV_PERL_PATH = path/to/remote/server/perl/bin | |
#PERL_PATH = local/dummy/path/to/perl/bin | |
# | |
#Makefile.setupenv: | |
# wget -O $@ https://raw.github.com/gist/1883312/Makefile.setupenv | |
# | |
#setupenv remotedev-test remotedev-reset remotedev-reset-setupenv \ | |
#config/perl/libs.txt \ | |
#carton-install carton-update local-submodules: %: Makefile.setupenv always | |
# make --makefile Makefile.setupenv $@ \ | |
# REMOTEDEV_HOST=$(REMOTEDEV_HOST) \ | |
# REMOTEDEV_PERL_PATH=$(REMOTEDEV_PERL_PATH) | |
# | |
#always: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment