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 <davide.madrisan@gmail.com>
This commit is contained in:
Davide Madrisan 2012-09-19 19:27:50 +02:00
parent 165e54e8d2
commit 0a648b670e
3 changed files with 45 additions and 12 deletions

View File

@ -17,6 +17,10 @@ Changes in version 1.12.4
* spec-create - Davide Madrisan: * spec-create - Davide Madrisan:
Document the creation of a specfile starting from a git repository. 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 Changes in version 1.12.3

View File

@ -847,6 +847,8 @@ curl $options --user \"***:***\" --quote \"DELE $deletefile\" $1"
# #
# args: # args:
# -d,--destdir : target directory # -d,--destdir : target directory
# --git-branch : git branch
# --preserve-dot-git : do not remove .git files
# $@ : git repository # $@ : git repository
# #
# return value: # return value:
@ -858,7 +860,7 @@ function git.create_tarball() {
local ARGS local ARGS
ARGS=`LC_ALL=C getopt \ ARGS=`LC_ALL=C getopt \
-o d:p:u: \ -o d:p:u: \
--long destdir:,proxy:,proxy-user: \ --long destdir:,git-branch:,preserve-dot-git:,proxy:,proxy-user: \
-n "$FUNCNAME" -- "$@"` -n "$FUNCNAME" -- "$@"`
[ $? = 0 ] || notify.error $"(bug)"" -- $FUNCNAME: "$"\`getopt' error" [ $? = 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 # 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 # see: http://bardofschool.blogspot.fr/2008/11/use-git-behind-proxy.html
local proxy proxy_user local proxy proxy_user
local git_branch
local preserve_dot_git=0
eval set -- "$ARGS" eval set -- "$ARGS"
while :; do while :; do
@ -875,6 +879,14 @@ function git.create_tarball() {
destdir="$2"; shift destdir="$2"; shift
notify.debug "$FUNCNAME: destdir = \"$destdir\"" 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) -p|--proxy)
proxy="$2"; shift proxy="$2"; shift
notify.debug "$FUNCNAME: proxy = \"$proxy\"" notify.debug "$FUNCNAME: proxy = \"$proxy\""
@ -910,8 +922,9 @@ function git.create_tarball() {
# create a tarball by cloning the git repository # create a tarball by cloning the git repository
notify.note \ notify.note \
"${NOTE}"$"cloning git repository"" <$git_repository>${NORM}""..." "${NOTE}"$"cloning git repository""\
git clone --quiet "$git_repository" <$git_repository> ${git_branch:+($git_branch)}${NORM}""..."
git clone ${git_branch:+-b $git_branch} --quiet "$git_repository"
[ $? -eq 0 ] || [ $? -eq 0 ] ||
{ popd &>/dev/null { popd &>/dev/null
rm -fr $tmpgitdir rm -fr $tmpgitdir
@ -919,9 +932,12 @@ function git.create_tarball() {
pck_tarball="$(find -mindepth 1 -maxdepth 1 -type d -printf "%f")" pck_tarball="$(find -mindepth 1 -maxdepth 1 -type d -printf "%f")"
if [ "$preserve_dot_git" = "0" ]; then
# remove git files # remove git files
rm -fr $pck_tarball/.git rm -fr $pck_tarball/.git
rm -f $pck_tarball/.gitignore rm -f $pck_tarball/.gitignore
rm -f $pck_tarball/.gitmodules
fi
pck_version="$(date "+%Y%m%dgit")" pck_version="$(date "+%Y%m%dgit")"
mv $pck_tarball ${pck_tarball}-${pck_version} mv $pck_tarball ${pck_tarball}-${pck_version}
@ -938,7 +954,8 @@ function git.create_tarball() {
an error occurred while creating"": ${pck_tarball}.tar.bz2"; } an error occurred while creating"": ${pck_tarball}.tar.bz2"; }
spec_source="${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}" pck_tarball="$destdir/${spec_source}"
popd &>/dev/null popd &>/dev/null

View File

@ -60,6 +60,8 @@ spec_cmd_makeinstall_default=""
[ "$perl_Makefile_generator" ] || perl_Makefile_generator="Makefile.PL" [ "$perl_Makefile_generator" ] || perl_Makefile_generator="Makefile.PL"
preserve_dot_git=0
# load the configuration file(s) # load the configuration file(s)
[ -r @libdir@/libcfg.lib ] || [ -r @libdir@/libcfg.lib ] ||
{ echo "$me: "$"library not found"": @libdir@/libcfg.lib" 1>&2 { echo "$me: "$"library not found"": @libdir@/libcfg.lib" 1>&2
@ -109,6 +111,8 @@ function usage() {
python : "$"specfile for python modules"" python : "$"specfile for python modules""
standard-daemon : "$"standard specfile for system/network services"" standard-daemon : "$"standard specfile for system/network services""
-o, --output "$"Redirect the output to the file <outfile>"" -o, --output "$"Redirect the output to the file <outfile>""
--git-branch "$"Specify a git branch""
--preserve-dot-git "$"Do not remove git files""
"$"Operation modes"": "$"Operation modes"":
-h, --help "$"Print this help, then exit"" -h, --help "$"Print this help, then exit""
@ -120,7 +124,8 @@ function usage() {
"$"Samples"": "$"Samples"":
@frontend@ -s ~/software/@package@-@version@.tar.bz2 -t standard -o @package@.spec @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 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 <davide.madrisan@gmail.com>." "$"Report bugs to <davide.madrisan@gmail.com>."
@ -152,7 +157,7 @@ config.check4user
exec_options=`LC_ALL=C getopt \ exec_options=`LC_ALL=C getopt \
-o s:n:v:t:o:DqrhV \ -o s:n:v:t:o:DqrhV \
--long \ --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,\ debug,quiet,colorize,help,version,\
frontend_opts: \ frontend_opts: \
-n "$me" -- "$@"` -n "$me" -- "$@"`
@ -176,6 +181,10 @@ while :; do
spec_type=$2; shift ;; spec_type=$2; shift ;;
-o|--output) -o|--output)
outfile=$2; shift ;; outfile=$2; shift ;;
--git-branch)
git_branch=$2; shift ;;
--preserve-dot-git)
preserve_dot_git=1 ;;
-D|--debug) -D|--debug)
let "verbose = 2" ;; let "verbose = 2" ;;
-q|--quiet) -q|--quiet)
@ -476,7 +485,10 @@ function specfile.create() {
case "$2" in case "$2" in
git://*|http://*.git|https://*.git) 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://*) http://*|https://*|ftp://*)
pck_tarball="${2##*/}" pck_tarball="${2##*/}"