libnetwork.lib; pck-update (action 3,5): improve the functions 'git.download()' and 'git.create_tarball()' by adding the option '--pck-version' and use it when calling 'git.download' in pck-update

Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
Davide Madrisan 2012-10-30 23:17:59 +01:00
parent 80e22280fe
commit f107a20bf8
4 changed files with 38 additions and 12 deletions

View File

@ -20,7 +20,6 @@ Changes in version 1.12.6
Do not use the operator '|&'. Use instead '2>&1 |' which is compatible at
least with bash 3.2.
+ update
* lib/libnetwork.lib - Davide Madrisan:
Clone the entire git repository when the option '--preserve-dot-git' is
selected by user.
@ -52,7 +51,6 @@ Changes in version 1.12.6
Update some requirements of the autospec subpackages in order to always use
the real package names instead of their aliases ('Provides' tag).
+ update
* lib/libnetwork.lib - Davide Madrisan:
New helper function: 'git.download()'.
@ -60,6 +58,12 @@ Changes in version 1.12.6
* pck-update - Davide Madrisan:
Action 3,5: support source files update from a git repository.
* lib/libnetwork.lib - Davide Madrisan:
git.download(), git.create_tarball(): new option '--pck-version'.
* pck-update - Davide Madrisan:
Action 3,5: set the package version when calling 'git.download()'.
-------------------------------------------------------------------------------
Changes in version 1.12.5

View File

@ -856,13 +856,14 @@ curl $options --user \"***:***\" --quote \"DELE $deletefile\" $1"
function git.download() {
local ARGS
ARGS=`LC_ALL=C getopt \
-o d:p:u: \
--long destdir:,proxy:,proxy-user: \
-o d:v:p:u: \
--long destdir:,pck-version:,proxy:,proxy-user: \
-n "$FUNCNAME" -- "$@"`
[ $? = 0 ] || notify.error $"(bug)"" -- $FUNCNAME: "$"\`getopt' error"
local destdir
local proxy proxy_user
local pck_version
eval set -- "$ARGS"
while :; do
@ -871,6 +872,10 @@ function git.download() {
destdir="$2"; shift
notify.debug "$FUNCNAME: destdir = \"$destdir\""
;;
-v|--pck-version)
pck_version="$2"; shift
notify.debug "$FUNCNAME: pck_version = \"$pck_version\""
;;
-p|--proxy)
proxy="$2"; shift
notify.debug "$FUNCNAME: proxy = \"$proxy\""
@ -904,6 +909,7 @@ function git.download() {
notify.debug "$FUNCNAME: git_branch = \"$git_branch\""
git.create_tarball \
--pck-version "$pck_version" \
--destdir "$destdir" \
--preserve-dot-git "0" --git-branch "$git_branch" \
"${token_dirname%/*}"
@ -921,13 +927,12 @@ function git.download() {
# return value:
# 0
#
# set: pck_version, spec_source, spec_source_comment, pck_tarball
# set: spec_source, spec_source_comment, pck_tarball
function git.create_tarball() {
local ARGS
ARGS=`LC_ALL=C getopt \
-o d:p:u: \
--long destdir:,git-branch:,preserve-dot-git:,proxy:,proxy-user: \
ARGS=`LC_ALL=C getopt -o d:v:p:u: \
--long destdir:,pck-version:,git-branch:,preserve-dot-git:,proxy:,proxy-user:\
-n "$FUNCNAME" -- "$@"`
[ $? = 0 ] || notify.error $"(bug)"" -- $FUNCNAME: "$"\`getopt' error"
@ -938,6 +943,7 @@ function git.create_tarball() {
local proxy proxy_user
local git_branch
local preserve_dot_git=0
local pck_version
eval set -- "$ARGS"
while :; do
@ -946,6 +952,10 @@ function git.create_tarball() {
destdir="$2"; shift
notify.debug "$FUNCNAME: destdir = \"$destdir\""
;;
-v|--pck-version)
pck_version="$2"; shift
notify.debug "$FUNCNAME: pck_version = \"$pck_version\""
;;
--git-branch)
git_branch="$2"; shift
notify.debug "$FUNCNAME: git_branch = \"$git_branch\""
@ -977,6 +987,10 @@ function git.create_tarball() {
[ "$destdir" ] || notify.error $"\
(bug)"" -- $FUNCNAME: "$"missing mandatory arg"" (--destdir)"
[ "$pck_version" ] ||
{ pck_version="$(date "+%Y%m%dgit")"
notify.debug "$FUNCNAME: pck_version = \"$pck_version\""; }
which git &>/dev/null ||
notify.error $"utility not found"": \`git'"
@ -1010,7 +1024,6 @@ function git.create_tarball() {
rm -f $pck_tarball/.gitmodules
fi
pck_version="$(date "+%Y%m%dgit")"
mv $pck_tarball ${pck_tarball}-${pck_version}
pck_tarball="${pck_tarball}-${pck_version}"
@ -1020,11 +1033,15 @@ function git.create_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
if [ $? -eq 0 ]; then
notify.note "\
...${NOTE}"$"done""${NORM}: \`${NOTE}${pck_tarball}.tar.bz2${NORM}'"
else
popd &>/dev/null
rm -fr $tmpgitdir
notify.error $"\
an error occurred while creating"": ${pck_tarball}.tar.bz2"; }
an error occurred while creating"": ${pck_tarball}.tar.bz2"
fi
spec_source="${pck_tarball}.tar.bz2"
notify.debug "$FUNCNAME: spec_source = $spec_source"

View File

@ -1125,6 +1125,7 @@ rpmvars.solve "$fullURL_new" "$SRPM_SPECFILE_WITH_PATH")
case "$fullURL_new" in
git://*|http://*.git|https://*.git)
git.download \
--pck-version "$pck_newver" \
--destdir="$source_dir" "$fullURL_new"
;;
*) curl.download --options "$curl_options" $sdflag \
@ -1956,6 +1957,7 @@ rpmvars.solve "$fullURL" "$SRPM_SPECFILE_WITH_PATH")
case "$fullURL" in
git://*|http://*.git|https://*.git)
git.download \
--pck-version "$pck_rpmversion" \
--destdir="$source_dir" "$fullURL"
;;
*) curl.download --options "$curl_options" $sdflag \

View File

@ -99,3 +99,6 @@ msgstr "si è verificato un errore durante la creazione di"
msgid "creating the compressed source tarball"
msgstr "creazione del file sorgente compresso"
msgid "done"
msgstr "fatto"