TODO update
[barry.git] / maintainer / make-rpm.sh
blobc03d9eaa5283dd7b6ff7607bd59e01948c26f250
1 #!/bin/sh
3 CHROOT="/var/chroot"
4 CHOWNUSER="cdfrey:cdfrey"
6 if [ -z "$1" -o -z "$2" -o -z "$3" -o -z "$4" ] ; then
7 echo
8 echo "Usage: ./make-rpm.sh tarball specfile chroot_target short_form"
9 echo
10 echo "Copies the tarball to the chroot target's redhat SOURCES dir, and"
11 echo "the spec file to SPEC dir, then enters the chroot system"
12 echo "and runs rpmbuild."
13 echo
14 echo "short_form is the tag to rename the resulting RPM's with,"
15 echo "such as fc5 or fc6."
16 echo
17 echo "Available chroot targets:"
18 find $CHROOT -maxdepth 1 -type d -print | sed "s/^.*\// /"
19 echo
20 exit 1
23 TARPATH="$1"
24 SPECPATH="$2"
25 TARNAME=`basename "$TARPATH"`
26 TARGET="$3"
27 TAG="$4"
29 set -e
31 cp "$TARPATH" "$CHROOT/$TARGET/usr/src/redhat/SOURCES"
32 cp "$SPECPATH" "$CHROOT/$TARGET/usr/src/redhat/SPECS/barry.spec"
33 chroot "$CHROOT/$TARGET" /bin/sh -lc "rm -f /usr/src/redhat/RPMS/i386/* /usr/src/redhat/SRPMS/* && cd /usr/src/redhat/SPECS && rpmbuild --target i386 -ba barry.spec --with gui --with opensync && cd /usr/src/redhat/RPMS/i386"
34 mkdir -p "build/$TARGET"
35 cp "$CHROOT/$TARGET/usr/src/redhat/RPMS/i386/"* "build/$TARGET"
36 cp "$CHROOT/$TARGET/usr/src/redhat/SRPMS/"* "build/$TARGET"
38 # We do this manually in a for loop, since the rename command is
39 # not the same across various linux distros...
41 cd "build/$TARGET"
42 for f in *.src.rpm ; do
43 mv "$f" "$(echo $f | sed "s/.src.rpm$/.$TAG.src.rpm/")"
44 done
45 for f in *.i386.rpm ; do
46 mv "$f" "$(echo $f | sed "s/.i386.rpm$/.$TAG.i386.rpm/")"
47 done
50 chown -R $CHOWNUSER "build/$TARGET"