Revision: 3584 http://gar.svn.sourceforge.net/gar/?rev=3584&view=rev Author: bdwalton Date: 2009-03-04 19:11:57 +0000 (Wed, 04 Mar 2009)
Log Message: ----------- Enable Git repo tracking with GAR. Modified Paths: -------------- csw/mgar/gar/v2/gar.conf.mk csw/mgar/gar/v2/gar.lib.mk csw/mgar/gar/v2/gar.mk Added Paths: ----------- csw/mgar/gar/v2/bin/gitproxy Added: csw/mgar/gar/v2/bin/gitproxy =================================================================== --- csw/mgar/gar/v2/bin/gitproxy (rev 0) +++ csw/mgar/gar/v2/bin/gitproxy 2009-03-04 19:11:57 UTC (rev 3584) @@ -0,0 +1,20 @@ +#!/bin/bash + +if [ -n "${http_proxy}" ]; then + + REMHOST=$1 + REMPORT=$2 + + set - $(echo "${http_proxy}" | sed 's/http//i' | tr -d '/' | tr ':' ' ') + PROXYHOST=$1 + PROXYPORT=$2 + + # this bit is copied from http://lkml.org/lkml/2006/2/26/207 and then + # modified to use netcat and handle proxy settings from the env. + (echo "CONNECT ${REMHOST}:${REMPORT} HTTP/1.0"; echo; cat ) | + nc ${PROXYHOST} ${PROXYPORT} | (read a; read a; cat ) + +else + echo Please set http_proxy in your environment. + exit 1 +fi Property changes on: csw/mgar/gar/v2/bin/gitproxy ___________________________________________________________________ Added: svn:executable + * Modified: csw/mgar/gar/v2/gar.conf.mk =================================================================== --- csw/mgar/gar/v2/gar.conf.mk 2009-03-04 18:46:34 UTC (rev 3583) +++ csw/mgar/gar/v2/gar.conf.mk 2009-03-04 19:11:57 UTC (rev 3584) @@ -31,6 +31,9 @@ MANIFEST_FILE ?= manifest LOGDIR ?= log +GIT_PROXY_SCRIPT ?= $(abspath $(GARBIN))/gitproxy +GIT_DEFAULT_TRACK = +refs/heads/master:refs/remotes/origin/master + # Outbound proxies http_proxy ?= ftp_proxy ?= @@ -131,8 +134,14 @@ # These are the core packages which must be installed for GAR to function correctly -PREREQUISITE_BASE_PKGS ?= CSWgmake CSWgtar CSWggrep CSWdiffutils CSWgfile CSWtextutils CSWwget CSWfindutils CSWgsed CSWgawk CSWbzip2 +DEF_BASE_PKGS = CSWgmake CSWgtar CSWggrep CSWdiffutils CSWgfile CSWtextutils CSWwget CSWfindutils CSWgsed CSWgawk CSWbzip2 +ifdef GIT_REPOS +# netcat and bash are for the gitproxy script. +DEF_BASE_PKGS += CSWgit CSWnetcat +endif +PREREQUISITE_BASE_PKGS ?= $(DEF_BASE_PKGS) + # Supported architectures returned from isalist(1) # Not all architectures are detected by all Solaris releases, especially # older releases lack precise detection. Modified: csw/mgar/gar/v2/gar.lib.mk =================================================================== --- csw/mgar/gar/v2/gar.lib.mk 2009-03-04 18:46:34 UTC (rev 3583) +++ csw/mgar/gar/v2/gar.lib.mk 2009-03-04 19:11:57 UTC (rev 3584) @@ -17,14 +17,26 @@ # convenience variable to make the cookie. MAKECOOKIE = mkdir -p $(COOKIEDIR)/$(@D) && date >> $(COOKIEDIR)/$@ +URLSTRIP = $(subst ://,//,$(1)) + +# if you need to proxy git:// connections, set GIT_USE_PROXY. There is a +# default proxy script that works with the (squid?) proxy at the BO buildfarm. +# override GIT_PROXY_SCRIPT to something else if you need to. +GIT_MAYBEPROXY = $(if $(GIT_USE_PROXY),GIT_PROXY_COMMAND=$(GIT_PROXY_SCRIPT)) +GIT_TREEISH = $(if $(GIT_TREEISH_$(1)),$(GIT_TREEISH_$(1)),HEAD) + #################### FETCH RULES #################### -URLS = $(subst ://,//,$(foreach SITE,$(FILE_SITES) $(MASTER_SITES),$(addprefix $(SITE),$(DISTFILES))) $(foreach SITE,$(FILE_SITES) $(PATCH_SITES) $(MASTER_SITES),$(addprefix $(SITE),$(PATCHFILES)))) +URLS = $(call URLSTRIP,$(foreach SITE,$(FILE_SITES) $(MASTER_SITES),$(addprefix $(SITE),$(DISTFILES))) $(foreach SITE,$(FILE_SITES) $(PATCH_SITES) $(MASTER_SITES),$(addprefix $(SITE),$(PATCHFILES)))) # if the caller has defined _postinstall, etc targets for a package, add # these 'dynamic script' targets to our fetch list URLS += $(foreach DYN,$(DYNSCRIPTS),dynscr//$(DYN)) +ifdef GIT_REPOS +URLS += $(foreach R,$(GIT_REPOS),gitrepo//$(call GITPROJ,$(R)) $(subst http,git-http,$(call URLSTRIP,$(R)))) +endif + # Download the file if and only if it doesn't have a preexisting # checksum file. Loop through available URLs and stop when you # get one that doesn't return an error code. @@ -43,6 +55,30 @@ fi; \ fi +gitrepo//%: + @( if [ -d $(GARCHIVEDIR)/$(call GITPROJ,$*) ]; then \ + ( cd $(GARCHIVEDIR)/$(call GITPROJ,$*); \ + $(GIT_MAYBEPROXY) git --bare fetch ) && \ + gln -s $(GARCHIVEDIR)/$(call GITPROJ,$*)/ $(PARTIALDIR)/$(call GITPROJ,$*); \ + else \ + false; \ + fi ) + +# the git remote add commands are so that we can later do a fetch +# to update the code. +# we possibly proxy the git:// references depending on GIT_USE_PROXY +git-http//%: + @$git clone --bare http://$* $(PARTIALDIR)/$(call GITPROJ,$*) + @( cd $(PARTIALDIR)/$(call GITPROJ,$*); \ + git remote add origin http://$*; \ + git config remote.origin.fetch $(if $(GIT_REFS_$(call GITPROJ,$*)),$(GIT_REFS_$(call GITPROJ,$*)),$(GIT_DEFAULT_TRACK)); ) + +git//%: + @$(GIT_MAYBEPROXY) git clone --bare git://$* $(PARTIALDIR)/$(call GITPROJ,$*) + @( cd $(PARTIALDIR)/$(call GITPROJ,$*); \ + git remote add origin git://$*; \ + git config remote.origin.fetch $(if $(GIT_REFS_$(call GITPROJ,$*)),$(GIT_REFS_$(call GITPROJ,$*)),$(GIT_DEFAULT_TRACK)); ) + # create ADMSCRIPTS 'on the fly' from variables defined by the caller # This version is private and should only be called from the non-private # version directly below @@ -118,7 +154,6 @@ echo '(!!!) $* not in $(CHECKSUM_FILE) file!' 1>&2; \ false; \ fi - #################### CHECKNEW RULES #################### @@ -277,6 +312,13 @@ @gzip -d $(WORKDIR)/$* @$(MAKECOOKIE) +# extra dependency rule for git repos, that will allow the user +# to supply an alternate target at their discretion +git-extract-%: + @echo " ===> Extracting Git Repo $(DOWNLOADDIR)/$* (Treeish: $(call GIT_TREEISH,$*))" + git --bare archive --prefix=$(GARNAME)-$(GARVERSION)/ --remote=file://$(abspath $(DOWNLOADDIR))/$*/ $(call GIT_TREEISH,$*) | gtar -xf - -C $(EXTRACTDIR) + @$(MAKECOOKIE) + # rule to extract files with unzip zip-extract-%: @echo " ==> Extracting $(DOWNLOADDIR)/$*" @@ -345,6 +387,9 @@ extract-archive-%.gz: gz-extract-%.gz @$(MAKECOOKIE) +extract-archive-%.git: git-extract-%.git + @$(MAKECOOKIE) + # anything we don't know about, we just assume is already # uncompressed and unarchived in plain format extract-archive-%: cp-extract-% Modified: csw/mgar/gar/v2/gar.mk =================================================================== --- csw/mgar/gar/v2/gar.mk 2009-03-04 18:46:34 UTC (rev 3583) +++ csw/mgar/gar/v2/gar.mk 2009-03-04 19:11:57 UTC (rev 3584) @@ -29,15 +29,18 @@ MAKEPATH = $(shell echo $(1) | perl -lne 'print join(":", split)') TOLOWER = $(shell echo $(1) | tr '[A-Z]' '[a-z]') +#meant to take a git url and return just the $proj.git part +GITPROJ = $(lastword $(subst /, ,$(1))) + PARALLELMFLAGS ?= $(MFLAGS) export PARALLELMFLAGS DISTNAME ?= $(GARNAME)-$(GARVERSION) DYNSCRIPTS = $(foreach PKG,$(SPKG_SPECS),$(foreach SCR,$(ADMSCRIPTS),$(if $(value $(PKG)_$(SCR)), $(PKG).$(SCR)))) -_NOCHECKSUM += $(DYNSCRIPTS) +_NOCHECKSUM += $(DYNSCRIPTS) $(foreach R,$(GIT_REPOS),$(call GITPROJ,$(R))) -ALLFILES ?= $(DISTFILES) $(PATCHFILES) $(DYNSCRIPTS) +ALLFILES ?= $(DISTFILES) $(PATCHFILES) $(DYNSCRIPTS) $(foreach R,$(GIT_REPOS),$(call GITPROJ,$(R))) ifeq ($(MAKE_INSTALL_DIRS),1) INSTALL_DIRS = $(addprefix $(DESTDIR),$(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir) $(datadir) $(sysconfdir) $(sharedstatedir) $(localstatedir) $(libdir) $(infodir) $(lispdir) $(includedir) $(mandir) $(foreach NUM,1 2 3 4 5 6 7 8, $(mandir)/man$(NUM)) $(sourcedir)) @@ -238,6 +241,8 @@ @$(foreach P,$(PATCHFILES),echo " $P";) @echo "Dynamically generated scripts: " @$(foreach D,$(DYNSCRIPTS),echo " $D";) + @echo "Git Repos tracked: " + @$(foreach R,$(GIT_REPOS),echo " $R";) # fetch - Retrieves $(DISTFILES) (and $(PATCHFILES) if defined) # into $(DOWNLOADDIR) as necessary. @@ -289,8 +294,8 @@ garchive: checksum $(GARCHIVE_TARGETS) ; # extract - Unpacks $(DISTFILES) into $(EXTRACTDIR) (patches are "zcatted" into the patch program) -EXTRACT_TARGETS-global ?= $(foreach SPEC,$(SPKG_SPECS),$(filter $(SPEC).%,$(DISTFILES) $(DYNSCRIPTS))) -EXTRACT_TARGETS = $(addprefix extract-archive-,$(filter-out $(NOEXTRACT),$(if $(EXTRACT_TARGETS-$(MODULATION)),$(EXTRACT_TARGETS-$(MODULATION)),$(DISTFILES) $(DYNSCRIPTS)))) +EXTRACT_TARGETS-global ?= $(foreach SPEC,$(SPKG_SPECS),$(filter $(SPEC).%,$(DISTFILES) $(DYNSCRIPTS) $(foreach R,$(GIT_REPOS),$(call GITPROJ,$(R))))) +EXTRACT_TARGETS = $(addprefix extract-archive-,$(filter-out $(NOEXTRACT),$(if $(EXTRACT_TARGETS-$(MODULATION)),$(EXTRACT_TARGETS-$(MODULATION)),$(DISTFILES) $(DYNSCRIPTS) $(foreach R,$(GIT_REPOS),$(call GITPROJ,$(R)))))) # We call an additional extract-modulated without resetting any variables so # a complete unpacked set goes to the global dir for packaging (like gspec) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ devel mailing list devel@lists.opencsw.org https://lists.opencsw.org/mailman/listinfo/devel