forked from pool/obs-service-recompress
osc copypac from project:openSUSE:Tools:Unstable package:obs-service-recompress revision:10
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-recompress?expand=0&rev=1
This commit is contained in:
commit
e92a6ed985
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
|
40
obs-service-recompress.spec
Normal file
40
obs-service-recompress.spec
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
Name: obs-service-recompress
|
||||||
|
License: GPL v2 or later
|
||||||
|
Group: Development/Tools/Building
|
||||||
|
Summary: An OBS source service: Recompress files
|
||||||
|
Version: 0.1
|
||||||
|
Release: 1
|
||||||
|
Source: recompress
|
||||||
|
Source1: recompress.service
|
||||||
|
Requires: xz gzip bzip2
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
|
BuildArch: noarch
|
||||||
|
|
||||||
|
%description
|
||||||
|
This is a source service for openSUSE Build Service.
|
||||||
|
|
||||||
|
It supports to compress, uncompress or recompress files from or to
|
||||||
|
|
||||||
|
none : No Compression
|
||||||
|
gz : Gzip Compression
|
||||||
|
bz2 : Bzip2 Compression
|
||||||
|
xz : XZ Compression
|
||||||
|
|
||||||
|
|
||||||
|
%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
|
||||||
|
|
85
recompress
Normal file
85
recompress
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# A simple script to checkout or update a svn or git repo as source service
|
||||||
|
|
||||||
|
# defaults
|
||||||
|
MYCOMPRESSION=""
|
||||||
|
FILES=""
|
||||||
|
|
||||||
|
while test $# -gt 0; do
|
||||||
|
case $1 in
|
||||||
|
*-compression)
|
||||||
|
MYCOMPRESSION="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*-file)
|
||||||
|
FILES="$FILES ${2##*/}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*-outdir)
|
||||||
|
MYOUTDIR="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo Unknown parameter $1.
|
||||||
|
echo 'Usage: recompress --compression $COMPRESSION --file $FILE --outdir $OUT'
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$MYCOMPRESSION" ]; then
|
||||||
|
MYCOMPRESSION="bz2"
|
||||||
|
fi
|
||||||
|
if [ -z "$FILES" ]; then
|
||||||
|
echo "ERROR: no inputs files are given via --file parameter!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "$MYOUTDIR" ]; then
|
||||||
|
echo "ERROR: no output directory is given via --outdir parameter!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for i in $FILES; do
|
||||||
|
FILE=`ls -1 $i`
|
||||||
|
UNCOMPRESS="cat"
|
||||||
|
BASENAME="$FILE"
|
||||||
|
if [ "${FILE%.gz}" != "$FILE" ]; then
|
||||||
|
UNCOMPRESS="gunzip -c"
|
||||||
|
BASENAME="${FILE%.gz}"
|
||||||
|
elif [ "${FILE%.bz2}" != "$FILE" ]; then
|
||||||
|
UNCOMPRESS="bunzip2 -c"
|
||||||
|
BASENAME="${FILE%.bz2}"
|
||||||
|
elif [ "${FILE%.xz}" != "$FILE" ]; then
|
||||||
|
UNCOMPRESS="xz -dc"
|
||||||
|
BASENAME="${FILE%.xz}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MYCOMPRESSION" == "gz" ]; then
|
||||||
|
COMPRESS="gzip -c -"
|
||||||
|
NEWFILE="${BASENAME#_service:}.gz"
|
||||||
|
elif [ "$MYCOMPRESSION" == "bz2" ]; then
|
||||||
|
COMPRESS="bzip2 -c -"
|
||||||
|
NEWFILE="${BASENAME#_service:}.bz2"
|
||||||
|
elif [ "$MYCOMPRESSION" == "xz" ]; then
|
||||||
|
COMPRESS="xz -c -"
|
||||||
|
NEWFILE="${BASENAME#_service:}.xz"
|
||||||
|
elif [ "$MYCOMPRESSION" == "none" ]; then
|
||||||
|
COMPRESS="cat -"
|
||||||
|
NEWFILE="${BASENAME#_service:}"
|
||||||
|
else
|
||||||
|
echo "ERROR: Unknown compression $MYCOMPRESSION"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# do the real work
|
||||||
|
$UNCOMPRESS "$FILE" | $COMPRESS > "$MYOUTDIR/$NEWFILE" || exit 1
|
||||||
|
|
||||||
|
if [ "${FILE#_service:}" != "$FILE" ]; then
|
||||||
|
# we can remove service files, no need to store them twice
|
||||||
|
rm -f "$FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
22
recompress.service
Normal file
22
recompress.service
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<service name="recompress">
|
||||||
|
<summary>Change File Compression</summary>
|
||||||
|
<description>This service supports to compress, uncompress or recompress files from or to
|
||||||
|
none : No Compression
|
||||||
|
gz : Gzip Compression
|
||||||
|
bz2 : Bzip2 Compression
|
||||||
|
xz : XZ Compression
|
||||||
|
</description>
|
||||||
|
<parameter name="compression">
|
||||||
|
<description>Used compression</description>
|
||||||
|
<allowedvalue>none</allowedvalue>
|
||||||
|
<allowedvalue>gz</allowedvalue>
|
||||||
|
<allowedvalue>bz2</allowedvalue>
|
||||||
|
<allowedvalue>xz</allowedvalue>
|
||||||
|
<required/>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="file">
|
||||||
|
<description>name of file to be recompressed. RegExp are allowed.</description>
|
||||||
|
<required/>
|
||||||
|
</parameter>
|
||||||
|
</service>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user