#!/bin/bash
-errlog()
-{
- local lastexit=$?
- local msg="$1"
-
- echo "❌ ERROR: $msg"
- echo "🛑 EXIT $lastexit"
- return $lastexit
-}
-
run_tests()
{
- mkdir -p /app-tests \
- || errlog "could not create folder /app-tests" \
- || return $?
- cd /app-tests \
- || errlog "could not change direcotry to /app-tests" \
- || return $?
- cmake -DCMAKE_BUILD_TYPE=Debug -DRUN_TESTS=ON /source \
- || errlog "could not create tests with cmake" \
- || return $?
- echo "ℹ️ INFO: run tests"
- make -j$(nproc) \
- || errlog "tests failed" \
- || return $?
-
- mkdir -p /app-imagemagick-tests \
- || errlog "could not create folder /app-imagemagick-tests" \
- || return $?
- cd /app-imagemagick-tests \
- || errlog "could not change direcotry to /app-imagemagick-tests" \
- || return $?
- cmake -DCMAKE_BUILD_TYPE=Debug -DRUN_TESTS=ON -DIMAGEMAGICK=ON /source \
- || errlog "could not create tests with cmake" \
- || return $?
- echo "ℹ️ INFO: run imagemagick tests"
- make -j$(nproc) \
- || errlog "tests failed" \
- || return $?
+ mkdir -p /app/tests && cd /app/tests
+ cmake -DCMAKE_BUILD_TYPE=Debug \
+ -DIMAGEMAGICK=OFF
+ -DRUN_TESTS=ON /src
+ make -j$(nproc)
+
+ mkdir -p /app/imagemagick-tests && cd /app/imagemagick-tests
+ cmake -DCMAKE_BUILD_TYPE=Debug \
+ -DIMAGEMAGICK=ON \
+ -DRUN_TESTS=ON /src
+ make -j$(nproc)
}
build_package()
{
- mkdir -p /app-build \
- || errlog "could not create folder /app-build" \
- || return $?
- cd /app-build \
- || errlog "could not change directory to /app-build" \
- || return $?
- cmake -DEXTRA_VERSION="-$ID-$VERSION_CODENAME" \
- -DCMAKE_BUILD_TYPE=Release /source \
- || errlog "could not create build with cmake" \
- || return $?
- echo "ℹ️ INFO: build package"
- make -j$(nproc) package \
- || errlog "could not build package" \
- || return $?
-
- mkdir -p /app-imagemagick-build \
- || errlog "could not create folder /app-imagemagick-build " \
- || return $?
- cd /app-imagemagick-build \
- || errlog "could not change directory to /app-imagemagick-build " \
- || return $?
- cmake -DEXTRA_VERSION="-imagemagick-$ID-$VERSION_CODENAME" \
- -DCMAKE_BUILD_TYPE=Release -DIMAGEMAGICK=ON /source \
- || errlog "could not create build with cmake" \
- || return $?
- echo "ℹ️ INFO: build imagemagick package"
- make -j$(nproc) package \
- || errlog "could not build imagemagick package" \
- || return $?
+ mkdir -p /app/build && cd /app/build
+ cmake -DCMAKE_BUILD_TYPE=Release \
+ -DIMAGEMAGICK=OFF \
+ -DEXTRA_VERSION="-$ID-$VERSION_CODENAME" /src
+ make -j$(nproc) package
+
+ mkdir -p /app/imagemagick-build && cd /app/imagemagick-build
+ cmake -DCMAKE_BUILD_TYPE=Release \
+ -DIMAGEMAGICK=ON \
+ -DEXTRA_VERSION="-imagemagick-$ID-$VERSION_CODENAME" /src
+ make -j$(nproc) package
}
copy_package()
{
- echo "ℹ️ INFO: copy package"
- cp /app-build/*.deb /source/build/ \
- || errlog "could not copy package to /source/build-$ID-$VERSION_CODENAME" \
- || return $?
- cp /app-imagemagick-build/*.deb /source/build/ \
- || errlog "could not copy package to /source/build-$ID-$VERSION_CODENAME" \
- || return $?
+ cp /app/build/*.deb /src/build/
+ cp /app/imagemagick-build/*.deb /src/build/
}
main()
{
- echo "⭐ START: run"
-
source /etc/os-release
run_tests || return $?
build_package || return $?
copy_package || return $?
-
- echo "✅ SUCCESS run"
}
main
\ No newline at end of file