2
0

rpmbuild-snaphot 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #!/usr/bin/env bash
  2. #
  3. # This script builds a snapshot RPM package of already existing Sofia-SIP
  4. # build tree
  5. #
  6. # Copyright (C) 2006 Nokia Corporation.
  7. #
  8. # Contact: Pekka Pessi <pekka.pessi@nokia.com>
  9. #
  10. # This library is free software; you can redistribute it and/or
  11. # modify it under the terms of the GNU Lesser General Public License
  12. # as published by the Free Software Foundation; either version 2.1 of
  13. # the License, or (at your option) any later version.
  14. #
  15. # This library is distributed in the hope that it will be useful, but
  16. # WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. # Lesser General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU Lesser General Public
  21. # License along with this library; if not, write to the Free Software
  22. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  23. # 02110-1301 USA
  24. #
  25. # Created: Fri May 23 17:16:54 EEST 2003 ppessi
  26. #
  27. function usage
  28. {
  29. echo "usage: snapshot.sh [-bc|-bb] [-c|--configure] [rpmbuild options]"
  30. exit $@
  31. }
  32. bb=-bb
  33. configure=0
  34. case "$1" in -b? ) bb=$1 ; shift ;; esac
  35. while true ; do
  36. case "$1" in
  37. -c | --configure | --co ) configure=1; shift; ;;
  38. '-?' | --help | -h ) usage 0 ;;
  39. *) break ;;
  40. esac
  41. done
  42. test -z "$srcdir" && srcdir=.
  43. RPMROOT=${RPMROOT:-`rpmbuild --eval='%_topdir' --quiet 2> /dev/null`}
  44. c=$srcdir/configure.ac
  45. PACKAGE_NAME=$(sed -n '/^AC_INIT/ { s/[^[]*\[//; s/\].*//; p;}' $c)
  46. NAME=$(echo $PACKAGE_NAME | tr 'A-Z ' 'a-z-')
  47. VERSION=$(sed -n '/^AC_INIT/ { s/.*\], \[//; s/\].*//; p;}' $c)
  48. GLIB_SOVER=$(sed -n '/^AC_SUBST[(]LIBVER_SOFIA_SIP_UA_GLIB_SOVER/ { s/.*, \[//; s/\].*//; p;}' $c)
  49. # Find spec in
  50. if test -r $NAME.spec.in ; then
  51. specin=$NAME.spec.in
  52. elif test -r packages/$NAME.spec.in ; then
  53. specin=packages/$NAME.spec.in
  54. else
  55. echo $NAME.spec.in: not found
  56. exit 2
  57. fi
  58. specversion=$(sed -n -e '/^Version:/ { s/Version: //; p }' ${specin%.in})
  59. if [ "$VERSION" != "$specversion" ]; then
  60. configure=1
  61. fi
  62. RELEASE=${RELEASE:-SNAP.$(date +"%Y%m%d.%H%M")}
  63. test -r config.status &&
  64. prefix=$(sed -n '/^s,@prefix@,/ { s/^s,[^,]*,//; s/,.*//; p;}' config.status)
  65. test -z "$prefix" && prefix=/usr
  66. wd=${TEMPDIR:=/tmp}/sofia-snapshot-$$
  67. spec=$wd/$NAME-${VERSION}-${RELEASE}.spec
  68. dummy=${NAME}-${VERSION}-${RELEASE}.tar.gz
  69. test -x ./configure || sh ./autogen.sh
  70. install -d ${RPMROOT}/{SOURCES/SNAP,SPECS,BUILD,RPMS,SRPMS} $wd &&
  71. echo Creating $spec &&
  72. awk '
  73. /@VERSION@/ { sub(/@VERSION@/, version); }
  74. /@PACKAGE@/ { sub(/@PACKAGE@/, package); }
  75. /@PACKAGE_NAME@/ { sub(/@PACKAGE_NAME@/, package_name); }
  76. /@LIBVER_SOFIA_SIP_UA_GLIB_SOVER@/ {
  77. sub(/@LIBVER_SOFIA_SIP_UA_GLIB_SOVER@/, glib_sover);
  78. }
  79. /^Release:/ {
  80. print "Release: " release "%{?dist}\n";
  81. print "Prefix: " prefix "\n";
  82. next;
  83. }
  84. /^Source0:/ { print "Source0:" dummy "\n"; next; }
  85. /disable-dependency-tracking/ {
  86. sub(/--disable-dependency-tracking/, "");
  87. }
  88. /^%configure/ {
  89. print "cd " "\"" pwd "\"";
  90. if (!configure) { $1="echo skipping configure"; }
  91. $1=$1 "-C --enable-maintainer-mode";
  92. print $0;
  93. next;
  94. }
  95. # Do not make documentation
  96. /^make doc/ { print "echo skipping " $0; next; }
  97. # Ignore CFLAGS set by RPM
  98. /^make/ { print "CFLAGS= " $0; next; }
  99. { print; }' \
  100. pwd=$PWD \
  101. configure=$configure dummy=$dummy \
  102. package=$NAME package_name="$PACKAGE_NAME" \
  103. version=$VERSION release=$RELEASE glib_sover=$GLIB_SOVER prefix=$prefix \
  104. $specin > $spec &&
  105. ln -s `pwd` $wd/${NAME}-${VERSION} &&
  106. tar cfz ${RPMROOT}/SOURCES/SNAP/$dummy -C $wd ${NAME}-${VERSION} &&
  107. rpmbuild $bb $spec --define '__os_install_post /usr/lib/rpm/brp-compress' --without docs -D"_sourcedir ${RPMROOT}/SOURCES/SNAP" "$@"
  108. rc=$?
  109. rm -rf $wd
  110. rm ${RPMROOT}/SOURCES/SNAP/$dummy
  111. exit $rc