Accepting request 205119 from home:saschpe:branches:openSUSE:Tools

- Move service to github.com/openSUSE/obs-service-set_version
- Add _service file to update package from there
- Drop local sources and use tarball from source services

OBS-URL: https://build.opensuse.org/request/show/205119
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-set_version?expand=0&rev=15
This commit is contained in:
Adrian Schröter 2013-10-29 14:07:44 +00:00 committed by Git OBS Bridge
parent 9741042957
commit a5c2030f35
6 changed files with 43 additions and 142 deletions

20
_service Normal file
View File

@ -0,0 +1,20 @@
<services>
<service mode="disabled" name="tar_scm">
<param name="url">git@github.com:openSUSE/obs-service-set_version.git</param>
<param name="scm">git</param>
<param name="exclude">.git</param>
<param name="version">git-master</param>
<param name="versionformat">@PARENT_TAG@</param>
<param name="revision">master</param>
<param name="changesrevision">faa5a4fd7a531eeab0ab43bbe1c5ccc909b607dd</param>
</service>
<service mode="disabled" name="recompress">
<param name="file">*.tar</param>
<param name="compression">gz</param>
</service>
<service mode="disabled" name="set_version">
<param name="basename">obs-service-set_version</param>
</service>
</services>

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:31514b9d30d33df4e171ca9e9f299a562f4734b6fde7b135e38c986e6dae936b
size 1993

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Oct 29 13:47:13 UTC 2013 - speilicke@suse.com
- Move service to github.com/openSUSE/obs-service-set_version
- Add _service file to update package from there
- Drop local sources and use tarball from source services
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Oct 8 10:06:26 UTC 2013 - jblunck@opensuse.org Tue Oct 8 10:06:26 UTC 2013 - jblunck@opensuse.org

View File

@ -16,14 +16,16 @@
# #
Name: obs-service-set_version %define service set_version
Name: obs-service-%{service}
Version: 0.3
Release: 0
Summary: An OBS source service: Update spec file version Summary: An OBS source service: Update spec file version
License: GPL-2.0+ License: GPL-2.0+
Group: Development/Tools/Building Group: Development/Tools/Building
Version: 0.3 Url: https://github.com/openSUSE/obs-service-%{service}
Release: 0 Source: %{name}-%{version}.tar.gz
Source: set_version
Source1: set_version.service
Requires: sed Requires: sed
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch BuildArch: noarch
@ -35,18 +37,18 @@ Very simply script to update the version in .spec or .dsc files according to
a given version or to the existing files. a given version or to the existing files.
%prep %prep
%setup -q -D -T 0 -n . %setup -q
%build %build
%install %install
mkdir -p $RPM_BUILD_ROOT/usr/lib/obs/service mkdir -p %{buildroot}%{_prefix}/lib/obs/service
install -m 0755 %{SOURCE0} $RPM_BUILD_ROOT/usr/lib/obs/service install -m 0755 set_version %{buildroot}%{_prefix}/lib/obs/service
install -m 0644 %{SOURCE1} $RPM_BUILD_ROOT/usr/lib/obs/service install -m 0644 set_version.service %{buildroot}%{_prefix}/lib/obs/service
%files %files
%defattr(-,root,root) %defattr(-,root,root)
%dir /usr/lib/obs %dir %{_prefix}/lib/obs
/usr/lib/obs/service %{_prefix}/lib/obs/service
%changelog %changelog

View File

@ -1,115 +0,0 @@
#!/bin/bash
# A simple script to update spec or dsc file
# very, very simple. I am happy about patches which handles multiple files with different version numbers
#
# (C) 2010 by Adrian Schröter <adrian@suse.de>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# See http://www.gnu.org/licenses/gpl-2.0.html for full license text.
# defaults
MYVERSION=""
FILES=""
while test $# -gt 0; do
case $1 in
*-version)
MYVERSION="$2"
shift
;;
*-file)
FILES="$FILES ${2##*/}"
shift
;;
*-basename)
BASENAME="^$2"
shift
;;
*-outdir)
MYOUTDIR="$2"
shift
;;
*)
echo Unknown parameter $1.
echo 'Usage: set_version --version $VERSION --file $FILE --basename $BASENAME --outdir $OUT'
exit 1
;;
esac
shift
done
get_version_from_file () {
if [ -z "$MYVERSION" ]; then
MYVERSION=`ls -1t | sed -n "s,$BASENAME.*[-_]\([0123456789].*\).tar.*,\1,p" | head -n 1`
fi
if [ -z "$MYVERSION" ]; then
MYVERSION=`ls -1t | sed -n "s,$BASENAME.*[-_]\([0123456789].*\).tgz$,\1,p" | head -n 1`
fi
if [ -z "$MYVERSION" ]; then
MYVERSION=`ls -1t | sed -n "s,$BASENAME.*[-_]\([0123456789].*\).tbz2$,\1,p" | head -n 1`
fi
if [ -z "$MYVERSION" ]; then
MYVERSION=`ls -1t | sed -n "s,$BASENAME.*[-_]\([0123456789].*\).zip$,\1,p" | head -n 1`
fi
if [ -z "$MYVERSION" ]; then
# take version number (and optional revision) from Debian changelog
MYVERSION=`head -n 1 *debian.changelog 2>/dev/null | sed -ne 's/.*(\(.*\)).*/\1/p'`
fi
if [ -z "$MYVERSION" ]; then
echo "ERROR: no version is given and can't get detected automatically"
exit 1
fi
# remove trailing ".orig", used by dpkg sources
MYVERSION=`sed s/.orig$// <<<$MYVERSION`
echo "Detected version as $MYVERSION"
}
write_files () {
if [ -z "$FILES" ]; then
FILES="*.spec *.dsc"
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 2>/dev/null`
[ -e "$FILE" ] || continue
sed "0,/^Version:\(\s*\)[^%]*/s//Version:\1$MYVERSION/" "$FILE" > "$MYOUTDIR/$FILE" || exit 1
echo "Updated first occurrence (if any) of Version in $FILE to $MYVERSION"
if [ "${FILE%.spec}" != "$FILE" ]; then
# set release back to zero after version upgrade, will be increased by OBS during build
# also keep macros in release in case of fedora/mandriva
sed -r -i "s,^Release:(\s*)[^%]*,Release:\10," "$MYOUTDIR/$FILE" || exit 1
fi
if [ "${FILE#_service:}" != "$FILE" ]; then
# we can remove service files, no need to store them twice
rm -f "$FILE"
fi
done
if [ -e PKGBUILD ]; then
FILE=`ls -1 _service:*[-_]${MYVERSION}* | head -n 1`
[ -z "$FILE" ] && FILE=`ls -1 *[-_]${MYVERSION}* | head -n 1`
MD5=`md5sum "$FILE" | head -n 1 | cut -d\ -f 1`
sed "0,/^pkgver=\(\s*\)[^%]*/s//pkgver=\1$MYVERSION/" PKGBUILD > "$MYOUTDIR/PKGBUILD" || exit 1
sed -r -i "s,^pkgrel=.*,pkgrel=0," "$MYOUTDIR/PKGBUILD" || exit 1
sed -r -i "s,^md5sums=.*,md5sums=('$MD5')," "$MYOUTDIR/PKGBUILD" || exit 1
fi
}
get_version_from_file
write_files
exit 0

View File

@ -1,16 +0,0 @@
<service name="set_version">
<summary>Updates version in spec and dsc files</summary>
<description>This service updates a spec file according to the existing files.
Can be used after download_url or tar_scm service.
</description>
<parameter name="version">
<description>Set version to this value, otherwise autodetection is running.</description>
</parameter>
<parameter name="basename">
<description>Limit version detection to files which start with given name.</description>
</parameter>
<parameter name="file">
<description>Update only the given file.</description>
</parameter>
</service>