Add PackageCloud.io publishing to CI scripts
[ric-plt/sdl.git] / package.sh
1 #!/bin/bash
2 #
3 # Copyright (c) 2019 AT&T Intellectual Property.
4 # Copyright (c) 2018-2019 Nokia.
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 set -e
19
20 if [ $# -eq 0 ]
21 then
22    echo "Generate a binary package"
23    echo "Usage: $0 [--target-dir <dir>] [--skip-config] target..."
24    echo "Where possible targets are debian and rpm"
25    exit 1
26 fi
27
28 SKIP_CONF=0
29 BUILD_RPM=0
30 BUILD_DEB=0
31 SKIP_TEST=0
32 TARGET_DIR=/tmp
33
34 for i in "$@"
35 do
36     case "$i" in
37     --target-dir)
38         shift
39         TARGET_DIR=$i
40         ;;
41     --skip-config)
42         SKIP_CONF=1
43         ;;
44     --skip-test)
45         SKIP_TEST=1
46         ;;
47     rpm)
48         BUILD_RPM=1
49         shift
50         ;;
51     debian)
52         BUILD_DEB=1
53         ;;
54     *)
55         echo "Unknown argument $1"
56         exit 1
57         ;;
58     esac
59 done
60
61 if [ $SKIP_CONF -eq 0 ]
62 then
63     ./autogen.sh && ./configure
64 fi
65
66 if [ $BUILD_RPM -ne 0 ]
67 then
68     if [ $SKIP_TEST ]
69     then
70         TESTOPT=--nocheck
71     fi
72     rpmbuild --nodeps $TESTOPT -bb rpm/sdl.spec --define="_sourcedir $PWD" --define="_builddir $PWD" --define="_rpmdir .."
73     cp ../x86_64/*.rpm "$TARGET_DIR"
74 fi
75
76 if [ $BUILD_DEB -ne 0 ]
77 then
78     if [ $SKIP_TEST -eq 1 ]
79     then
80         export DEB_BUILD_OPTIONS="nocheck noddebs"
81     fi
82     debuild -b -us -uc
83 fi