From d6f0fe6814348e7a169fc616f05541108131081c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danilo=20Je=C5=A1i=C4=87?= <34022788+djesic@users.noreply.github.com> Date: Wed, 19 May 2021 14:49:33 +0200 Subject: [PATCH] Modified scripts (#73) --- tools/deb-amd64/Dockerfile | 13 +++++--- tools/deb-amd64/build-image-amd64.sh | 6 +--- tools/deb-amd64/run-amd64.sh | 11 ++++--- tools/deb-arm64/Dockerfile | 4 ++- tools/deb-arm64/build-image-arm64.sh | 8 ++--- tools/deb-arm64/run-arm64.sh | 9 +++--- tools/deb-armv7l/Dockerfile | 13 +++++--- tools/deb-armv7l/build-image-armv7l.sh | 8 ++--- tools/deb-armv7l/run-armv7l.sh | 9 +++--- tools/make_deb.sh | 43 +------------------------- tools/make_release.sh | 9 +----- tools/make_zip.sh | 7 ++++- 12 files changed, 46 insertions(+), 94 deletions(-) diff --git a/tools/deb-amd64/Dockerfile b/tools/deb-amd64/Dockerfile index 0633533..1682c07 100644 --- a/tools/deb-amd64/Dockerfile +++ b/tools/deb-amd64/Dockerfile @@ -1,12 +1,15 @@ -FROM ubuntu:bionic-20200403 +FROM amd64/debian:buster WORKDIR /build -RUN apt-get update \ - && apt-get install -y git gcc g++ cmake zlib1g-dev \ - && apt-get install -y mosquitto cmake libssl-dev \ - && apt-get install -y devscripts debhelper +ENV TZ=Europe/Belgrade +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN apt update +RUN apt install -y git gcc g++ cmake automake autotools-dev autoconf m4 zlib1g-dev \ + cmake libtool libssl-dev devscripts debhelper COPY make_deb.sh /build +COPY *.zip /build #CMD ["bash", "make_deb.sh"] diff --git a/tools/deb-amd64/build-image-amd64.sh b/tools/deb-amd64/build-image-amd64.sh index 4e33909..f461f54 100755 --- a/tools/deb-amd64/build-image-amd64.sh +++ b/tools/deb-amd64/build-image-amd64.sh @@ -15,12 +15,8 @@ # limitations under the License. # -if [ "$EUID" -ne 0 ]; then - echo "Please run as sudo." - exit -fi - cp ../make_deb.sh . +cp ../*.zip . docker build -t wolkabout:wg-amd64 . rm make_deb.sh diff --git a/tools/deb-amd64/run-amd64.sh b/tools/deb-amd64/run-amd64.sh index fa0e3a4..6080bcb 100755 --- a/tools/deb-amd64/run-amd64.sh +++ b/tools/deb-amd64/run-amd64.sh @@ -15,11 +15,6 @@ # limitations under the License. # -if [ "$EUID" -ne 0 ]; then - echo "Please run as sudo." - exit -fi - ./build-image-amd64.sh docker container stop debuilder @@ -31,6 +26,7 @@ if [ $? -eq 1 ]; then fi docker run -dit --name debuilder --cpus $(nproc) wolkabout:wg-amd64 || exit +docker exec -it debuilder unzip /build/*.zip -d WolkGateway || exit docker exec -it debuilder /build/make_deb.sh $branch || exit docker cp debuilder:/build/ . @@ -40,4 +36,9 @@ docker container rm debuilder mv ./build/*.deb . rm -rf ./build/ +rm *dbgsym* + +rm ./make_deb.sh +rm ./*.zip + chown "$USER:$USER" *.deb diff --git a/tools/deb-arm64/Dockerfile b/tools/deb-arm64/Dockerfile index 6a15204..ac6799e 100644 --- a/tools/deb-arm64/Dockerfile +++ b/tools/deb-arm64/Dockerfile @@ -6,8 +6,10 @@ ENV TZ=Europe/Belgrade RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN apt update -RUN apt install -y git gcc g++ cmake automake autotools-dev autoconf m4 zlib1g-dev cmake libtool libssl-dev libpoco-dev devscripts debhelper +RUN apt install -y git gcc g++ cmake automake autotools-dev autoconf m4 zlib1g-dev \ + cmake libtool libssl-dev devscripts debhelper COPY make_deb.sh /build +COPY *.zip /build #CMD ["bash", "make_deb.sh"] diff --git a/tools/deb-arm64/build-image-arm64.sh b/tools/deb-arm64/build-image-arm64.sh index 054b983..83b3fc8 100755 --- a/tools/deb-arm64/build-image-arm64.sh +++ b/tools/deb-arm64/build-image-arm64.sh @@ -15,15 +15,11 @@ # limitations under the License. # -if [ "$EUID" -ne 0 ]; then - echo "Please run as sudo." - exit -fi - -sudo apt-get install qemu binfmt-support qemu-user-static +echo "If something doesn\'t work, install the dependencies: 'apt-get install qemu qemu-user-static binfmt-support'" docker run --rm --privileged multiarch/qemu-user-static --reset -p yes cp ../make_deb.sh . +cp ../*.zip . docker build -t wolkabout:wg-arm64 . rm make_deb.sh diff --git a/tools/deb-arm64/run-arm64.sh b/tools/deb-arm64/run-arm64.sh index 28fb865..dff238e 100755 --- a/tools/deb-arm64/run-arm64.sh +++ b/tools/deb-arm64/run-arm64.sh @@ -15,11 +15,6 @@ # limitations under the License. # -if [ "$EUID" -ne 0 ]; then - echo "Please run as sudo." - exit -fi - ./build-image-arm64.sh docker container stop debuilder @@ -31,6 +26,7 @@ if [ $? -eq 1 ]; then fi docker run -dit --name debuilder --cpus $(nproc) wolkabout:wg-arm64 || exit +docker exec -it debuilder unzip /build/*.zip -d WolkGateway || exit docker exec -it debuilder /build/make_deb.sh $branch || exit docker cp debuilder:/build/ . @@ -42,4 +38,7 @@ rm -rf ./build/ rm *dbgsym* +rm ./make_deb.sh +rm ./*.zip + chown "$USER:$USER" *.deb diff --git a/tools/deb-armv7l/Dockerfile b/tools/deb-armv7l/Dockerfile index f883eb9..330e072 100644 --- a/tools/deb-armv7l/Dockerfile +++ b/tools/deb-armv7l/Dockerfile @@ -1,12 +1,15 @@ -FROM raspbian/stretch:latest +FROM arm32v7/debian:buster WORKDIR /build -RUN apt-get update \ - && apt-get install -y git gcc g++ cmake \ - && apt-get install -y automake autotools-dev autoconf m4 zlib1g-dev cmake libtool libssl-dev \ - && apt-get install -y devscripts debhelper +ENV TZ=Europe/Belgrade +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN apt update +RUN apt install -y git gcc g++ cmake automake autotools-dev autoconf m4 zlib1g-dev \ + cmake libtool libssl-dev devscripts debhelper COPY make_deb.sh /build +COPY *.zip /build #CMD ["bash", "make_deb.sh"] diff --git a/tools/deb-armv7l/build-image-armv7l.sh b/tools/deb-armv7l/build-image-armv7l.sh index 10a599f..6b0e276 100755 --- a/tools/deb-armv7l/build-image-armv7l.sh +++ b/tools/deb-armv7l/build-image-armv7l.sh @@ -15,15 +15,11 @@ # limitations under the License. # -if [ "$EUID" -ne 0 ]; then - echo "Please run as sudo." - exit -fi - -sudo apt-get install qemu binfmt-support qemu-user-static +echo "If something doesn\'t work, install the dependencies: 'apt-get install qemu qemu-user-static binfmt-support'" docker run --rm --privileged multiarch/qemu-user-static --reset -p yes cp ../make_deb.sh . +cp ../*.zip . docker build -t wolkabout:wg-armv7l . rm make_deb.sh diff --git a/tools/deb-armv7l/run-armv7l.sh b/tools/deb-armv7l/run-armv7l.sh index cfd7972..4540658 100755 --- a/tools/deb-armv7l/run-armv7l.sh +++ b/tools/deb-armv7l/run-armv7l.sh @@ -15,11 +15,6 @@ # limitations under the License. # -if [ "$EUID" -ne 0 ]; then - echo "Please run as sudo." - exit -fi - ./build-image-armv7l.sh docker container stop debuilder @@ -31,6 +26,7 @@ if [ $? -eq 1 ]; then fi docker run -dit --name debuilder --cpus $(nproc) wolkabout:wg-armv7l || exit +docker exec -it debuilder unzip /build/*.zip -d WolkGateway || exit docker exec -it debuilder /build/make_deb.sh $branch || exit docker cp debuilder:/build/ . @@ -42,4 +38,7 @@ rm -rf ./build/ rm *dbgsym* +rm ./make_deb.sh +rm ./*.zip + chown "$USER:$USER" *.deb diff --git a/tools/make_deb.sh b/tools/make_deb.sh index 748db52..f9225ed 100755 --- a/tools/make_deb.sh +++ b/tools/make_deb.sh @@ -1,31 +1,4 @@ #!/bin/bash -# -# Copyright 2020 WolkAbout Technology s.r.o. -# -# 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. -# -# This script is used to make a release .deb file for WolkGateway release - -if [ $# -eq 1 ]; then - branch=$1 -else - branch=$(git rev-parse --abbrev-ref HEAD) - - if [ "$branch" == "" ]; then - echo "You must specify a branch as parameter to the script (if the script is not part of a repo)" - exit - fi -fi if [ $(dpkg -l | grep -c devscripts) -lt 1 ]; then if [ "$EUID" -ne 0 ]; then @@ -45,20 +18,6 @@ if [ $(dpkg -l | grep -c debhelper) -lt 1 ]; then apt install -y debhelper fi -rm -rf ./tmp-wg-deb -mkdir -p ./tmp-wg-deb -cd ./tmp-wg-deb || exit -git clone https://github.com/Wolkabout/WolkGateway --recurse-submodules cd ./WolkGateway || exit -git checkout "$branch" -if [ $? -ne 0 ]; then - echo "Can't checkout to branch named $branch" - exit -fi -git submodule update -ls + debuild -us -uc -b -j$(nproc) -cd ../ -mv *.deb .. -cd ../ -rm -rf ./tmp-wg-deb diff --git a/tools/make_release.sh b/tools/make_release.sh index b36639c..ff16f56 100755 --- a/tools/make_release.sh +++ b/tools/make_release.sh @@ -15,16 +15,10 @@ # limitations under the License. # -if [ "$EUID" -ne 0 ]; then - echo "Please run as sudo." - exit -fi - filename="release-v$(cat ../RELEASE_NOTES.txt | grep "**Version" | head -1 | sed -e "s/**Version //" | sed -e "s/\*\*//")" mkdir -p ./"$filename" ./make_zip.sh -mv *.zip "$filename" cd ./deb-amd64 || exit ./run-amd64.sh @@ -41,5 +35,4 @@ cd ./deb-arm64 || exit mv *.deb ../"$filename"/ cd .. -cd "$filename" || exit -chown "$USER:$USER" * +mv *.zip "$filename" diff --git a/tools/make_zip.sh b/tools/make_zip.sh index f82cefe..a7587dd 100755 --- a/tools/make_zip.sh +++ b/tools/make_zip.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# This script is used to make a release .zip file for WolkGatewayModule-Modbus release +# This script is used to make a release .zip file for WolkGateway release if [ $# -eq 1 ]; then branch=$1 @@ -45,6 +45,11 @@ if [ $? -ne 0 ]; then echo "Can't checkout to branch named $branch" exit fi +git submodule update --recursive +cd ./WolkSDK-Cpp || exit +git submodule init +git submodule update +cd .. || exit filename="WolkGateway-v$(cat RELEASE_NOTES.txt | grep "**Version" | head -1 | sed -e "s/**Version //" | sed -e "s/\*\*//").zip" echo "filename: $filename" zip -qr $filename *