osc copypac from project:openSUSE:Tools:Unstable package:obs-service-extract_file revision:2
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-extract_file?expand=0&rev=1
This commit is contained in:
commit
1e3fec3de0
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
## Default LFS
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.osc
|
68
extract_file
Normal file
68
extract_file
Normal file
@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
# A simple script to checkout or update a svn or git repo as source service
|
||||
|
||||
# defaults
|
||||
MYARCHIVE=""
|
||||
MYFILES=""
|
||||
|
||||
while test $# -gt 0; do
|
||||
case $1 in
|
||||
*-archive)
|
||||
MYARCHIVE="${2##*/}"
|
||||
shift
|
||||
;;
|
||||
*-file)
|
||||
MYFILES="$MYFILES ${2##*/}"
|
||||
shift
|
||||
;;
|
||||
*-outdir)
|
||||
MYOUTDIR="$2"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo Unknown parameter $1.
|
||||
echo 'Usage: extract_file --archive $ARCHIVE --file $FILE --outdir $OUT'
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "$MYARCHIVE" ]; then
|
||||
echo "ERROR: no archive specified!"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$MYFILES" ]; then
|
||||
echo "ERROR: no checkout URL is given via --url parameter!"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$MYOUTDIR" ]; then
|
||||
echo "ERROR: no output directory is given via --outdir parameter!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$MYOUTDIR"
|
||||
|
||||
existing_archive=$(echo $MYARCHIVE)
|
||||
if [ -e "$existing_archive" ]; then
|
||||
if [ "${existing_archive%.tar.gz}" != "$existing_archive" ]; then
|
||||
tar xfz "$existing_archive" $MYFILES || exit 1
|
||||
elif [ "${existing_archive%.tar.bz2}" != "$existing_archive" ]; then
|
||||
tar xfj "$existing_archive" $MYFILES || exit 1
|
||||
elif [ "${existing_archive%.tar.xz}" != "$existing_archive" ]; then
|
||||
tar xfJ "$existing_archive" $MYFILES || exit 1
|
||||
elif [ "${existing_archive%.tar}" != "$existing_archive" ]; then
|
||||
tar xf "$existing_archive" $MYFILES || exit 1
|
||||
elif [ "${existing_archive%.zip}" != "$existing_archive" ]; then
|
||||
unzip "$existing_archive" $MYFILES || exit 1
|
||||
else
|
||||
echo "ERROR: unknown archive format $existing_archive"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "ERROR: archive not found: $existing_archive"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
13
extract_file.service
Normal file
13
extract_file.service
Normal file
@ -0,0 +1,13 @@
|
||||
<service name="extract_file">
|
||||
<summary>Extract files from archive</summary>
|
||||
<description>This service can be used to extract a file from an tar or zip archive. This can be used to used a spec file directly from a tar.</description>
|
||||
<parameter name="archive">
|
||||
<description>Archive to be used</description>
|
||||
<required/>
|
||||
</parameter>
|
||||
<parameter name="files">
|
||||
<description>Files to extract</description>
|
||||
<required/>
|
||||
</parameter>
|
||||
</service>
|
||||
|
35
obs-service-extract_file.spec
Normal file
35
obs-service-extract_file.spec
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
Name: obs-service-extract_file
|
||||
License: GPL v2 or later
|
||||
Group: Development/Tools/Building
|
||||
Summary: An OBS source service: Extract a file from an archive
|
||||
Version: 0.1
|
||||
Release: 1
|
||||
Source: extract_file
|
||||
Source1: extract_file.service
|
||||
Requires: tar bzip2 gzip xz unzip
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildArch: noarch
|
||||
|
||||
%description
|
||||
This is a source service for openSUSE Build Service.
|
||||
|
||||
It supports to extract a file from an archive, for example a spec file from a tar.
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q -D -T 0 -n .
|
||||
|
||||
%build
|
||||
|
||||
|
||||
%install
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/lib/obs/service
|
||||
install -m 0755 %{SOURCE0} $RPM_BUILD_ROOT/usr/lib/obs/service
|
||||
install -m 0644 %{SOURCE1} $RPM_BUILD_ROOT/usr/lib/obs/service
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%dir /usr/lib/obs
|
||||
/usr/lib/obs/service
|
||||
|
Loading…
Reference in New Issue
Block a user