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:
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

View File

@ -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

View File

@ -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 <outfile>""
--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 <davide.madrisan@gmail.com>."
@ -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##*/}"