Add a script to build REC images
[ta/build-tools.git] / create_manifest_rpm.sh
diff --git a/create_manifest_rpm.sh b/create_manifest_rpm.sh
new file mode 100755 (executable)
index 0000000..b7ac213
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/bash
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -x
+set -eu
+
+scriptdir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
+source $scriptdir/lib.sh
+
+work=${1:-$WORKTMP/manifest-work}
+work=$(readlink -f $work)
+rm -rf $work
+mkdir -p $work
+cp -f $MANIFEST_PATH/*.spec $work
+
+$scriptdir/create_mock_config.sh $MANIFEST_PATH/build_config.ini $work/mock_config
+
+rpm_macros=$work/rpmmacros
+$scriptdir/mock2rpmbuild_config.py --mock-config $work/mock_config/mock.cfg --output-file-path $rpm_macros
+
+docker run --rm \
+    -v $rpm_macros:/root/.rpmmacros \
+    -v $work:/work \
+    alpine:3.9.4 \
+    sh -c '\
+        apk add rpm && \
+        rpmbuild --build-in-place --rmspec -ba /work/*.spec && \
+        find /root/rpmbuild -name "*.rpm" | xargs -I "{}" mv {} /work'
+
+_add_rpms_to_localrepo $(find $work -name '*.rpm')