removed unneeded sstream header
[barry.git] / maintainer / make-rpm.sh
blobffec5d34b4759ec763fe0f6396d0306c7b8820eb
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 -type d -maxdepth 1 -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"
33 chroot "$CHROOT/$TARGET" /bin/sh -c "rm -f /usr/src/redhat/RPMS/i386/* /usr/src/redhat/SRPMS/* && cd /usr/src/redhat/SPECS && rpmbuild -ba barry.spec --with gui && 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"