Created
February 22, 2012 07:53
-
-
Save wakaba/1883312 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 | |
SSH = ssh | |
REMOTEDEV_HOST = develop.test | |
REMOTEDEV_PERL_PATH = perl | |
SETUPENV_CURRENT_REVISION = 20120310 | |
SETUPENV_MIN_REVISION = $(SETUPENV_CURRENT_REVISION) | |
setupenv: setupenv-perl | |
setupenv-perl: config/perl/libs.txt | |
setupenv-update: | |
ifeq "$(sort $(SETUPENV_CURRENT_REVISION) $(SETUPENV_MIN_REVISION))" "$(SETUPENV_CURRENT_REVISION) $(SETUPENV_MIN_REVISION)" | |
#$(SETUPENV_CURRENT_REVISION) < $(SETUPENV_MIN_REVISION) | |
wget -O Makefile.setupenv https://raw.github.com/wakaba/perl-setupenv/master/Makefile.setupenv | |
endif | |
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) "mkdir -p $(shell cat local/remotedev/remote-directory-name.txt) && 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 | |
# | |
#test: local-submodules carton-install config/perl/libs.txt | |
# PATH=$(PERL_PATH):$(PATH) PERL5LIB=$(shell cat config/perl/libs.txt) \ | |
# $(PROVE) t/*.t | |
# | |
#Makefile-setupenv: Makefile.setupenv | |
# make --makefile Makefile.setupenv setupenv-update \ | |
# SETUPENV_MIN_REVISION=20120310 | |
# | |
#Makefile.setupenv: | |
# wget -O $@ https://raw.github.com/wakaba/perl-setupenv/master/Makefile.setupenv | |
# | |
#setupenv remotedev-test remotedev-reset remotedev-reset-setupenv \ | |
#config/perl/libs.txt \ | |
#carton-install carton-update local-submodules: %: Makefile-setupenv | |
# 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