Fix 'h' option missing
[barry.git] / maintainer / make-user-rpm.sh
blob4a9d54b2203afa892c411a972583362bd5503dcd
1 #!/bin/sh
3 if [ -z "$1" -o -z "$2" -o -z "$3" -o -z "$4" -o -z "$CHROOTUSER" -o -z "$CHOWNUSER" ] ; then
4 echo
5 echo "Usage: ./make-rpm.sh tarball specfile chroot_target short_form"
6 echo
7 echo "Copies the tarball to the chroot target's user rpmbuild SOURCES dir, and"
8 echo "the spec file to SPEC dir, then enters the chroot system"
9 echo "and runs rpmbuild as the default user."
10 echo
11 echo "short_form is the tag to rename the resulting RPM's with,"
12 echo "such as fc5 or fc6."
13 echo
14 echo "Expects CHROOTUSER to be set appropriately in the environment."
15 echo
16 exit 1
19 TARPATH="$1"
20 SPECPATH="$2"
21 TARNAME=`basename "$TARPATH"`
22 TARGET="$3"
23 TAG="$4"
25 set -e
27 cp "$TARPATH" "$TARGET/home/$CHROOTUSER/rpmbuild/SOURCES"
28 cp "$SPECPATH" "$TARGET/home/$CHROOTUSER/rpmbuild/SPECS/barry.spec"
29 USERCMD="rm -f /home/$CHROOTUSER/rpmbuild/RPMS/i386/* /home/$CHROOTUSER/rpmbuild/SRPMS/* && cd /home/$CHROOTUSER/rpmbuild/SPECS && rpmbuild --target i386 -ba barry.spec --with gui --with opensync && cd /home/$CHROOTUSER/rpmbuild/RPMS/i386"
30 chroot "$TARGET" su -c "$USERCMD" - $CHROOTUSER
31 mkdir -p "build/$TAG"
32 cp "$TARGET/home/$CHROOTUSER/rpmbuild/RPMS/i386/"* "build/$TAG"
33 cp "$TARGET/home/$CHROOTUSER/rpmbuild/SRPMS/"* "build/$TAG"
35 # We do this manually in a for loop, since the rename command is
36 # not the same across various linux distros...
38 cd "build/$TAG"
39 for f in *.src.rpm ; do
40 mv "$f" "$(echo $f | sed "s/.src.rpm$/.$TAG.src.rpm/")"
41 done
42 for f in *.i386.rpm ; do
43 mv "$f" "$(echo $f | sed "s/.i386.rpm$/.$TAG.i386.rpm/")"
44 done
47 chown -R "$CHOWNUSER" "build/$TAG"