]> mj.ucw.cz Git - libucw.git/blob - debian/mk
Debian: The build system is packaged as a part of libucw-dev
[libucw.git] / debian / mk
1 #!/bin/bash
2 # A script for building of LibUCW packages
3 # (c) 2013--2017 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 --no-checkout           Expect manually checked out sources to build directory (useful for chrooted building; --version is mandatory)
20 EOF
21         exit 1
22 }
23
24 function pkg-gen-debian {(
25         cd $BUILDDIR
26         echo "Configuring"
27         ./configure debian/config VER="$VER" TREEHASH="$TREEHASH" $CONF \
28                 PREFIX=/ \
29                 INSTALL_INCLUDE_DIR=/usr/include/libucw \
30                 INSTALL_DOC_DIR=/usr/share/doc/libucw/html \
31                 INSTALL_CONFIG_DIR=/usr/share/doc/libucw/examples/etc
32
33         echo "Creating debian/control"
34         build/genconf debian/control.in debian/control obj/config.mk
35
36         if [ -n "$GEN_SCRIPT" ] ; then
37                 echo "Executing $GEN_SCRIPT"
38                 eval "$GEN_SCRIPT"
39         fi
40
41         echo "Creating debian/changelog"
42         export EDITOR=true
43         CL=debian/changelog
44         rm -f $CL
45         dch --changelog=$CL --create --package=$PKG --newversion=$VER "Automatic release."
46         dch --changelog=$CL --release
47         sed -i '/Initial release/d' $CL
48 )}
49
50 ROOT="`pwd`"
51 PKG=libucw
52 ARCHONLY=
53 NO_SOURCE=
54 CLEANUP=
55 CONF=
56 GEN_SCRIPT=
57 while [ -n "$1" ] ; do
58         case "$1" in
59         --archonly)     ARCHONLY=1
60                         ;;
61         --no-source)    NO_SOURCE=1
62                         ;;
63         --cleanup)      CLEANUP=1
64                         ;;
65         --version=*)    PKGVER="${1:10}"
66                         ;;
67         --abi-version=*)CONF="$CONF UCW_ABI_SUFFIX=-${1:14}"
68                         ;;
69         --gen-script=*) GEN_SCRIPT="${1:13}"
70                         ;;
71         --extra-conf=*) CONF="$CONF ${1:13}"
72                         ;;
73         --no-checkout)  PKG_NO_CHECKOUT=1
74                         ;;
75         *)              usage
76                         ;;
77         esac
78         shift
79 done
80
81 pkg-git-version
82 pkg-git-checkout
83
84 echo $VER >$BUILDDIR/UCW_VERSION
85 pkg-gen-debian
86
87 BUILDOPTS=
88 if [ -n "$ARCHONLY" ] ; then
89         BUILDOPTS=-B
90 elif [ -n "$NO_SOURCE" ] ; then
91         BUILDOPTS=-b
92 fi
93 (cd $BUILDDIR && dpkg-buildpackage -rfakeroot -us -uc $BUILDOPTS)
94 [ -z "$ARCHONLY" ] || rm -f debian-tmp/*_all.deb
95 pkg-get-files debian-tmp/*.{deb,dsc,changes,tar.gz}
96
97 [ -z "$CLEANUP" ] || pkg-cleanup