summaryrefslogtreecommitdiffstats
path: root/utils/oci-runtime-tools/Makefile
blob: 5db5f4c0b3f6d17cd8257619b09cb0adfb6dac1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
include $(TOPDIR)/rules.mk

PKG_NAME:=oci-runtime-tools
PKG_VERSION:=1.3.0.20260316
PKG_RELEASE:=6
PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=LICENSE

PKG_SOURCE_PROTO:=git
PKG_SOURCE_NAME:=runtime-tools
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/opencontainers/runtime-tools.git
PKG_SOURCE_VERSION:=8a4db579f5c88af5a0d036fad34bddc9c1f703f3
PKG_MIRROR_HASH:=9a7eb014afbef68a9e51ab05b363064984e24b522aca38ab12e108f4467a177c

PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>

PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=no-mips16

GO_PKG:=github.com/opencontainers/runtime-tools/
GO_PKG_LDFLAGS_X:=main.gitCommit=$(PKG_SOURCE_VERSION) main.version=$(PKG_VERSION)

BUSYBOX_STATIC_VERSION:=1.31.0

ifdef CONFIG_i386
  ROOTFS_ARCHIVE:=rootfs-386.tar.gz
endif
ifdef CONFIG_i686
  ROOTFS_ARCHIVE:=rootfs-386.tar.gz
endif
ifdef CONFIG_x86_64
  ROOTFS_ARCHIVE:=rootfs-amd64.tar.gz
endif
ifdef CONFIG_aarch64
  ROOTFS_ARCHIVE:=rootfs-arm64.tar.gz
endif

include $(INCLUDE_DIR)/package.mk
include ../../lang/golang/golang-package.mk

define Download/busybox-static-armv8l
  URL:=https://busybox.net/downloads/binaries/$$(BUSYBOX_STATIC_VERSION)-defconfig-multiarch-musl/
  URL_FILE:=busybox-armv8l
  FILE:=busybox-$(BUSYBOX_STATIC_VERSION)-static-armv8l
  HASH:=141adb1b625a6f44c4b114f76b4387b4ea4f7ab802b88eb40e0d2f6adcccb1c3
endef

define Package/oci-runtime-tool
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=oci-runtime-tool
  URL:=https://github.com/opencontainers/runtime-tools
  DEPENDS:=$(GO_ARCH_DEPENDS)
endef

define Package/oci-runtime-tool/description
  OCI (Open Container Initiative) runtime tools
  Generate OCI runtime spec configuration files and validate OCI bundles.
endef

define Package/oci-runtime-tests
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=OCI runtimetest tool
  URL:=https://github.com/opencontainers/runtime-tools
  DEPENDS:=@(aarch64||i386||i686||x86_64) oci-runtime-tool +tar +unshare
endef

define Package/oci-runtime-tests/description
  OCI (Open Container Initiative) runtime tools
  This package provides test cases as well as artifacts required to
  validate an OCI runtime.
  Best used in combination with a TAP consumer like 'node-tap',
  installable via npm.
endef

GO_PKG_BUILD_VARS += GO111MODULE=auto

define Build/Prepare
	$(call Build/Prepare/Default)
ifdef CONFIG_aarch64
	$(eval $(call Download,busybox-static-armv8l))
	( \
		mkdir -p $(PKG_BUILD_DIR)/rootfs-armv8l ;\
		cd $(PKG_BUILD_DIR)/rootfs-armv8l ;\
		$(TAR) xzf ../rootfs-amd64.tar.gz ;\
		$(CP) $(DL_DIR)/busybox-$(BUSYBOX_STATIC_VERSION)-static-armv8l bin/busybox ;\
		chmod 0755 bin/busybox ;\
		$(TAR) czf ../rootfs-arm64.tar.gz . ;\
	)
endif
endef

define Build/Compile
	$(call GoPackage/Build/Compile)
	$(GO_GENERAL_BUILD_CONFIG_VARS) \
	$(GO_PKG_BUILD_CONFIG_VARS) \
	GO_BUILD_PKG="$(GO_PKG)cmd/runtimetest" \
	$(GO_PKG_VARS) \
	CGO_ENABLED=0 \
	$(SHELL) $(GO_INCLUDE_DIR)golang-build.sh build \
		-v -buildvcs=false -trimpath -tags "netgo osusergo" \
		-ldflags "$(patsubst %,-X %,$(GO_PKG_LDFLAGS_X))"
	$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
endef

define Package/oci-runtime-tool/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/oci-runtime-tool $(1)/usr/bin
endef

define Package/oci-runtime-tests/install
	$(INSTALL_DIR) $(1)/usr/libexec/oci-runtime-test
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/runtimetest $(1)/usr/libexec/oci-runtime-test/
	( cd $(PKG_BUILD_DIR) ; $(FIND) ./validation/ -name *.go | grep -v util | \
	xargs -I'%' -n 1 basename % .go | while read testbin; do \
		$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/$$$${testbin} \
			$(1)/usr/libexec/oci-runtime-test/$$$${testbin}.t ; \
	done )
	$(INSTALL_DIR) $(1)/usr/share/oci-runtime-test
	$(INSTALL_DATA) $(PKG_BUILD_DIR)/$(ROOTFS_ARCHIVE) $(1)/usr/share/oci-runtime-test/
	$(LN) ../../share/oci-runtime-test/$(ROOTFS_ARCHIVE) $(1)/usr/libexec/oci-runtime-test/
endef

$(eval $(call GoBinPackage,oci-runtime-tools))
$(eval $(call BuildPackage,oci-runtime-tool))
$(eval $(call BuildPackage,oci-runtime-tests))