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