aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlo Landmeter <clandmeter@alpinelinux.org>2019-02-19 15:22:53 +0000
committerCarlo Landmeter <clandmeter@alpinelinux.org>2019-02-19 15:22:53 +0000
commit142bcd67b1931cb519818a856524de4791918e2a (patch)
tree4aac0b34177f483ff180e38a4283fdcf000ff92e
downloadalpine-drone-ci-142bcd67b1931cb519818a856524de4791918e2a.tar.bz2
alpine-drone-ci-142bcd67b1931cb519818a856524de4791918e2a.tar.xz
initial commit
-rw-r--r--.drone.yml200
-rw-r--r--LICENSE21
-rw-r--r--README.md4
-rw-r--r--dockerfiles/edge/aarch64/Dockerfile11
-rw-r--r--dockerfiles/edge/armhf/Dockerfile11
-rw-r--r--dockerfiles/edge/armv7/Dockerfile14
-rw-r--r--dockerfiles/edge/armv7/arch1
-rw-r--r--dockerfiles/edge/x86/Dockerfile11
-rw-r--r--dockerfiles/edge/x86_64/Dockerfile11
-rw-r--r--dockerfiles/v3.9/aarch64/Dockerfile11
-rw-r--r--dockerfiles/v3.9/armhf/Dockerfile11
-rw-r--r--dockerfiles/v3.9/armv7/Dockerfile14
-rw-r--r--dockerfiles/v3.9/armv7/arch1
-rw-r--r--dockerfiles/v3.9/x86/Dockerfile11
-rw-r--r--dockerfiles/v3.9/x86_64/Dockerfile11
-rw-r--r--files/etc/apk/repositories0
-rw-r--r--files/etc/skel/.abuild/abuild.conf3
-rw-r--r--files/etc/sudoers.d/wheel1
-rwxr-xr-xscripts/build.sh129
-rwxr-xr-xscripts/setup.sh18
20 files changed, 494 insertions, 0 deletions
diff --git a/.drone.yml b/.drone.yml
new file mode 100644
index 0000000..6fe2e63
--- /dev/null
+++ b/.drone.yml
@@ -0,0 +1,200 @@
+---
+kind: pipeline
+name: edge-x86
+
+platform:
+ os: linux
+ arch: amd64
+
+steps:
+ - name: publish
+ image: plugins/docker
+ settings:
+ username:
+ from_secret: docker_user
+ password:
+ from_secret: docker_pass
+ repo: alpinelinux/alpine-drone-ci
+ tags: edge-x86
+ dockerfile: dockerfiles/edge/x86/Dockerfile
+
+---
+kind: pipeline
+name: v3.9-x86
+
+platform:
+ os: linux
+ arch: amd64
+
+steps:
+ - name: publish
+ image: plugins/docker
+ settings:
+ username:
+ from_secret: docker_user
+ password:
+ from_secret: docker_pass
+ repo: alpinelinux/alpine-drone-ci
+ tags: v3.9-x86
+ dockerfile: dockerfiles/v3.9/x86/Dockerfile
+
+---
+kind: pipeline
+name: edge-x86_64
+
+platform:
+ os: linux
+ arch: amd64
+
+steps:
+ - name: publish
+ image: plugins/docker
+ settings:
+ username:
+ from_secret: docker_user
+ password:
+ from_secret: docker_pass
+ repo: alpinelinux/alpine-drone-ci
+ tags: edge-x86_64
+ dockerfile: dockerfiles/edge/x86_64/Dockerfile
+
+---
+kind: pipeline
+name: v3.9-x86_64
+
+platform:
+ os: linux
+ arch: amd64
+
+steps:
+ - name: publish
+ image: plugins/docker
+ settings:
+ username:
+ from_secret: docker_user
+ password:
+ from_secret: docker_pass
+ repo: alpinelinux/alpine-drone-ci
+ tags: v3.9-x86_64
+ dockerfile: dockerfiles/v3.9/x86_64/Dockerfile
+
+---
+kind: pipeline
+name: edge-aarch64
+
+platform:
+ os: linux
+ arch: arm64
+
+steps:
+ - name: publish
+ image: plugins/docker
+ settings:
+ username:
+ from_secret: docker_user
+ password:
+ from_secret: docker_pass
+ repo: alpinelinux/alpine-drone-ci
+ tags: edge-aarch64
+ dockerfile: dockerfiles/edge/aarch64/Dockerfile
+
+---
+kind: pipeline
+name: v3.9-aarch64
+
+platform:
+ os: linux
+ arch: arm64
+
+steps:
+ - name: publish
+ image: plugins/docker
+ settings:
+ username:
+ from_secret: docker_user
+ password:
+ from_secret: docker_pass
+ repo: alpinelinux/alpine-drone-ci
+ tags: v3.9-aarch64
+ dockerfile: dockerfiles/v3.9/aarch64/Dockerfile
+
+---
+kind: pipeline
+name: edge-armhf
+
+platform:
+ os: linux
+ arch: arm
+
+steps:
+ - name: publish
+ image: plugins/docker
+ settings:
+ username:
+ from_secret: docker_user
+ password:
+ from_secret: docker_pass
+ repo: alpinelinux/alpine-drone-ci
+ tags: edge-armhf
+ dockerfile: dockerfiles/edge/armhf/Dockerfile
+
+---
+kind: pipeline
+name: v3.9-armhf
+
+platform:
+ os: linux
+ arch: arm
+
+steps:
+ - name: publish
+ image: plugins/docker
+ settings:
+ username:
+ from_secret: docker_user
+ password:
+ from_secret: docker_pass
+ repo: alpinelinux/alpine-drone-ci
+ tags: v3.9-armhf
+ dockerfile: dockerfiles/v3.9/armhf/Dockerfile
+
+---
+kind: pipeline
+name: edge-armv7
+
+platform:
+ os: linux
+ arch: arm
+
+steps:
+ - name: publish
+ image: plugins/docker
+ settings:
+ username:
+ from_secret: docker_user
+ password:
+ from_secret: docker_pass
+ repo: alpinelinux/alpine-drone-ci
+ tags: edge-armv7
+ dockerfile: dockerfiles/edge/armv7/Dockerfile
+
+---
+kind: pipeline
+name: v3.9-armv7
+
+platform:
+ os: linux
+ arch: arm
+
+steps:
+ - name: publish
+ image: plugins/docker
+ settings:
+ username:
+ from_secret: docker_user
+ password:
+ from_secret: docker_pass
+ repo: alpinelinux/alpine-drone-ci
+ tags: v3.9-armv7
+ dockerfile: dockerfiles/v3.9/armv7/Dockerfile
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..bffb2e3
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 Carlo Landmeter
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..9b471d6
--- /dev/null
+++ b/README.md
@@ -0,0 +1,4 @@
+# alpine-drone-ci
+Build Alpine Linux packages with drone CI
+
+[![Build Status](https://cloud.drone.io/api/badges/clandmeter/alpine-drone-ci/status.svg)](https://cloud.drone.io/clandmeter/alpine-drone-ci)
diff --git a/dockerfiles/edge/aarch64/Dockerfile b/dockerfiles/edge/aarch64/Dockerfile
new file mode 100644
index 0000000..9c0cbb1
--- /dev/null
+++ b/dockerfiles/edge/aarch64/Dockerfile
@@ -0,0 +1,11 @@
+FROM arm64v8/alpine:latest
+
+COPY scripts/*.sh /usr/local/bin/
+COPY files/etc/ /etc/
+
+RUN ["setup.sh", "edge" ]
+
+USER buildozer
+
+ENTRYPOINT [ "/bin/sh" ]
+
diff --git a/dockerfiles/edge/armhf/Dockerfile b/dockerfiles/edge/armhf/Dockerfile
new file mode 100644
index 0000000..c52f5e5
--- /dev/null
+++ b/dockerfiles/edge/armhf/Dockerfile
@@ -0,0 +1,11 @@
+FROM arm32v6/alpine:latest
+
+COPY scripts/*.sh /usr/local/bin/
+COPY files/etc/ /etc/
+
+RUN ["setup.sh", "edge" ]
+
+USER buildozer
+
+ENTRYPOINT [ "/bin/sh" ]
+
diff --git a/dockerfiles/edge/armv7/Dockerfile b/dockerfiles/edge/armv7/Dockerfile
new file mode 100644
index 0000000..29bc2fa
--- /dev/null
+++ b/dockerfiles/edge/armv7/Dockerfile
@@ -0,0 +1,14 @@
+FROM arm32v6/alpine:latest
+
+COPY scripts/*.sh /usr/local/bin/
+COPY files/etc/ /etc/
+
+# hack to force system to upgrade to armv7
+COPY dockerfiles/edge/armv7/arch /etc/apk/
+
+RUN ["setup.sh", "edge" ]
+
+USER buildozer
+
+ENTRYPOINT [ "/bin/sh" ]
+
diff --git a/dockerfiles/edge/armv7/arch b/dockerfiles/edge/armv7/arch
new file mode 100644
index 0000000..c9811b7
--- /dev/null
+++ b/dockerfiles/edge/armv7/arch
@@ -0,0 +1 @@
+armv7
diff --git a/dockerfiles/edge/x86/Dockerfile b/dockerfiles/edge/x86/Dockerfile
new file mode 100644
index 0000000..6d74529
--- /dev/null
+++ b/dockerfiles/edge/x86/Dockerfile
@@ -0,0 +1,11 @@
+FROM i386/alpine:latest
+
+COPY scripts/*.sh /usr/local/bin/
+COPY files/etc/ /etc/
+
+RUN ["setup.sh", "edge" ]
+
+USER buildozer
+
+ENTRYPOINT [ "/bin/sh" ]
+
diff --git a/dockerfiles/edge/x86_64/Dockerfile b/dockerfiles/edge/x86_64/Dockerfile
new file mode 100644
index 0000000..2f7fbd6
--- /dev/null
+++ b/dockerfiles/edge/x86_64/Dockerfile
@@ -0,0 +1,11 @@
+FROM amd64/alpine:latest
+
+COPY scripts/*.sh /usr/local/bin/
+COPY files/etc/ /etc/
+
+RUN ["setup.sh", "edge" ]
+
+USER buildozer
+
+ENTRYPOINT [ "/bin/sh" ]
+
diff --git a/dockerfiles/v3.9/aarch64/Dockerfile b/dockerfiles/v3.9/aarch64/Dockerfile
new file mode 100644
index 0000000..104717c
--- /dev/null
+++ b/dockerfiles/v3.9/aarch64/Dockerfile
@@ -0,0 +1,11 @@
+FROM arm64v8/alpine:3.9
+
+COPY scripts/*.sh /usr/local/bin/
+COPY files/etc/ /etc/
+
+RUN ["setup.sh", "v3.9" ]
+
+USER buildozer
+
+ENTRYPOINT [ "/bin/sh" ]
+
diff --git a/dockerfiles/v3.9/armhf/Dockerfile b/dockerfiles/v3.9/armhf/Dockerfile
new file mode 100644
index 0000000..a2f6165
--- /dev/null
+++ b/dockerfiles/v3.9/armhf/Dockerfile
@@ -0,0 +1,11 @@
+FROM arm32v6/alpine:3.9
+
+COPY scripts/*.sh /usr/local/bin/
+COPY files/etc/ /etc/
+
+RUN ["setup.sh", "v3.9" ]
+
+USER buildozer
+
+ENTRYPOINT [ "/bin/sh" ]
+
diff --git a/dockerfiles/v3.9/armv7/Dockerfile b/dockerfiles/v3.9/armv7/Dockerfile
new file mode 100644
index 0000000..394f9a4
--- /dev/null
+++ b/dockerfiles/v3.9/armv7/Dockerfile
@@ -0,0 +1,14 @@
+FROM arm32v6/alpine:3.9
+
+COPY scripts/*.sh /usr/local/bin/
+COPY files/etc/ /etc/
+
+# hack to force system to upgrade to armv7
+COPY dockerfiles/v3.9/armv7/arch /etc/apk/
+
+RUN ["setup.sh", "v3.9" ]
+
+USER buildozer
+
+ENTRYPOINT [ "/bin/sh" ]
+
diff --git a/dockerfiles/v3.9/armv7/arch b/dockerfiles/v3.9/armv7/arch
new file mode 100644
index 0000000..c9811b7
--- /dev/null
+++ b/dockerfiles/v3.9/armv7/arch
@@ -0,0 +1 @@
+armv7
diff --git a/dockerfiles/v3.9/x86/Dockerfile b/dockerfiles/v3.9/x86/Dockerfile
new file mode 100644
index 0000000..7fd95ec
--- /dev/null
+++ b/dockerfiles/v3.9/x86/Dockerfile
@@ -0,0 +1,11 @@
+FROM i386/alpine:3.9
+
+COPY scripts/*.sh /usr/local/bin/
+COPY files/etc/ /etc/
+
+RUN ["setup.sh", "v3.9" ]
+
+USER buildozer
+
+ENTRYPOINT [ "/bin/sh" ]
+
diff --git a/dockerfiles/v3.9/x86_64/Dockerfile b/dockerfiles/v3.9/x86_64/Dockerfile
new file mode 100644
index 0000000..0ce65a5
--- /dev/null
+++ b/dockerfiles/v3.9/x86_64/Dockerfile
@@ -0,0 +1,11 @@
+FROM amd64/alpine:3.9
+
+COPY scripts/*.sh /usr/local/bin/
+COPY files/etc/ /etc/
+
+RUN ["setup.sh", "v3.9" ]
+
+USER buildozer
+
+ENTRYPOINT [ "/bin/sh" ]
+
diff --git a/files/etc/apk/repositories b/files/etc/apk/repositories
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/files/etc/apk/repositories
diff --git a/files/etc/skel/.abuild/abuild.conf b/files/etc/skel/.abuild/abuild.conf
new file mode 100644
index 0000000..a5512b3
--- /dev/null
+++ b/files/etc/skel/.abuild/abuild.conf
@@ -0,0 +1,3 @@
+# buildozer abuild settings
+PACKAGER="buildozer <alpine-infra@lists.alpinelinux.org>"
+REPODEST="$HOME/drone/packages"
diff --git a/files/etc/sudoers.d/wheel b/files/etc/sudoers.d/wheel
new file mode 100644
index 0000000..7c499c2
--- /dev/null
+++ b/files/etc/sudoers.d/wheel
@@ -0,0 +1 @@
+%wheel ALL=(ALL) NOPASSWD: ALL
diff --git a/scripts/build.sh b/scripts/build.sh
new file mode 100755
index 0000000..a0324a0
--- /dev/null
+++ b/scripts/build.sh
@@ -0,0 +1,129 @@
+#!/bin/sh
+
+set -eu
+
+readonly APORTSDIR=$HOME/drone/aports
+readonly REPOS="main community testing"
+readonly MIRROR=http://dl-cdn.alpinelinux.org/alpine
+
+msg() {
+ local color=${2:-green}
+ case "$color" in
+ red) color="31";;
+ green) color="32";;
+ yellow) color="33";;
+ blue) color="34";;
+ *) color="32";;
+ esac
+ printf "\033[1;%sm>>>\033[1;0m %s\n" "$color" "$1" | xargs >&2
+}
+
+die() {
+ msg "$1" red
+ exit 1
+}
+
+get_release() {
+ local branch=$DRONE_COMMIT_BRANCH
+ case $branch in
+ *-stable) echo v${branch%-*};;
+ master) echo edge;;
+ *) die "Branch \"$branch\" not supported!"
+ esac
+}
+
+build_aport() {
+ local repo="$1" aport="$2"
+ cd "$APORTSDIR/$repo/$aport"
+ sudo chown buildozer .
+ abuild -r
+}
+
+changed_repos() {
+ local repo= range="$1"
+ cd "$APORTSDIR"
+ for repo in $REPOS; do
+ git diff --exit-code $range -- $repo >/dev/null \
+ || echo "$repo"
+ done
+}
+
+get_commit_range() {
+ local pr=$DRONE_PULL_REQUEST
+ local repo=$DRONE_REPO
+ local token=$GH_TOKEN
+ local json=$(set +x; curl -H "Authorization: token $token" \
+ -fsL https://api.github.com/repos/$repo/pulls/$pr)
+ [ "$?" != 0 ] && die "Failed to fetch PR data"
+ local base_sha=$(echo "$json" | jq -r .base.sha)
+ local head_sha=$(echo "$json" | jq -r .head.sha)
+ printf "%s..%s\n" "$base_sha" "$head_sha"
+}
+
+
+set_repositories_for() {
+ local target_repo="$1" repos= repo=
+ local release=$(get_release)
+ for repo in $REPOS; do
+ repos="$repos $MIRROR/$release/$repo"
+ [ "$repo" = "$target_repo" ] && break
+ done
+ sudo sh -c "printf '%s\n' $repos > /etc/apk/repositories"
+ sudo apk update
+}
+
+changed_aports() {
+ cd "$APORTSDIR"
+ local repo="$1" range="$2"
+ local aports=$(git diff --name-only --diff-filter=ACMR --relative="$repo" \
+ $range -- "*/APKBUILD" | xargs -I% dirname %)
+ ap builddirs -d "$APORTSDIR/$repo" $aports 2>/dev/null | xargs -I% basename % | xargs
+}
+
+setup_system() {
+ sudo sh -c "echo $MIRROR/$(get_release)/main > /etc/apk/repositories"
+ sudo apk -U upgrade -a || apk fix || die "Failed to up/downgrade system"
+ abuild-keygen -ain
+ sudo sed -i 's/JOBS=[0-9]*/JOBS=$(nproc)/' /etc/abuild.conf
+ sudo install -do buildozer "$HOME"/drone/packages
+}
+
+sysinfo() {
+ printf ">>> Host system information (arch: %s, release: %s) <<<\n" "$(apk --print-arch)" "$(get_release)"
+ printf "- Number of Cores: %s\n" $(nproc)
+ printf "- Memory: %s Gb\n" $(awk '/^MemTotal/ {print ($2/1024/1024)}' /proc/meminfo)
+ printf "- Free space: %s\n" $(df -hP / | awk '/\/$/ {print $4}')
+}
+
+aport_ok=
+aport_ng=
+
+sysinfo || true
+setup_system
+
+commit_range=$(get_commit_range)
+
+for repo in $(changed_repos "$commit_range"); do
+ set_repositories_for "$repo"
+ for pkgname in $(changed_aports "$repo" "$commit_range"); do
+ if build_aport "$repo" "$pkgname"; then
+ checkapk || true
+ aport_ok="$aport_ok $repo/$pkgname"
+ else
+ aport_ng="$aport_ng $repo/$pkgname"
+ fi
+ done
+done
+
+echo "### Build summary ###"
+
+for ok in $aport_ok; do
+ msg "$ok: build succesfully"
+done
+
+if [ -n "$aport_ng" ]; then
+ die "Failed to build packages:$aport_ng"
+elif [ -z "$aport_ok" ]; then
+ die "No packages found to be built."
+fi
+
diff --git a/scripts/setup.sh b/scripts/setup.sh
new file mode 100755
index 0000000..ad94053
--- /dev/null
+++ b/scripts/setup.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -eu
+
+release=${1:-edge}
+echo "http://dl-cdn.alpinelinux.org/alpine/$release/main" > /etc/apk/repositories
+
+apk -U upgrade -a
+apk add alpine-sdk lua-aports curl jq pigz
+rm -rf /var/cache/apk/*
+
+# use buildozer for building
+adduser -D buildozer
+adduser buildozer abuild
+adduser buildozer wheel
+
+# default distfiles location
+install -d -g abuild -m 775 /var/cache/distfiles