From 7f224658e0b3b0fb4799ffa44a943792d08bce41 Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Tue, 21 Apr 2020 15:05:13 +0300 Subject: [PATCH 1/8] *: moved docker files to the packaging folder --- .travis.yml | 2 +- Makefile | 8 ++++++++ build_docker.sh | 2 +- release.sh => build_release.sh | 0 Dockerfile => packaging/docker/Dockerfile | 0 packaging/docker/Dockerfile.hub | 23 +++++++++++++++++++++++ packaging/docker/README.md | 6 ++++++ 7 files changed, 39 insertions(+), 2 deletions(-) rename release.sh => build_release.sh (100%) rename Dockerfile => packaging/docker/Dockerfile (100%) create mode 100644 packaging/docker/Dockerfile.hub create mode 100644 packaging/docker/README.md diff --git a/.travis.yml b/.travis.yml index fd369c2e..d6fc01cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -86,7 +86,7 @@ matrix: - node -v - npm -v # Prepare releases - - ./release.sh + - ./build_release.sh - ls -l dist deploy: diff --git a/Makefile b/Makefile index 74934562..ff32c957 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,9 @@ GOPATH := $(shell go env GOPATH) JSFILES = $(shell find client -path client/node_modules -prune -o -type f -name '*.js') STATIC = build/static/index.html CHANNEL ?= release +DOCKER_IMAGE_DEV_NAME=adguardhome-dev +DOCKERFILE=packaging/docker/Dockerfile +DOCKERFILE_HUB=packaging/docker/Dockerfile.travis TARGET=AdGuardHome @@ -26,6 +29,11 @@ $(TARGET): $(STATIC) *.go home/*.go dhcpd/*.go dnsfilter/*.go dnsforward/*.go CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(GIT_VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)" -asmflags="-trimpath=$(PWD)" -gcflags="-trimpath=$(PWD)" PATH=$(GOPATH)/bin:$(PATH) packr clean +docker: + docker build -t "$(DOCKER_IMAGE_DEV_NAME)" -f "$(DOCKERFILE)" . + @echo Now you can run the docker image: + @echo docker run --name "$(DOCKER_IMAGE_DEV_NAME)" -p 53:53/tcp -p 53:53/udp -p 3000:3000/tcp $(DOCKER_IMAGE_DEV_NAME) + clean: $(MAKE) cleanfast rm -rf build diff --git a/build_docker.sh b/build_docker.sh index 1123d269..81173574 100755 --- a/build_docker.sh +++ b/build_docker.sh @@ -4,7 +4,7 @@ set -eE set -o pipefail set -x -DOCKERFILE="Dockerfile.travis" +DOCKERFILE="packaging/docker/Dockerfile.hub" IMAGE_NAME="adguard/adguardhome" if [[ "${TRAVIS_BRANCH}" == "master" ]] diff --git a/release.sh b/build_release.sh similarity index 100% rename from release.sh rename to build_release.sh diff --git a/Dockerfile b/packaging/docker/Dockerfile similarity index 100% rename from Dockerfile rename to packaging/docker/Dockerfile diff --git a/packaging/docker/Dockerfile.hub b/packaging/docker/Dockerfile.hub new file mode 100644 index 00000000..0e11574e --- /dev/null +++ b/packaging/docker/Dockerfile.hub @@ -0,0 +1,23 @@ +FROM alpine:latest +LABEL maintainer="AdGuard Team " + +# Update CA certs +RUN apk --no-cache --update add ca-certificates libcap && \ + rm -rf /var/cache/apk/* && \ + mkdir -p /opt/adguardhome/conf /opt/adguardhome/work && \ + chown -R nobody: /opt/adguardhome + +COPY --chown=nobody:nogroup ./AdGuardHome /opt/adguardhome/AdGuardHome + +RUN setcap 'cap_net_bind_service=+eip' /opt/adguardhome/AdGuardHome + +EXPOSE 53/tcp 53/udp 67/udp 68/udp 80/tcp 443/tcp 853/tcp 3000/tcp + +VOLUME ["/opt/adguardhome/conf", "/opt/adguardhome/work"] + +WORKDIR /opt/adguardhome/work + +#USER nobody + +ENTRYPOINT ["/opt/adguardhome/AdGuardHome"] +CMD ["-h", "0.0.0.0", "-c", "/opt/adguardhome/conf/AdGuardHome.yaml", "-w", "/opt/adguardhome/work", "--no-check-update"] diff --git a/packaging/docker/README.md b/packaging/docker/README.md new file mode 100644 index 00000000..d44ec143 --- /dev/null +++ b/packaging/docker/README.md @@ -0,0 +1,6 @@ +## Docker images + +* `Dockerfile` is used for local development. Build it using `make docker` command. + +* `Dockerfile.huub` is used to publish AdGuard images to Docker Hub: https://hub.docker.com/r/adguard/adguardhome + Check out `build_docker.sh` for the details. \ No newline at end of file From 0cb876a71c6c9460263b9d92661e5f7aac5a393a Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Tue, 21 Apr 2020 16:25:29 +0300 Subject: [PATCH 2/8] *: added snapcraft build configuration --- .travis.yml | 16 ++++++- build_snap.sh | 81 +++++++++++++++++++++++++++++++++++ packaging/snap/README.md | 5 +++ packaging/snap/snapcraft.yaml | 31 ++++++++++++++ 4 files changed, 132 insertions(+), 1 deletion(-) create mode 100755 build_snap.sh create mode 100644 packaging/snap/README.md create mode 100644 packaging/snap/snapcraft.yaml diff --git a/.travis.yml b/.travis.yml index d6fc01cc..a4f01db4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -118,4 +118,18 @@ matrix: - docker login -u="$DOCKER_USER" -p="$DOCKER_PASSWORD" - ./build_docker.sh after_script: - - docker images + - docker images + + # Snapcraft build configuration + - if: repo = AdguardTeam/AdGuardHome + - name: snapcraft + # if: type != pull_request AND (branch = master OR tag IS present) AND repo = AdguardTeam/AdGuardHome + if: branch = snapcraft + go: + - 1.14.x + os: + - linux + services: + - docker + script: + - ./build_snap.sh diff --git a/build_snap.sh b/build_snap.sh new file mode 100755 index 00000000..2d305a52 --- /dev/null +++ b/build_snap.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +set -eE +set -o pipefail +set -x + +BUILDER_IMAGE="adguard/snapcraft:1.0" +SNAPCRAFT_TMPL="packaging/snap/snapcraft.yaml" +SNAP_NAME="adguardhometest" +VERSION=`git describe --abbrev=4 --dirty --always --tags` + +if [[ "${TRAVIS_BRANCH}" == "master" ]] +then + CHANNEL="edge" +else + CHANNEL="release" +fi + +# Launchpad oauth tokens data is necessary to run snapcraft remote-build +# +# Here's an instruction on how to generate launchpad OAuth tokens: +# https://uci.readthedocs.io/en/latest/oauth.html +# +# Launchpad credentials are necessary to run snapcraft remote-build command +echo "[1] +consumer_key = ${LAUNCHPAD_KEY} +consumer_secret = +access_token = ${LAUNCHPAD_ACCESS_TOKEN} +access_secret = ${LAUNCHPAD_ACCESS_SECRET} +" > launchpad_credentials + +# Snapcraft login data +# It can be exported using snapcraft export-login command +echo "[login.ubuntu.com] +macaroon = ${SNAPCRAFT_MACAROON} +unbound_discharge = ${SNAPCRAFT_UBUNTU_DISCHARGE} +email = ${SNAPCRAFT_EMAIL}" > snapcraft_login + +# Prepare the snap configuration +cp ${SNAPCRAFT_TMPL} ./snapcraft.yaml +sed -i.bak 's/dev_version/'"${VERSION}"'/g' ./snapcraft.yaml + +build_snap() { + # Run the build + docker run -it -v $(pwd):/build \ + -v $(pwd)/launchpad_credentials:/root/.local/share/snapcraft/provider/launchpad/credentials:ro \ + ${BUILDER_IMAGE} \ + snapcraft remote-build --build-on=${ARCH} --launchpad-accept-public-upload +} + +publish_snap() { + # Check that the snap file exists + snapFile="${SNAP_NAME}_${VERSION}_${ARCH}.snap" + if [ ! -f ${snapFile} ]; then + echo "Snap file ${snapFile} not found!" + exit 1 + fi + + # Login and publish the snap + docker run -it -v $(pwd):/build \ + ${BUILDER_IMAGE} \ + sh -c "snapcraft login --with=/build/snapcraft_login && snapcraft push --release=${CHANNEL} /build/${snapFile}" +} + +# Build snaps +ARCH=i386 build_snap +ARCH=arm64 build_snap +ARCH=armhf build_snap +ARCH=amd64 build_snap + +# Publish snaps +ARCH=i386 publish_snap +ARCH=arm64 publish_snap +ARCH=armhf publish_snap +ARCH=amd64 publish_snap + +# Clean up +rm launchpad_credentials +rm snapcraft.yaml +rm snapcraft.yaml.bak +rm snapcraft_login \ No newline at end of file diff --git a/packaging/snap/README.md b/packaging/snap/README.md new file mode 100644 index 00000000..764100ff --- /dev/null +++ b/packaging/snap/README.md @@ -0,0 +1,5 @@ +## Snapcraft + +Configuration for our snap. + +Check out `build_snap.sh` for more details. \ No newline at end of file diff --git a/packaging/snap/snapcraft.yaml b/packaging/snap/snapcraft.yaml new file mode 100644 index 00000000..ba7a47d0 --- /dev/null +++ b/packaging/snap/snapcraft.yaml @@ -0,0 +1,31 @@ +name: adguardhometest +base: core18 +version: 'dev_version' +summary: Network-wide ads & trackers blocking DNS server +description: | + AdGuard Home is a network-wide software for blocking ads & tracking. After + you set it up, it'll cover ALL your home devices, and you don't need any + client-side software for that. + It operates as a DNS server that re-routes tracking domains to a "black hole," + thus preventing your devices from connecting to those servers. It's based + on software we use for our public AdGuard DNS servers -- both share a lot + of common code. +grade: stable +confinement: strict + +parts: + adguard-home: + plugin: make + source: . + build-snaps: [ node/13/stable, go ] + build-packages: [ git, build-essential ] + override-build: | + make clean + make + cp AdGuardHome ${SNAPCRAFT_PART_INSTALL}/ +apps: + adguard-home: + command: AdGuardHome -c ${SNAP_COMMON}/AdGuardHome.yaml -w ${SNAP_DATA} --no-check-update + plugs: [ network-bind ] + daemon: simple + restart-condition: always \ No newline at end of file From 3fdd3f7cec9f75433c1ed2ea30dd023980092ffc Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Tue, 21 Apr 2020 17:23:29 +0300 Subject: [PATCH 3/8] *: travis - print log on failuer --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index a4f01db4..39a7bf28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -133,3 +133,6 @@ matrix: - docker script: - ./build_snap.sh + after_failure: + # replace snap name + - cat adguardhometest_*.txt \ No newline at end of file From 3ae6043748bb9c396723f83a8206426908bf5ba7 Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Wed, 22 Apr 2020 13:40:13 +0300 Subject: [PATCH 4/8] *: remove snap from travis --- .travis.yml | 17 ----------------- build_snap.sh | 12 ++++++++++-- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 39a7bf28..b2e5a2dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -119,20 +119,3 @@ matrix: - ./build_docker.sh after_script: - docker images - - # Snapcraft build configuration - - if: repo = AdguardTeam/AdGuardHome - - name: snapcraft - # if: type != pull_request AND (branch = master OR tag IS present) AND repo = AdguardTeam/AdGuardHome - if: branch = snapcraft - go: - - 1.14.x - os: - - linux - services: - - docker - script: - - ./build_snap.sh - after_failure: - # replace snap name - - cat adguardhometest_*.txt \ No newline at end of file diff --git a/build_snap.sh b/build_snap.sh index 2d305a52..89da6fbe 100755 --- a/build_snap.sh +++ b/build_snap.sh @@ -16,6 +16,12 @@ else CHANNEL="release" fi +# If bash is interactive, set `-it` parameter for docker run +INTERACTIVE="" +if [ -t 0 ] ; then + INTERACTIVE="-it" +fi + # Launchpad oauth tokens data is necessary to run snapcraft remote-build # # Here's an instruction on how to generate launchpad OAuth tokens: @@ -42,7 +48,8 @@ sed -i.bak 's/dev_version/'"${VERSION}"'/g' ./snapcraft.yaml build_snap() { # Run the build - docker run -it -v $(pwd):/build \ + docker run ${INTERACTIVE} --rm \ + -v $(pwd):/build \ -v $(pwd)/launchpad_credentials:/root/.local/share/snapcraft/provider/launchpad/credentials:ro \ ${BUILDER_IMAGE} \ snapcraft remote-build --build-on=${ARCH} --launchpad-accept-public-upload @@ -57,7 +64,8 @@ publish_snap() { fi # Login and publish the snap - docker run -it -v $(pwd):/build \ + docker run ${INTERACTIVE} --rm \ + -v $(pwd):/build \ ${BUILDER_IMAGE} \ sh -c "snapcraft login --with=/build/snapcraft_login && snapcraft push --release=${CHANNEL} /build/${snapFile}" } From 093617e6bd4e64f3c9a5df740af286623473e301 Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Wed, 22 Apr 2020 15:07:17 +0300 Subject: [PATCH 5/8] *: update build_snap.sh --- build_snap.sh | 228 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 190 insertions(+), 38 deletions(-) diff --git a/build_snap.sh b/build_snap.sh index 89da6fbe..49e05071 100755 --- a/build_snap.sh +++ b/build_snap.sh @@ -7,6 +7,7 @@ set -x BUILDER_IMAGE="adguard/snapcraft:1.0" SNAPCRAFT_TMPL="packaging/snap/snapcraft.yaml" SNAP_NAME="adguardhometest" +LAUNCHPAD_CREDENTIALS_DIR=".local/share/snapcraft/provider/launchpad" VERSION=`git describe --abbrev=4 --dirty --always --tags` if [[ "${TRAVIS_BRANCH}" == "master" ]] @@ -22,40 +23,127 @@ if [ -t 0 ] ; then INTERACTIVE="-it" fi -# Launchpad oauth tokens data is necessary to run snapcraft remote-build -# -# Here's an instruction on how to generate launchpad OAuth tokens: -# https://uci.readthedocs.io/en/latest/oauth.html -# -# Launchpad credentials are necessary to run snapcraft remote-build command -echo "[1] -consumer_key = ${LAUNCHPAD_KEY} -consumer_secret = -access_token = ${LAUNCHPAD_ACCESS_TOKEN} -access_secret = ${LAUNCHPAD_ACCESS_SECRET} -" > launchpad_credentials +function usage() { + cat < snapcraft_login + Please note that in order for the builds to work properly, you need to setup some env variables. -# Prepare the snap configuration -cp ${SNAPCRAFT_TMPL} ./snapcraft.yaml -sed -i.bak 's/dev_version/'"${VERSION}"'/g' ./snapcraft.yaml + These are necessary for "remote-build' command. + Read this doc on how to generate them: https://uci.readthedocs.io/en/latest/oauth.html + + * LAUNCHPAD_KEY -- launchpad CI key + * LAUNCHPAD_ACCESS_TOKEN -- launchpad access token + * LAUNCHPAD_ACCESS_SECRET -- launchpad access secret + + These are necessary for snapcraft publish command to work. + They can be exported using "snapcraft export-login" + + * SNAPCRAFT_MACAROON + * SNAPCRAFT_UBUNTU_DISCHARGE + * SNAPCRAFT_EMAIL + + Examples: + ${0##*/} build-docker - builds snaps using remote-build inside a Docker environment + ${0##*/} build - builds snaps using remote-build + ${0##*/} publish-docker-beta - publishes snaps to the beta channel using Docker environment + ${0##*/} publish-docker-release - publishes snaps to the release channel using Docker environment + ${0##*/} publish-beta - publishes snaps to the beta channel + ${0##*/} publish-release - publishes snaps to the release channel + ${0##*/} cleanup - clean up temporary files that were created by the builds +EOF + exit 1 +} + +####################################### +# helper functions +####################################### + +function prepare() { + # Launchpad oauth tokens data is necessary to run snapcraft remote-build + # + # Here's an instruction on how to generate launchpad OAuth tokens: + # https://uci.readthedocs.io/en/latest/oauth.html + # + # Launchpad credentials are necessary to run snapcraft remote-build command + echo "[1] + consumer_key = ${LAUNCHPAD_KEY} + consumer_secret = + access_token = ${LAUNCHPAD_ACCESS_TOKEN} + access_secret = ${LAUNCHPAD_ACCESS_SECRET} + " > launchpad_credentials + + # Snapcraft login data + # It can be exported using snapcraft export-login command + echo "[login.ubuntu.com] + macaroon = ${SNAPCRAFT_MACAROON} + unbound_discharge = ${SNAPCRAFT_UBUNTU_DISCHARGE} + email = ${SNAPCRAFT_EMAIL}" > snapcraft_login + + # Prepare the snap configuration + cp ${SNAPCRAFT_TMPL} ./snapcraft.yaml + sed -i.bak 's/dev_version/'"${VERSION}"'/g' ./snapcraft.yaml + rm -f snapcraft.yaml.bak +} build_snap() { - # Run the build + # prepare credentials + prepare + + # copy them to the directory where snapcraft will be able to read them + mkdir -p ~/${LAUNCHPAD_CREDENTIALS_DIR} + cp -f snapcraft_login ~/${LAUNCHPAD_CREDENTIALS_DIR}/credentials + chmod 600 ~/${LAUNCHPAD_CREDENTIALS_DIR}/credentials + + # run the build + snapcraft remote-build --build-on=${ARCH} --launchpad-accept-public-upload + + # remove the credentials - we don't need them anymore + rm -rf ~/${LAUNCHPAD_CREDENTIALS_DIR} + + # cleanup credentials + cleanup +} + +build_snap_docker() { + # prepare credentials + prepare + docker run ${INTERACTIVE} --rm \ -v $(pwd):/build \ - -v $(pwd)/launchpad_credentials:/root/.local/share/snapcraft/provider/launchpad/credentials:ro \ + -v $(pwd)/launchpad_credentials:/root/${LAUNCHPAD_CREDENTIALS_DIR}/credentials:ro \ ${BUILDER_IMAGE} \ snapcraft remote-build --build-on=${ARCH} --launchpad-accept-public-upload + + # cleanup credentials + cleanup } publish_snap() { + # prepare credentials + prepare + + # Check that the snap file exists + snapFile="${SNAP_NAME}_${VERSION}_${ARCH}.snap" + if [ ! -f ${snapFile} ]; then + echo "Snap file ${snapFile} not found!" + exit 1 + fi + + # Login if necessary + snapcraft login --with=snapcraft_login + + # Push to the channel + snapcraft push --release=${CHANNEL} ${snapFile} + + # cleanup credentials + cleanup +} + +publish_snap_docker() { + # prepare credentials + prepare + # Check that the snap file exists snapFile="${SNAP_NAME}_${VERSION}_${ARCH}.snap" if [ ! -f ${snapFile} ]; then @@ -68,22 +156,86 @@ publish_snap() { -v $(pwd):/build \ ${BUILDER_IMAGE} \ sh -c "snapcraft login --with=/build/snapcraft_login && snapcraft push --release=${CHANNEL} /build/${snapFile}" + + # cleanup credentials + cleanup } -# Build snaps -ARCH=i386 build_snap -ARCH=arm64 build_snap -ARCH=armhf build_snap -ARCH=amd64 build_snap +####################################### +# main functions +####################################### -# Publish snaps -ARCH=i386 publish_snap -ARCH=arm64 publish_snap -ARCH=armhf publish_snap -ARCH=amd64 publish_snap +build() { + ARCH=i386 build_snap + ARCH=arm64 build_snap + ARCH=armhf build_snap + ARCH=amd64 build_snap +} -# Clean up -rm launchpad_credentials -rm snapcraft.yaml -rm snapcraft.yaml.bak -rm snapcraft_login \ No newline at end of file +build_docker() { + ARCH=i386 build_snap_docker + ARCH=arm64 build_snap_docker + ARCH=armhf build_snap_docker + ARCH=amd64 build_snap_docker +} + +publish_docker() { + if [[ -z $1 ]]; then + echo "No channel specified" + exit 1 + fi + CHANNEL="${1}" + if [ "$CHANNEL" != "release" ] && [ "$CHANNEL" != "beta" ]; then + echo "$CHANNEL is an invalid value for the update channel!" + exit 1 + fi + + ARCH=i386 publish_snap_docker + ARCH=arm64 publish_snap_docker + ARCH=armhf publish_snap_docker + ARCH=amd64 publish_snap_docker +} + +publish() { + if [[ -z $1 ]]; then + echo "No channel specified" + exit 1 + fi + CHANNEL="${1}" + if [ "$CHANNEL" != "release" ] && [ "$CHANNEL" != "beta" ]; then + echo "$CHANNEL is an invalid value for the update channel!" + exit 1 + fi + + ARCH=i386 publish_snap + ARCH=arm64 publish_snap + ARCH=armhf publish_snap + ARCH=amd64 publish_snap +} + +cleanup() { + rm -f launchpad_credentials + rm -f snapcraft.yaml + rm -f snapcraft.yaml.bak + rm -f snapcraft_login +} + +####################################### +# main +####################################### +if [[ -z $1 || $1 == "--help" || $1 == "-h" ]]; then + usage +fi + +case "$1" in +"build-docker") build_docker ;; +"build") build ;; +"publish-docker-beta") publish_docker beta ;; +"publish-docker-release") publish_docker release ;; +"publish-beta") publish beta ;; +"publish-release") publish release ;; +"cleanup") cleanup ;; +*) usage ;; +esac + +exit 0 \ No newline at end of file From daf9af9a224931135863a8be9ba46545148fd372 Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Wed, 22 Apr 2020 17:48:37 +0300 Subject: [PATCH 6/8] *: rename resulting snapfile -- remove version from it --- build_snap.sh | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/build_snap.sh b/build_snap.sh index 49e05071..4e9a00bd 100755 --- a/build_snap.sh +++ b/build_snap.sh @@ -8,13 +8,10 @@ BUILDER_IMAGE="adguard/snapcraft:1.0" SNAPCRAFT_TMPL="packaging/snap/snapcraft.yaml" SNAP_NAME="adguardhometest" LAUNCHPAD_CREDENTIALS_DIR=".local/share/snapcraft/provider/launchpad" -VERSION=`git describe --abbrev=4 --dirty --always --tags` -if [[ "${TRAVIS_BRANCH}" == "master" ]] -then - CHANNEL="edge" -else - CHANNEL="release" +if [[ -z ${VERSION} ]]; then + VERSION=`git describe --abbrev=4 --dirty --always --tags` + echo "VERSION env variable is not set, getting it from git: ${VERSION}" fi # If bash is interactive, set `-it` parameter for docker run @@ -60,6 +57,18 @@ EOF ####################################### function prepare() { + if [ -z ${LAUNCHPAD_KEY} ] || [ -z ${LAUNCHPAD_ACCESS_TOKEN} ] || [ -z ${LAUNCHPAD_ACCESS_SECRET} ]; then + echo "Launchpad oauth tokens are not set, exiting" + usage + exit 1 + fi + + if [ -z ${SNAPCRAFT_MACAROON} ] || [ -z ${SNAPCRAFT_UBUNTU_DISCHARGE} ] || [ -z ${SNAPCRAFT_EMAIL} ]; then + echo "Snapcraft auth params are not set, exiting" + usage + exit 1 + fi + # Launchpad oauth tokens data is necessary to run snapcraft remote-build # # Here's an instruction on how to generate launchpad OAuth tokens: @@ -101,6 +110,9 @@ build_snap() { # remove the credentials - we don't need them anymore rm -rf ~/${LAUNCHPAD_CREDENTIALS_DIR} + # remove version from the file name + rename_snap_file + # cleanup credentials cleanup } @@ -115,16 +127,33 @@ build_snap_docker() { ${BUILDER_IMAGE} \ snapcraft remote-build --build-on=${ARCH} --launchpad-accept-public-upload + # remove version from the file name + rename_snap_file + # cleanup credentials cleanup } +rename_snap_file() { + # In order to make working with snaps easier later on + # we remove version from the file name + + # Check that the snap file exists + snapFile="${SNAP_NAME}_${VERSION}_${ARCH}.snap" + if [ ! -f ${snapFile} ]; then + echo "Snap file ${snapFile} not found!" + exit 1 + fi + + mv -f ${snapFile} "${SNAP_NAME}_${ARCH}.snap" +} + publish_snap() { # prepare credentials prepare # Check that the snap file exists - snapFile="${SNAP_NAME}_${VERSION}_${ARCH}.snap" + snapFile="${SNAP_NAME}_${ARCH}.snap" if [ ! -f ${snapFile} ]; then echo "Snap file ${snapFile} not found!" exit 1 @@ -145,7 +174,7 @@ publish_snap_docker() { prepare # Check that the snap file exists - snapFile="${SNAP_NAME}_${VERSION}_${ARCH}.snap" + snapFile="${SNAP_NAME}_${ARCH}.snap" if [ ! -f ${snapFile} ]; then echo "Snap file ${snapFile} not found!" exit 1 From 47160c16d9f5c2226f33af52a503e5826c1748ec Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Wed, 22 Apr 2020 18:39:47 +0300 Subject: [PATCH 7/8] *: cleanup --- build_snap.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build_snap.sh b/build_snap.sh index 4e9a00bd..8879fd22 100755 --- a/build_snap.sh +++ b/build_snap.sh @@ -57,13 +57,13 @@ EOF ####################################### function prepare() { - if [ -z ${LAUNCHPAD_KEY} ] || [ -z ${LAUNCHPAD_ACCESS_TOKEN} ] || [ -z ${LAUNCHPAD_ACCESS_SECRET} ]; then + if [ -z "${LAUNCHPAD_KEY}" ] || [ -z "${LAUNCHPAD_ACCESS_TOKEN}" ] || [ -z "${LAUNCHPAD_ACCESS_SECRET}" ]; then echo "Launchpad oauth tokens are not set, exiting" usage exit 1 fi - if [ -z ${SNAPCRAFT_MACAROON} ] || [ -z ${SNAPCRAFT_UBUNTU_DISCHARGE} ] || [ -z ${SNAPCRAFT_EMAIL} ]; then + if [ -z "${SNAPCRAFT_MACAROON}" ] || [ -z "${SNAPCRAFT_UBUNTU_DISCHARGE}" ] || [ -z "${SNAPCRAFT_EMAIL}" ]; then echo "Snapcraft auth params are not set, exiting" usage exit 1 From 054980bc8b9cab4ac8dd5421d724f421cd046583 Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Wed, 22 Apr 2020 18:50:24 +0300 Subject: [PATCH 8/8] *: fix typo --- packaging/docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/docker/README.md b/packaging/docker/README.md index d44ec143..0d7ff06f 100644 --- a/packaging/docker/README.md +++ b/packaging/docker/README.md @@ -2,5 +2,5 @@ * `Dockerfile` is used for local development. Build it using `make docker` command. -* `Dockerfile.huub` is used to publish AdGuard images to Docker Hub: https://hub.docker.com/r/adguard/adguardhome +* `Dockerfile.hub` is used to publish AdGuard images to Docker Hub: https://hub.docker.com/r/adguard/adguardhome Check out `build_docker.sh` for the details. \ No newline at end of file