Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/rpms/buildrpm.sh
diff options
context:
space:
mode:
Diffstat (limited to 'rpms/buildrpm.sh')
-rw-r--r--rpms/buildrpm.sh123
1 files changed, 123 insertions, 0 deletions
diff --git a/rpms/buildrpm.sh b/rpms/buildrpm.sh
new file mode 100644
index 0000000..1b935e2
--- /dev/null
+++ b/rpms/buildrpm.sh
@@ -0,0 +1,123 @@
+#!/bin/bash
+#
+# Copyright (C) 2012 Ruben Rodriguez <ruben@trisquel.info>
+#
+# 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.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+# This script builds Dextrose patched, Sugar rpms from git repositories
+# Requirements: git, yum-utils, rpmbuild, patch, libtool, intltool, createrepo
+
+set -e
+
+if [ $# != 2 ]
+then
+ echo Usage: sh $0 version package
+ echo Example: sh $0 0.94.1 sugar-toolkit
+ exit 1
+fi
+
+# Let's make sure we have all we need
+yum -y install git yum-utils rpmbuild patch libtool intltool createrepo
+
+WD=$PWD
+VERSION=$1
+PACKAGE=$2
+FUZZ=20
+ARCH=$(rpm -q glibc |sed 's/.*\.//;s/i686/i386/')
+TEST=$(mktemp -d)
+
+rm -rf ~/rpmbuild/SOURCES ~/rpmbuild/SPECS
+
+mkdir -p ~/rpmbuild/BUILD ~/rpmbuild/BUILDROOT ~/rpmbuild/RPMS ~/rpmbuild/SOURCES ~/rpmbuild/SPECS/$PACKAGE ~/rpmbuild/SRPMS
+
+
+cp $PACKAGE/$PACKAGE.spec ~/rpmbuild/SPECS/$PACKAGE/
+[ -f $PACKAGE/macros.$PACKAGE ] && cp $PACKAGE/macros.$PACKAGE ~/rpmbuild/SOURCES/
+
+git clone git://git.sugarlabs.org/$PACKAGE/mainline.git ~/rpmbuild/SOURCES/$PACKAGE-$VERSION
+cd ~/rpmbuild/SOURCES/$PACKAGE-$VERSION
+git checkout v$VERSION
+cd $WD
+sed "s/Version:.*/Version: $VERSION/" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
+sed "s/Release:.*/Release: $(date +%Y%m%d)dx3/" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
+# Since sugar and sugar-artwork DX3 specs *already* have epoch set to the
+# date number, we will continue that hack for DX3. BUT THIS IS WRONG!!!
+sed '/^Epoch:/d' -i ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec
+sed "/^Name:/s/$/\nEpoch: $(date +%Y%m%d)/" -i ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec
+
+# Let's allow some fuzz
+sed "1s/$/\n%define _default_patch_fuzz $FUZZ/" -i ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec
+
+cd ~/rpmbuild/SOURCES/$PACKAGE-$VERSION
+[ $PACKAGE = "sugar-artwork" ] && sed '/GNOME_COMPILE_WARNINGS/d' configure.ac -i
+sh autogen.sh
+cd ..
+tar -jcvf $PACKAGE-$VERSION.tar.bz2 $PACKAGE-$VERSION
+cd $WD
+
+############################################################################
+
+# Set tokens for adding patches to the spec file
+sed "/^Source0/s/$/\n\#ListPatches/" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
+sed "/^%setup/s/$/\n\#MakePatches/" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
+sed "/^Patch/d" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
+sed "/^%*patch/d" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
+
+# number, name, string, strip
+addpatch(){
+sed "/ListPatches/s%^%Patch$1: $3\n%" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
+sed "/MakePatches/s/^/%patch$1 -p$4 -b $2\n/" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
+}
+
+rm -rf ~/rpmbuild/RPMS/$PACKAGE-$VERSION.*patches
+cp ~/rpmbuild/SOURCES/$PACKAGE-$VERSION $TEST/src -a
+cd $TEST/src
+for i in $WD/$PACKAGE/*patch
+do
+ file=${i//*\//}
+ number=${file//-*/}
+ log=$(patch -N -t -F$FUZZ --dry-run -p1 < $i 2>&1)
+ if [ $? = 0 ]
+ then
+ echo APPLYED PATCH: $file | tee -a ~/rpmbuild/RPMS/$PACKAGE-$VERSION.appliedpatches
+ patch -F$FUZZ -p1 < $i
+ cp $i ~/rpmbuild/SOURCES/
+ addpatch $number .$number "$file" 1
+ else
+ if echo $log |grep -q "previously applied"
+ then
+ echo ALREADY APPLIED: $file | tee -a ~/rpmbuild/RPMS/$PACKAGE-$VERSION.failedpatches
+ else
+ echo FAILED TO APPLY: $file | tee -a ~/rpmbuild/RPMS/$PACKAGE-$VERSION.failedpatches
+ fi
+ fi
+done
+cd $WD
+rm -rf $TEST
+
+# Clean tokens
+sed '/ListPatches/d; /MakePatches/d' ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
+
+############################################################################
+
+grep BuildRequires ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec |sed s/.*\ //|xargs yum -y install
+rpmbuild --clean ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec
+if rpm -q glibc |grep -q armv5
+then
+ rpmbuild --target armv5tel -ba ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec
+else
+ rpmbuild -ba ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec
+fi