Add a script to build REC images
[ta/build-tools.git] / create_manifest_rpm.sh
1 #!/bin/bash
2 # Copyright 2019 Nokia
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 set -x
17 set -eu
18
19 scriptdir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
20 source $scriptdir/lib.sh
21
22 work=${1:-$WORKTMP/manifest-work}
23 work=$(readlink -f $work)
24 rm -rf $work
25 mkdir -p $work
26 cp -f $MANIFEST_PATH/*.spec $work
27
28 $scriptdir/create_mock_config.sh $MANIFEST_PATH/build_config.ini $work/mock_config
29
30 rpm_macros=$work/rpmmacros
31 $scriptdir/mock2rpmbuild_config.py --mock-config $work/mock_config/mock.cfg --output-file-path $rpm_macros
32
33 docker run --rm \
34     -v $rpm_macros:/root/.rpmmacros \
35     -v $work:/work \
36     alpine:3.9.4 \
37     sh -c '\
38         apk add rpm && \
39         rpmbuild --build-in-place --rmspec -ba /work/*.spec && \
40         find /root/rpmbuild -name "*.rpm" | xargs -I "{}" mv {} /work'
41
42 _add_rpms_to_localrepo $(find $work -name '*.rpm')