Commit 4815cc81 authored by Vitaly Lipatov's avatar Vitaly Lipatov

rpmgs: add src.rpm download support

parent a261e7c6
...@@ -55,6 +55,31 @@ LISTRPMARGS=$@ ...@@ -55,6 +55,31 @@ LISTRPMARGS=$@
} }
# Extract Source tarball from src.rpm file
# Args: SRCRPM TARGET
extract_from_srcrpm()
{
local SRCRPM="$(realpath "$1")"
local TARGET="$2"
local TMPDIR
TMPDIR=$(mktemp -d) || fatal "Can't create temp dir"
info "Extracting Source tarball from $(basename "$SRCRPM") ..."
docmd $ERCCMD -C "$TMPDIR" x "$SRCRPM" || { rm -rf "$TMPDIR" ; fatal "Can't extract src.rpm" ; }
# find the source tarball inside extracted directory
local TARBALL
TARBALL=$(find "$TMPDIR" -name '*.tar*' -o -name '*.tgz' -o -name '*.zip' -o -name '*.7z' | head -1)
if [ -z "$TARBALL" ] ; then
rm -rf "$TMPDIR"
fatal "No source tarball found in src.rpm"
fi
info "Found source tarball: $(basename "$TARBALL")"
repack_tarball "$TARBALL" "$TARGET"
local RET=$?
rm -rf "$TMPDIR"
rm -f "$SRCRPM"
return $RET
}
repack_tarball() repack_tarball()
{ {
# TODO: move it into repack # TODO: move it into repack
...@@ -125,6 +150,15 @@ download_to() ...@@ -125,6 +150,15 @@ download_to()
popd popd
return $RET return $RET
fi fi
# handle src.rpm: extract Source tarball from it
if echo "$URL" | grep -q '\.src\.rpm$' ; then
local DF="$(basename "$URL")"
download_url "$URL" && DF="$DOWNLOADEDNAME" && extract_from_srcrpm "$DF" "$TARGET"
local RET=$?
[ "$RET" = "0" ] || rm -fv "$DF" "$TARGET"
popd
return $RET
fi
local DF="$(basename "$URL")" local DF="$(basename "$URL")"
download_url "$URL" && DF="$DOWNLOADEDNAME" && repack_tarball "$DF" "$TARGET" download_url "$URL" && DF="$DOWNLOADEDNAME" && repack_tarball "$DF" "$TARGET"
local RET=$? local RET=$?
...@@ -260,7 +294,7 @@ function print_error() ...@@ -260,7 +294,7 @@ function print_error()
{ {
echog "Can't find any spec file. It is possible you run this script not in git dir." echog "Can't find any spec file. It is possible you run this script not in git dir."
echog "If you use old style build, run rpmgs with spec name as arg." echog "If you use old style build, run rpmgs with spec name as arg."
echog "If you wish download src.rpm, use rpmgp script." echog "You can also use src.rpm URL in Source-url."
exit 1 exit 1
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment