spec-create: allow specfile creation from a git repository
Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
parent
c3335e6113
commit
36fcfd24d6
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
||||
Changes in version 1.10.0
|
||||
Wed Apr 18 2012 Davide Madrisan <davide.madrisan(a)gmail.com>
|
||||
|
||||
+ improvement
|
||||
* spec-create - Davide Madrisan:
|
||||
Add code to create specfiles directly from git repositories.
|
||||
Example:
|
||||
autospec -s git://git.kernel.org/pub/scm/utils/cpu/mce/mcelog.git \
|
||||
-o mcelog.spec
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Changes in version 1.9.4
|
||||
Tue Apr 17 2012 Davide Madrisan <davide.madrisan(a)gmail.com>
|
||||
|
||||
|
12
NEWS
12
NEWS
@ -1,3 +1,15 @@
|
||||
List of user visible changes in the release 1.10.0
|
||||
|
||||
-- Improvement
|
||||
|
||||
* spec-create - Davide Madrisan:
|
||||
Specfile can now be created directly from a git repository.
|
||||
Here an example:
|
||||
autospec -s git://git.kernel.org/pub/scm/utils/cpu/mce/mcelog.git \
|
||||
-o mcelog.spec
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
List of user visible changes in the release 1.9.4
|
||||
|
||||
-- Improvement
|
||||
|
@ -467,6 +467,7 @@ function specfile.create() {
|
||||
|
||||
# 'pck_tarball' = absolute path of '$1'
|
||||
local pck_tarball
|
||||
local pck_name pck_version
|
||||
|
||||
case "$2" in
|
||||
http://*|https://*|ftp://*)
|
||||
@ -480,6 +481,48 @@ ${proxy:+--proxy $proxy} ${proxy_user:+--proxy-user $proxy_user} \
|
||||
|
||||
pck_tarball=$source_dir/$pck_tarball
|
||||
;;
|
||||
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"
|
||||
pck_tarball=$source_dir/${spec_source}
|
||||
|
||||
popd &>/dev/null
|
||||
rm -fr $tmpgitdir
|
||||
;;
|
||||
*://*)
|
||||
notify.error $"unsupported protocol"": \`${2//\:*}'"
|
||||
;;
|
||||
@ -495,7 +538,7 @@ ${proxy:+--proxy $proxy} ${proxy_user:+--proxy-user $proxy_user} \
|
||||
notify.error $"cannot find the package $pck_tarball"
|
||||
|
||||
# get the package name from the tarball name
|
||||
local pck_name=${3:-`echo $2 | sed -n "\
|
||||
[ "$pck_name" ] || pck_name=${3:-`echo $2 | sed -n "\
|
||||
s/.*\/// # remove directory name, if any
|
||||
s/\.[^0-9].*// # remove trailing stuff (.tar.gz, ...)
|
||||
/-[0-9]*/{s/-[0-9].*//p;q} # <pck_name>-<pck_ver>
|
||||
@ -509,7 +552,7 @@ ${proxy:+--proxy $proxy} ${proxy_user:+--proxy-user $proxy_user} \
|
||||
[[ "${pck_newver//[0-9\.]/}" ]] &&
|
||||
notify.error $"invalid version number"" -- \`$pck_newver'"
|
||||
|
||||
local pck_version=${4:-`echo $2 | sed -n "\
|
||||
[ "$pck_version" ] || pck_version=${4:-`echo $2 | sed -n "\
|
||||
/[0-9]/!q # return nothing if no number is found in the package name
|
||||
s,.*/,, # remove directory name, if any
|
||||
s/\.[^0-9].*// # remove trailing stuff (.tar.gz, ...)
|
||||
|
@ -1,5 +1,5 @@
|
||||
# translation of it.po to Italiana
|
||||
# Copyright (C) 2004-2008 Davide Madrisan
|
||||
# Copyright (C) 2004-2008,2012 Davide Madrisan
|
||||
# Davide Madrisan <davide.madrisan@gmail.com>
|
||||
|
||||
msgid ""
|
||||
@ -145,6 +145,12 @@ 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