libnetwork.lib: move code from spec-create to the new function git.create_tarball()
Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
parent
59ef053eca
commit
0594180470
@ -32,6 +32,10 @@ Wed Apr 18 2012 Davide Madrisan <davide.madrisan(a)gmail.com>
|
||||
* autospec.spec - Silvan Calarco:
|
||||
Do not require '/usr/bin/host' in early stage platform development.
|
||||
|
||||
* spec-create, lib/libnetwork.lib - Davide Madrisan:
|
||||
Move code from spec-create to the new function 'git.create_tarball()' in
|
||||
libnetwork.lib.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes in version 1.9.4
|
||||
|
@ -792,3 +792,105 @@ curl $options --user \"***:***\" --quote \"DELE $deletefile\" $1"
|
||||
|
||||
[[ "$retval" != "0" && "$exitonerror" = 1 ]] && exit 1
|
||||
}
|
||||
|
||||
# function git.create_tarball
|
||||
# clone a git repository and convert is into a tarball file
|
||||
#
|
||||
# args:
|
||||
# -d,--destdir : target directory
|
||||
# $@ : git repository
|
||||
#
|
||||
# return value:
|
||||
# 0
|
||||
#
|
||||
# set: pck_version, spec_source, spec_source_comment, pck_tarball
|
||||
|
||||
function git.create_tarball() {
|
||||
local ARGS
|
||||
ARGS=`LC_ALL=C getopt \
|
||||
-o d:p:u: \
|
||||
--long destdir:,proxy:,proxy-user: \
|
||||
-n "$FUNCNAME" -- "$@"`
|
||||
[ $? = 0 ] || notify.error $"(bug)"" -- $FUNCNAME: "$"\`getopt' error"
|
||||
|
||||
local destdir
|
||||
local proxy proxy_user
|
||||
|
||||
eval set -- "$ARGS"
|
||||
while :; do
|
||||
case "$1" in
|
||||
-d|--destdir)
|
||||
destdir="$2"; shift
|
||||
notify.debug "$FUNCNAME: destdir = \"$destdir\""
|
||||
;;
|
||||
-p|--proxy)
|
||||
proxy="$2"; shift
|
||||
notify.debug "$FUNCNAME: proxy = \"$proxy\""
|
||||
;;
|
||||
-u|--proxy-user)
|
||||
proxy_user="$2"; shift
|
||||
notify.debug "$FUNCNAME: proxy_user = \"$proxy_user\""
|
||||
;;
|
||||
--) shift; break;;
|
||||
*) notify.error $"\
|
||||
(bug)"" -- $FUNCNAME: "$"\`getopt' error: bad command \`$1'" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
local git_repository="$1"
|
||||
notify.debug "$FUNCNAME: git_repository = \"$git_repository\""
|
||||
[ "$git_repository" ] || notify.error $"\
|
||||
(bug)"" -- $FUNCNAME: "$"missing mandatory arg"" (#1)"
|
||||
|
||||
[ "$destdir" ] || notify.error $"\
|
||||
(bug)"" -- $FUNCNAME: "$"missing mandatory arg"" (--destdir)"
|
||||
|
||||
which git &>/dev/null ||
|
||||
notify.error $"utility not found"": \`git'"
|
||||
|
||||
local tmpgitdir=$(mktemp -q -d -t tmpgit.XXXXXXXX)
|
||||
[ $? -eq 0 ] ||
|
||||
notify.error $"can't create temporary files"
|
||||
notify.debug "$FUNCNAME: tmpgitdir = $tmpgitdir"
|
||||
|
||||
pushd $tmpgitdir &>/dev/null
|
||||
|
||||
# create a tarball by cloning the git repository
|
||||
notify.note \
|
||||
"${NOTE}"$"cloning git repository"" <$git_repository>${NORM}""..."
|
||||
git clone --quiet "$git_repository"
|
||||
[ $? -eq 0 ] ||
|
||||
{ popd &>/dev/null
|
||||
rm -fr $tmpgitdir
|
||||
notify.error $"cannot clone git repository"; }
|
||||
|
||||
pck_tarball="$(find -mindepth 1 -maxdepth 1 -type d -printf "%f")"
|
||||
|
||||
# remove git files
|
||||
rm -fr $pck_tarball/.git
|
||||
rm -f $pck_tarball/.gitignore
|
||||
|
||||
pck_version="$(date "+%Y%m%dgit")"
|
||||
mv $pck_tarball ${pck_tarball}-${pck_version}
|
||||
pck_tarball="${pck_tarball}-${pck_version}"
|
||||
|
||||
# create a compressed tarball
|
||||
tar -cvf ${pck_tarball}.tar $pck_tarball/ >/dev/null &&
|
||||
bzip2 ${pck_tarball}.tar &&
|
||||
mv ${pck_tarball}.tar.bz2 $destdir/
|
||||
[ $? -eq 0 ] ||
|
||||
{ popd &>/dev/null
|
||||
rm -fr $tmpgitdir
|
||||
notify.error $"\
|
||||
an error occurred while creating"": ${pck_tarball}.tar.bz2"; }
|
||||
|
||||
spec_source="${pck_tarball}.tar.bz2"
|
||||
spec_source_comment="## GITSOURCE $git_repository"
|
||||
pck_tarball="$destdir/${spec_source}"
|
||||
|
||||
popd &>/dev/null
|
||||
rm -fr $tmpgitdir
|
||||
|
||||
return 0
|
||||
}
|
||||
|
@ -474,51 +474,8 @@ function specfile.create() {
|
||||
local pck_name pck_version
|
||||
|
||||
case "$2" in
|
||||
git://*|http://*.git|https://*.git)
|
||||
which git &>/dev/null ||
|
||||
notify.error $"utility not found"": \`git'"
|
||||
|
||||
tmpgitdir=$(mktemp -q -d -t tmpgit.XXXXXXXX)
|
||||
[ $? -eq 0 ] ||
|
||||
notify.error $"can't create temporary files"
|
||||
notify.debug "$FUNCNAME: tmpgitdir = $tmpgitdir"
|
||||
|
||||
pushd $tmpgitdir &>/dev/null
|
||||
|
||||
# create a tarball by cloning the git repository
|
||||
notify.note "${NOTE}"$"cloning git repository"" <$2>${NORM}""..."
|
||||
git clone --quiet "$2"
|
||||
[ $? -eq 0 ] ||
|
||||
{ popd &>/dev/null
|
||||
rm -fr $tmpgitdir
|
||||
notify.error $"cannot clone git repository"; }
|
||||
|
||||
pck_tarball="$(find -mindepth 1 -maxdepth 1 -type d -printf "%f")"
|
||||
|
||||
# remove git files
|
||||
rm -fr $pck_tarball/.git
|
||||
rm -f $pck_tarball/.gitignore
|
||||
|
||||
pck_version="$(date "+%Y%m%dgit")"
|
||||
mv $pck_tarball ${pck_tarball}-${pck_version}
|
||||
pck_tarball="${pck_tarball}-${pck_version}"
|
||||
|
||||
# create a compressed tarball
|
||||
tar -cvf ${pck_tarball}.tar $pck_tarball/ >/dev/null &&
|
||||
bzip2 ${pck_tarball}.tar &&
|
||||
mv ${pck_tarball}.tar.bz2 $source_dir/
|
||||
[ $? -eq 0 ] ||
|
||||
{ popd &>/dev/null
|
||||
rm -fr $tmpgitdir
|
||||
notify.error $"\
|
||||
an error occurred while creating"": ${pck_tarball}.tar.bz2"; }
|
||||
|
||||
spec_source="${pck_tarball}.tar.bz2"
|
||||
spec_source_comment="## GITSOURCE $2"
|
||||
pck_tarball=$source_dir/${spec_source}
|
||||
|
||||
popd &>/dev/null
|
||||
rm -fr $tmpgitdir
|
||||
git://*|http://*.git|https://*.git)
|
||||
git.create_tarball --destdir="$source_dir" "$2"
|
||||
;;
|
||||
http://*|https://*|ftp://*)
|
||||
pck_tarball="${2##*/}"
|
||||
|
@ -37,6 +37,9 @@ msgstr "non è un numero"
|
||||
msgid "missing mandatory arg"
|
||||
msgstr "parametro mancante"
|
||||
|
||||
msgid "utility not found"
|
||||
msgstr "programma non trovato"
|
||||
|
||||
msgid "can't create temporary files"
|
||||
msgstr "impossibile creare file temporanei"
|
||||
|
||||
@ -84,3 +87,12 @@ msgstr "pacchetto non trovato"
|
||||
|
||||
msgid "downloading"
|
||||
msgstr "download di"
|
||||
|
||||
msgid "cloning git repository"
|
||||
msgstr "clonazione del repository"
|
||||
|
||||
msgid "cannot clone git repository"
|
||||
msgstr "impossibile clonare il repository git"
|
||||
|
||||
msgid "an error occurred while creating"
|
||||
msgstr "si è verificato un errore durante la creazione di"
|
||||
|
@ -145,12 +145,6 @@ msgstr "ignorato"
|
||||
msgid "cannot download"
|
||||
msgstr "impossibile scaricare"
|
||||
|
||||
msgid "cloning git repository"
|
||||
msgstr "clonazione del repository git"
|
||||
|
||||
msgid "cannot clone git repository"
|
||||
msgstr "impossibile clonare il repository git"
|
||||
|
||||
msgid "unsupported protocol"
|
||||
msgstr "protocollo non supportato"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user