Add initial code
[ta/build-tools.git] / build_step_create_rpms.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 -e
18
19 scriptdir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
20 source $scriptdir/lib.sh
21
22 _get_projects_all() { repo list -g torpm -n | sort; }
23
24 _get_project_dirs() {
25   for i in $@; do
26     repo info -l $i | grep "^Mount path: " | awk '{print $3}' | tr '\n' ' '
27   done
28 }
29
30 build_rpms()
31 {
32   local work=$1
33   shift
34   rm -rf $work
35   mkdir -p $work
36
37   CENTOS_SOURCES="$(_read_build_config rpm centos_sources)" \
38   $RPM_BUILDER/makebuild.py \
39     -m $RPM_BUILDER_SETTINGS \
40     -w $work \
41     $@ #-v --nowipe
42 }
43
44 # build one or all projects
45 if [ -n "$1" ]; then
46   projects_to_build=$@
47 else
48   projects_to_build="$MANIFEST_PATH $(_get_project_dirs $(_get_projects_all))"
49   _run_cmd $LIBDIR/prepare_manifest.sh
50 fi
51
52 rpmwork=$WORKTMP/rpms
53 build_rpms $rpmwork $projects_to_build
54 _add_rpms_to_repos_from_workdir $rpmwork