]> mj.ucw.cz Git - libucw.git/blob - debian/mk
Packages: Implemented `debian/mk --extra-conf=...'.
[libucw.git] / debian / mk
1 #!/bin/bash
2 # A script for building of LibUCW packages
3 # (c) 2013--2014 Pavel Charvat <pchar@ucw.cz>
4
5 set -e
6 . debian/pkg-lib
7
8 function usage {
9         cat >&2 <<EOF
10 Usage: $0 <options>
11 Options:
12 --archonly              Build only binary packages
13 --no-source             Don't build source files
14 --cleanup               Cleanup temporary files when finished
15 --version=<ver>         Custom version number of resulting packages (default: autodetect from git-describe)
16 --abi-version=<ver>     Custom version number of the LibUCW's ABI (default: defined in ucw/default.cfg)
17 --gen-script=<script>   Custom script to postprocess
18 --extra-conf=<args>     Add extra arguments to the configure script
19 EOF
20         exit 1
21 }
22
23 function pkg-gen-debian {(
24         cd $BUILDDIR
25         echo "Configuring"
26         ./configure debian/config VER="$VER" TREEHASH="$TREEHASH" $CONF \
27                 PREFIX=/ \
28                 INSTALL_INCLUDE_DIR=/usr/include/libucw \
29                 INSTALL_DOC_DIR=/usr/share/doc/libucw/html \
30                 INSTALL_CONFIG_DIR=/usr/share/doc/libucw/examples/etc
31
32         echo "Creating debian/control"
33         build/genconf debian/control.in debian/control obj/config.mk
34
35         if [ -n "$GEN_SCRIPT" ] ; then
36                 echo "Executing $GEN_SCRIPT"
37                 eval "$GEN_SCRIPT"
38         fi
39
40         echo "Creating debian/changelog"
41         export EDITOR=true
42         CL=debian/changelog
43         rm -f $CL
44         dch --changelog=$CL --create --package=$PKG --newversion=$VER "Automatic release."
45         dch --changelog=$CL --release
46         sed -i '/Initial release/d' $CL
47 )}
48
49 ROOT="`pwd`"
50 PKG=libucw
51 ARCHONLY=
52 NO_SOURCE=
53 CLEANUP=
54 CONF=
55 GEN_SCRIPT=
56 while [ -n "$1" ] ; do
57         case "$1" in
58         --archonly)     ARCHONLY=1
59                         ;;
60         --no-source)    NO_SOURCE=1
61                         ;;
62         --cleanup)      CLEANUP=1
63                         ;;
64         --version=*)    PKGVER="${1:10}"
65                         ;;
66         --abi-version=*)CONF="$CONF UCW_ABI_SUFFIX=-${1:14}"
67                         ;;
68         --gen-script=*) GEN_SCRIPT="${1:13}"
69                         ;;
70         --extra-conf=*) CONF="$CONF ${1:13}"
71                         ;;
72         *)              usage
73                         ;;
74         esac
75         shift
76 done
77
78 pkg-git-version
79 pkg-git-checkout
80
81 echo $TREEVER >$BUILDDIR/UCW_VERSION
82 pkg-gen-debian
83
84 BUILDOPTS=
85 if [ -n "$ARCHONLY" ] ; then
86         BUILDOPTS=-B
87 elif [ -n "$NO_SOURCE" ] ; then
88         BUILDOPTS=-b
89 fi
90 (cd $BUILDDIR && dpkg-buildpackage -rfakeroot -us -uc $BUILDOPTS)
91 [ -z "$ARCHONLY" ] || rm -f debian-tmp/*_all.deb
92 pkg-get-files debian-tmp/*.{deb,dsc,changes,tar.gz}
93
94 [ -z "$CLEANUP" ] || pkg-cleanup