Skip to content

Commit

Permalink
Openwrt (#203)
Browse files Browse the repository at this point in the history
* x64 Openwrt support
  • Loading branch information
bretambrose authored Jan 3, 2023
1 parent bd2cec4 commit af691dd
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 3 deletions.
41 changes: 41 additions & 0 deletions .github/docker-images/openwrt-x64-openjdk8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM openwrtorg/rootfs

# for some reason this directory isn't created by this point and we need it
RUN mkdir -p /var/lock
RUN mkdir -p /usr/local/bin

RUN opkg update

# packages in openwrt
RUN opkg install git-http ca-bundle curl python3 python3-pip gcc make bash sudo

# packages we have to get from alpine

# first, pull apk directly
RUN wget http://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/apk-tools-static-2.12.9-r3.apk
RUN tar -xzf apk-tools-static-2.12.9-r3.apk

# next, install stuff that either
# (1) isn't in openwrt and we don't want to build ourselves (cmake, maven)
# (2) appears to be broken (python3-awscli)
#
# Under normal circumstances, we let the repository (via builder.json and custom actions) guide the language runtime installation, but since
# (1) openwrt does not have many runtimes in its package manager (and tools like maven that depend on those runtimes)
# (2) we are only doing openwrt CI checks for Java
# we install the desired JDK here as well.
#
RUN ./sbin/apk.static -X http://dl-cdn.alpinelinux.org/alpine/v3.16/main -X http://dl-cdn.alpinelinux.org/alpine/v3.16/community -U --allow-untrusted --initdb add cmake openjdk8 maven aws-cli

# stub libraries for stuff we unconditionally link; functionality is all actually in musl already
# long term we might want to make our recognition better, but this is a blocker for the s2n build
RUN ar -rc /usr/lib/libpthread.a
RUN ar -rc /usr/lib/libdl.a
RUN ar -rc /usr/lib/librt.a
RUN ar -rc /usr/lib/libm.a

###############################################################################
# Install entrypoint
###############################################################################
ADD entrypoint.sh /usr/local/bin/builder
RUN chmod a+x /usr/local/bin/builder
ENTRYPOINT ["/usr/local/bin/builder"]
1 change: 1 addition & 0 deletions .github/workflows/create-channel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ jobs:
- alpine-3.16-arm64
- alpine-3.16-armv7
- alpine-3.16-armv6
- openwrt-x64-openjdk8

steps:
- name: Checkout Sources
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
- alpine-3.16-arm64
- alpine-3.16-armv7
- alpine-3.16-armv6
- openwrt-x64-openjdk8

steps:
- name: Checkout Sources
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-container-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ shift

aws ecr get-login-password | docker login 123124136734.dkr.ecr.us-east-1.amazonaws.com -u AWS --password-stdin
export DOCKER_IMAGE=123124136734.dkr.ecr.us-east-1.amazonaws.com/${IMAGE_NAME}:${BUILDER_VERSION}
docker run --env GITHUB_REF --env GITHUB_HEAD_REF --env AWS_ACCESS_KEY_ID --env AWS_SECRET_ACCESS_KEY --env AWS_DEFAULT_REGION --env CXXFLAGS $DOCKER_IMAGE --version=${BUILDER_VERSION} $@
docker run --env GITHUB_REF --env GITHUB_HEAD_REF --env AWS_ACCESS_KEY_ID --env AWS_SECRET_ACCESS_KEY --env AWS_DEFAULT_REGION --env CXXFLAGS --env AWS_CRT_ARCH $DOCKER_IMAGE --version=${BUILDER_VERSION} $@
8 changes: 8 additions & 0 deletions builder/core/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PKG_TOOLS(Enum):
PKG = 'freebsd_pkg'
ZYPPER = 'zypper'
DNF = 'dnf'
OPKG = 'opkg'


KEYS = {
Expand Down Expand Up @@ -153,6 +154,13 @@ class PKG_TOOLS(Enum):
'pkg_update': '',
'pkg_install': 'apk add --no-cache',
},
'openwrt': {
'os': 'linux',
'pkg_tool': PKG_TOOLS.OPKG,
'pkg_setup': [],
'pkg_update': 'opkg update',
'pkg_install': 'opkg install',
},
'raspbian': {
'os': 'linux',
'pkg_tool': PKG_TOOLS.APT,
Expand Down
4 changes: 2 additions & 2 deletions builder/core/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ def normalize_target(target):

def _file_contains(path, search):
if os.path.isfile(path):
#print('Probing {}'.format(path))
with open(path) as f:
line = f.readline()
while line:
#print(' {}'.format(line), end='')
if search in line:
return True
line = f.readline()
Expand Down Expand Up @@ -96,6 +94,8 @@ def _discover_host():
return 'opensuse'
if _file_contains('/etc/os-release', 'Red Hat Enterprise Linux'):
return 'rhel'
if _file_contains('/etc/os-release', 'OpenWrt'):
return 'openwrt'
return 'linux'
else:
return platform
Expand Down

0 comments on commit af691dd

Please sign in to comment.