Initial commit

This commit is contained in:
Johannes 'fish' Ziemke 2019-03-09 11:48:10 +01:00
commit 291f06df6e
8 changed files with 120 additions and 0 deletions

25
.circleci/config.yml Normal file
View file

@ -0,0 +1,25 @@
version: 2
jobs:
all:
docker:
- image: circleci/golang:1.11
steps:
- checkout
- setup_remote_docker
- run:
name: build-and-release
command: |
curl -L https://github.com/tcnksm/ghr/releases/download/v0.12.0/ghr_v0.12.0_linux_amd64.tar.gz \
| sudo tar --strip=1 -C /usr/bin -xzvf -
make build-all
workflows:
version: 2
all:
jobs:
- all:
filters:
tags:
only: /^[0-9]*$/
branches:
ignore: /.*/

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
build
*.opk

3
ARCHS Normal file
View file

@ -0,0 +1,3 @@
x86_64
arm64
armhf

63
Makefile Normal file
View file

@ -0,0 +1,63 @@
VERSION ?= 0.2.0-rc5
PVERSION ?= 1
ARCH ?= x86_64
suffix := $(subst -x86_64,,-$(ARCH))
FILES = $(shell find files/ -type f)
DIR = build/$(VERSION)/$(ARCH)
OUT = build/k3s_$(VERSION)_$(ARCH).opk
define CONTROL
Package: k3s
Version: ${VERSION}-${PVERSION}
Architecture: $(ARCH)
Maintainer: Johannes 'fish' Ziemke
Depends: iptables kmod-ipt-extra iptables-mod-extra kmod-br-netfilter ca-certificates
Description: The Docker Engine packages for OpenWrt
endef
export CONTROL
.PHONY: all
all: $(OUT)
build-all:
if [ -n "$$(ls build/)" ]; then echo build/ not empty && exit 1; fi
for a in $$(cat ARCHS); do \
for v in $$(cat VERSIONS); do \
make ARCH=$$a VERSION=$$v; \
done; \
done
.PHONY: release
release: build-all
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} \
-c ${CIRCLE_SHA1} -delete ${PVERSION} build/
$(OUT): $(DIR)/pkg/control.tar.gz $(DIR)/pkg/data.tar.gz $(DIR)/pkg/debian-binary
tar -C $(DIR)/pkg -czvf "$@" debian-binary data.tar.gz control.tar.gz
$(DIR)/data: $(FILES)
mkdir -p "$@/usr/bin"
cp -r files/* "$@"
curl -sfLo "$@/usr/bin/k3s" \
https://github.com/rancher/k3s/releases/download/v$(VERSION)/k3s${suffix}
chmod a+x "$@/usr/bin/k3s"
$(DIR)/pkg/data.tar.gz: $(DIR)/data
tar -C "$<" -czvf "$@" .
$(DIR)/pkg:
mkdir -p $@
$(DIR)/pkg/debian-binary: $(DIR)/pkg
echo 2.0 > $@
$(DIR)/pkg/control: $(DIR)/pkg
echo "$$CONTROL" > "$@"
$(DIR)/pkg/control.tar.gz: $(DIR)/pkg/control
tar -C $(DIR)/pkg -czvf "$@" control
.PHONY: clean
clean:
rm -rf build/

7
README.md Normal file
View file

@ -0,0 +1,7 @@
# k3s on OpenWrt
Makefile to generate OpenWrt .opkg packages from official k3s binaries.
## Usage
Run `make` to build the default version for `x86_64`. You can override ARCH and
VERSION, e.g `make ARCH=armhf`. See ARCHS and VERSIONS files for available
architectures and versions.

2
VERSIONS Normal file
View file

@ -0,0 +1,2 @@
0.2.0-rc5
0.2.0-rc4

2
files/etc/config/k3s Normal file
View file

@ -0,0 +1,2 @@
config globals 'globals'
option root '/data/k3s'

16
files/etc/init.d/k3s Executable file
View file

@ -0,0 +1,16 @@
#!/bin/sh /etc/rc.common
START=60
STOP=20
PIDFILE=/var/run/k3s.pid
EXEC="/usr/bin/k3s"
start() {
start-stop-daemon -S -b -x "$EXEC" -m -p "$PIDFILE" \
-- server --data-dir $(uci_get k3s.globals.root)
}
stop() {
start-stop-daemon -K -p "$PIDFILE"
}