diff --git a/daps.spec b/daps.spec index e70dfc6..5472395 100644 --- a/daps.spec +++ b/daps.spec @@ -28,6 +28,7 @@ Group: Productivity/Publishing/XML URL: http://svn.berlios.de/viewvc/opensuse-doc/trunk/tools/daps/ Source0: %{name}-%{version}.tar.bz2 Source1: %{name}.rpmlintrc +Source2: fetch_source BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildArch: noarch diff --git a/fetch_source b/fetch_source new file mode 100644 index 0000000..be167e5 --- /dev/null +++ b/fetch_source @@ -0,0 +1,81 @@ +#!/bin/bash +# +# +# Create DAPS source tarball from SVN +# +# Copyright (C) 2004 - 2011 SUSE Linux Products GmbH +# +# Author: +# Frank Sundermeyer +# + +NAME=daps +VERSION= +SPECFILE=${NAME}.spec +SVNPATH=https://svn.opensuse.org/svn/opensuse-doc/trunk/tools/daps +TMPDIR=$(mktemp -q -d --tmpdir daps_XXXXXXXX) +EXCLUDES=${TMPDIR}/${NAME}/packaging/exclude-files_for_daps_package.txt + +#---------- +# Functions +#---------- + +# exit on error +# +function exit_on_error { + echo -e "$1" + rm -rf $TMPDIR + exit 1 +} +#----- +# MAIN +#----- +# +# This script needs to be called from the daps osc checkout directory, so +# lets check whethter we are in the correct directory +# +if [[ ! -s daps.spec && ! -d .osc ]]; then + echo "Looks like you are not in the daps checkout directory." + read -p "Continue anyway (y/n) [n]: " CONT + if [[ n = $CONT || N = $CONT ]]; then + exit_on_error "Aborted by user." + fi +fi + +# +# Export daps from SVN +# +svn export -q $SVNPATH ${TMPDIR}/${NAME} || exit_on_error "SVN export failed" + +# +# Get the version number +# +VERSION=$(egrep "^Version:\s*" ${TMPDIR}/${NAME}/packaging/$SPECFILE | sed 's/^Version:\s*//') + +if [[ -z $VERSION ]]; then + exit_on_error "Couldn't get version number from spec-file." +fi + +# +# Create the tarball +# +export BZIP2=--best +tar cjhf ${NAME}-${VERSION}.tar.bz2 -C ${TMPDIR} \ + --exclude-from=$EXCLUDES ${NAME} || exit_on_error "Failed to create the tarball." + +echo "Successfully created ${NAME}-${VERSION}.tar.bz2" + +# +# Copy the spec file if necessary +# +diff -q $SPECFILE ${TMPDIR}/${NAME}/packaging/$SPECFILE >/dev/null +if [[ 0 = $? ]]; then + echo "spec file is up-to-date" +else + cp ${TMPDIR}/${NAME}/packaging/$SPECFILE . || exit_on_error "Failed to copy the specfile." + echo "Successfully updated the spec file." +fi + +rm -rf ${TMPDIR} + +exit 0