From 0a648b670e69fad837f80cf38a29e9d492d332e5 Mon Sep 17 00:00:00 2001 From: Davide Madrisan Date: Wed, 19 Sep 2012 19:27:50 +0200 Subject: [PATCH] spec-create, lib/libnetwork.lib: add aupport for git branches in spec-create by adding the new options --git-branch and --preserve-dot-git Signed-off-by: Davide Madrisan --- ChangeLog | 4 ++++ lib/libnetwork.lib.in | 35 ++++++++++++++++++++++++++--------- plugins/spec-create.in | 18 +++++++++++++++--- 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 770a282..aa0cd9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,10 @@ Changes in version 1.12.4 * spec-create - Davide Madrisan: Document the creation of a specfile starting from a git repository. + * spec-create, lib/libnetwork.lib - Madrisan: + Add aupport for git branches in spec-create by adding the new options + '--git-branch' and '--preserve-dot-git'. + ------------------------------------------------------------------------------- Changes in version 1.12.3 diff --git a/lib/libnetwork.lib.in b/lib/libnetwork.lib.in index 269a902..096c838 100644 --- a/lib/libnetwork.lib.in +++ b/lib/libnetwork.lib.in @@ -846,8 +846,10 @@ curl $options --user \"***:***\" --quote \"DELE $deletefile\" $1" # clone a git repository and convert is into a tarball file # # args: -# -d,--destdir : target directory -# $@ : git repository +# -d,--destdir : target directory +# --git-branch : git branch +# --preserve-dot-git : do not remove .git files +# $@ : git repository # # return value: # 0 @@ -858,7 +860,7 @@ function git.create_tarball() { local ARGS ARGS=`LC_ALL=C getopt \ -o d:p:u: \ - --long destdir:,proxy:,proxy-user: \ + --long destdir:,git-branch:,preserve-dot-git:,proxy:,proxy-user: \ -n "$FUNCNAME" -- "$@"` [ $? = 0 ] || notify.error $"(bug)"" -- $FUNCNAME: "$"\`getopt' error" @@ -867,6 +869,8 @@ function git.create_tarball() { # HINT: git config --global http.proxy http://user:pwd@proxy.srv.com:port # see: http://bardofschool.blogspot.fr/2008/11/use-git-behind-proxy.html local proxy proxy_user + local git_branch + local preserve_dot_git=0 eval set -- "$ARGS" while :; do @@ -875,6 +879,14 @@ function git.create_tarball() { destdir="$2"; shift notify.debug "$FUNCNAME: destdir = \"$destdir\"" ;; + --git-branch) + git_branch="$2"; shift + notify.debug "$FUNCNAME: git_branch = \"$git_branch\"" + ;; + --preserve-dot-git) + preserve_dot_git="$2"; shift + notify.debug "$FUNCNAME: preserve_dot_git = \"$preserve_dot_git\"" + ;; -p|--proxy) proxy="$2"; shift notify.debug "$FUNCNAME: proxy = \"$proxy\"" @@ -910,8 +922,9 @@ function git.create_tarball() { # create a tarball by cloning the git repository notify.note \ - "${NOTE}"$"cloning git repository"" <$git_repository>${NORM}""..." - git clone --quiet "$git_repository" + "${NOTE}"$"cloning git repository""\ + <$git_repository> ${git_branch:+($git_branch)}${NORM}""..." + git clone ${git_branch:+-b $git_branch} --quiet "$git_repository" [ $? -eq 0 ] || { popd &>/dev/null rm -fr $tmpgitdir @@ -919,9 +932,12 @@ function git.create_tarball() { pck_tarball="$(find -mindepth 1 -maxdepth 1 -type d -printf "%f")" - # remove git files - rm -fr $pck_tarball/.git - rm -f $pck_tarball/.gitignore + if [ "$preserve_dot_git" = "0" ]; then + # remove git files + rm -fr $pck_tarball/.git + rm -f $pck_tarball/.gitignore + rm -f $pck_tarball/.gitmodules + fi pck_version="$(date "+%Y%m%dgit")" mv $pck_tarball ${pck_tarball}-${pck_version} @@ -938,7 +954,8 @@ function git.create_tarball() { an error occurred while creating"": ${pck_tarball}.tar.bz2"; } spec_source="${pck_tarball}.tar.bz2" - spec_source_comment="## GITSOURCE $git_repository" + spec_source_comment="\ +## GITSOURCE $git_repository${git_branch:+ it_branch}" pck_tarball="$destdir/${spec_source}" popd &>/dev/null diff --git a/plugins/spec-create.in b/plugins/spec-create.in index c9de89a..78003ba 100644 --- a/plugins/spec-create.in +++ b/plugins/spec-create.in @@ -60,6 +60,8 @@ spec_cmd_makeinstall_default="" [ "$perl_Makefile_generator" ] || perl_Makefile_generator="Makefile.PL" +preserve_dot_git=0 + # load the configuration file(s) [ -r @libdir@/libcfg.lib ] || { echo "$me: "$"library not found"": @libdir@/libcfg.lib" 1>&2 @@ -109,6 +111,8 @@ function usage() { python : "$"specfile for python modules"" standard-daemon : "$"standard specfile for system/network services"" -o, --output "$"Redirect the output to the file "" + --git-branch "$"Specify a git branch"" + --preserve-dot-git "$"Do not remove git files"" "$"Operation modes"": -h, --help "$"Print this help, then exit"" @@ -120,7 +124,8 @@ function usage() { "$"Samples"": @frontend@ -s ~/software/@package@-@version@.tar.bz2 -t standard -o @package@.spec @frontend@ -s http://ftp.qilinux.it/devel/tools/@package@/@package@-@version@.tar.bz2 - @frontend@ -s git://anongit.freedesktop.org/gstreamer/gst-omx -o gst-omx.spec -n gst-omx + @frontend@ -s git://anongit.freedesktop.org/gstreamer/gst-omx \\ + --git-branch=\"raspberry\" --preserve-dot-git -o gst-omx.spec "$"Report bugs to ." @@ -152,7 +157,7 @@ config.check4user exec_options=`LC_ALL=C getopt \ -o s:n:v:t:o:DqrhV \ --long \ -source:,pck-name:,pck-version:,type:,output:,\ +source:,pck-name:,pck-version:,type:,output:,git-branch:,preserve-dot-git,\ debug,quiet,colorize,help,version,\ frontend_opts: \ -n "$me" -- "$@"` @@ -176,6 +181,10 @@ while :; do spec_type=$2; shift ;; -o|--output) outfile=$2; shift ;; + --git-branch) + git_branch=$2; shift ;; + --preserve-dot-git) + preserve_dot_git=1 ;; -D|--debug) let "verbose = 2" ;; -q|--quiet) @@ -476,7 +485,10 @@ function specfile.create() { case "$2" in git://*|http://*.git|https://*.git) - git.create_tarball --destdir="$source_dir" "$2" + git.create_tarball \ + --git-branch="$git_branch" \ + --preserve-dot-git="$preserve_dot_git" \ + --destdir="$source_dir" "$2" ;; http://*|https://*|ftp://*) pck_tarball="${2##*/}"