- Automatic package versions
- Generate Makefile for creating signed packages
- Build with x86_64 variant by default
- Add Nim example
- Runtime schema fixes
This commit is contained in:
Ehmry - 2019-04-27 19:54:22 +02:00
parent 00415c56ee
commit a853c0d5e0
23 changed files with 322 additions and 117 deletions

70
Tupfile Normal file
View File

@ -0,0 +1,70 @@
.gitignore
include_rules
ifndef SCULPT_VERSION
error CONFIG_SCULPT_VERSION is undefined
endif
ifndef PUBLIC_USER
error CONFIG_PUBLIC_USER is undefined
endif
SHORT_SUM = b2sum -l24
: $(DEPOT_DIR)/<raw-archives> $(DEPOT_DIR)/<bin-archives> |> \
for f in %<raw-archives> %<bin-archives>; do \
awk -F '/' '{print "s|local/"$2"/"$3"/current|@(PUBLIC_USER)/"$2"/"$3"/"$4"|"}' $f >> %o; done; \
|> $(VERSIONS_SED_FILE)
# Generate a listing of all raw archives
: $(DEPOT_DIR)/<raw-archives> |> \
touch %o; \
for f in %<raw-archives>; do cat $f >> %o; done; \
|> $(RAW_LISTING)
# Generate a listing of all raw archives
: $(DEPOT_DIR)/<bin-archives> |> \
for f in %<bin-archives>; do tail -n1 $f >> %o; done; \
|> $(BIN_LISTING)
# Generate a listing of all binary archives
: $(DEPOT_DIR)/<packages> |> ^ generate package version sed script^ \
for d in `dirname %<packages> | tr ' ' '\n' | sort -u`; do \
echo $d/`cat $d/.ARCHIVES $d/runtime | $(SHORT_SUM)` | awk -F '/' \
'{print "s|local/pkg/"$3"/current|@(PUBLIC_USER)/pkg/"$3"/"substr($5,0,6)"|"}' >> %o; \
done \
|> $(PKG_SED_FILE)
# Generate sed commands for replacing package versions
: $(DEPOT_DIR)/<raw-archives> $(DEPOT_DIR)/<bin-archives> $(PKG_SED_FILE) |> \
^ generate public makefile^ \
echo PUBLIC_USER=@(PUBLIC_USER) >> %o; \
echo PUBLIC_ARCH=@(TUP_ARCH) >> %o; \
echo "all: public/@(PUBLIC_USER)/index/@(SCULPT_VERSION).xz.sig" >> %o; \
echo %%.xz.sig: %%.xz >> %o; \
echo " @echo sign \$<" >> %o; \
echo " @gpg --detach-sign --digest-algo SHA256 --no-tty --local-user @(PUBLIC_KEY) < \$< > tmp" >> %o; \
echo " @mv tmp \$@" >> %o; \
for f in %<raw-archives>; do \
awk -F '/' -f errata/raw.mk.awk $f >> %o; done; \
for f in %<bin-archives>; do \
awk -F '/' -f errata/bin.mk.awk $f >> %o; done; \
awk -F '/' -f errata/pkg.mk.awk $(PKG_SED_FILE) >> %o; done \
|> Makefile
# Generate the makefile for creating signed package tarballs
: index.xml | $(PKG_SED_FILE) |> ^ generate public index^ \
xmllint %f | sed \
-e 's|_/pkg/\([^"]*\)|local/pkg/\1/current|' \
-f $(PKG_SED_FILE) \
| xz > %o; \
|> public/@(PUBLIC_USER)/index/@(SCULPT_VERSION).xz
AWK_RUNTIME_PATH = awk -v RS=' ' -F '/' \
'/runtime/ {print " <pkg path=\"local/pkg/"$3"/current\"/>"}'
: $(DEPOT_DIR)/<packages> |> ^ generate local index^ \
echo '<index>' > %o; \
echo %<packages> | $(AWK_RUNTIME_PATH) | sort >> %o; \
echo '</index>' >> %o |> $(DEPOT_DIR)/index/@(SCULPT_VERSION)
# Generate the depot index file

View File

@ -1,69 +1,110 @@
.gitignore
export PKG_CONFIG_PATH
CC = `pkg-config genode-base --variable cc`
CXX = `pkg-config genode-base --variable cxx`
LD = `pkg-config genode-base --variable ld`
AR = `pkg-config genode-base --variable ar`
ifndef DEPOT_USER
error CONFIG_DEPOT_USER is undefined
ifeq ($(RAW_NAME),)
RAW_NAME = $(TARGET_NAME)
endif
ifndef DEPOT_VERSION
error CONFIG_DEPOT_VERSION is undefined
ifeq ($(BIN_NAME),)
BIN_NAME = $(TARGET_NAME)
endif
DEPOT_DIR = $(TUP_CWD)/depot/@(DEPOT_USER)
PUBLIC_DIR = $(TUP_CWD)/public/@(DEPOT_USER)
ifeq ($(PKG_NAME),)
PKG_NAME = $(TARGET_NAME)
endif
DEPOT_BIN_DIR = $(DEPOT_DIR)/bin/x86_64
PUBLIC_BIN_DIR = $(PUBLIC_DIR)/bin/x86_64
GIT_VERSION=`git describe --always`
BIN_VERSION=$(GIT_VERSION)
PKG_VERSION=$(GIT_VERSION)
ifeq ($(RAW_VERSION),)
RAW_VERSION=$(GIT_VERSION)
endif
DEPOT_DIR = $(TUP_CWD)/depot
DEPOT_RAW_DIR = $(DEPOT_DIR)/raw
DEPOT_BIN_DIR = $(DEPOT_DIR)/bin/@(TUP_ARCH)
DEPOT_PKG_DIR = $(DEPOT_DIR)/pkg
PUBLIC_DIR = $(TUP_CWD)/public
PUBLIC_RAW_DIR = $(PUBLIC_DIR)/raw
PUBLIC_BIN_DIR = $(PUBLIC_DIR)/bin
PUBLIC_PKG_DIR = $(PUBLIC_DIR)/pkg
DEPOT_RAW_DIR = $(DEPOT_DIR)/raw
PUBLIC_RAW_DIR = $(PUBLIC_DIR)/raw
RAW_DIR = $(DEPOT_RAW_DIR)/$(RAW_NAME)/current
# Destination for locally defined raw package
!strip_to_depot = |> ^ strip bin/%d^ strip -o %o %f |> $(DEPOT_BIN_DIR)/%d/@(DEPOT_VERSION)/%b
BIN_DIR = $(DEPOT_BIN_DIR)/$(BIN_NAME)/current
# Destination for locally defined binary package
PKG_DIR = $(DEPOT_BIN_DIR)/$(BIN_NAME)/current
# Destination for locally defined runtime package
!raw = |> ^ COLLECT %o^ \
echo $(RAW_DEPENDS) local/raw/$(RAW_NAME)/$(RAW_VERSION) | tr ' ' '\n' > %o; \
echo local/raw/$(RAW_NAME)/$(RAW_VERSION) > %o \
|> $(RAW_DIR)/.ARCHIVES $(DEPOT_DIR)/<raw-archives>
!bin = |> ^ COLLECT %o^ \
echo $(BIN_DEPENDS) local/src/$(BIN_NAME)/$(BIN_VERSION) | tr ' ' '\n' > %o; \
|> $(BIN_DIR)/.ARCHIVES $(DEPOT_DIR)/<bin-archives>
# Macro invoked in BIN_RULES
RAW_RULES = $(TUP_CWD)/errata/raw.tup
# Rules for finalizing a locally defined raw package
BIN_RULES = $(TUP_CWD)/errata/bin.tup
# Rules for finalizing a locally defined binary package
PKG_RULES = $(TUP_CWD)/errata/pkg.tup
# Rules for finalizing a locally defined runtime package
AWK_LOCAL_ARCHIVES = awk -F '/' \
'{if ($1 != "local") {print $0} \
else {print $1"/"$2"/"$3"/current"}}'
!pkg = |> |>
!collect_raw = |> ^ COLLECT %o^ \
cp %f %o \
|> $(RAW_DIR)/%b
!collect_bin = |> ^ COLLECT %o^ \
strip -o %o %f \
|> $(DEPOT_BIN_DIR)/$(BIN_NAME)/current/%b
!collect_pkg_runtime = | $(VERSIONS_SED_FILE) |> ^ package %f^ \
xmllint --noout -schema $(ERRATA_DIR)/runtime.xsd %f; \
cp %f $(DEPOT_PKG_DIR)/$(PKG_NAME)/current/runtime; \
echo $(PKG_DEPENDS) | tr ' ' '\n' | sed \
-e 's|_/\(.*\)/\(.*\)$|local/\1/\2/current|' \
> $(DEPOT_PKG_DIR)/$(PKG_NAME)/current/archives; \
sed -f $(VERSIONS_SED_FILE) $(DEPOT_PKG_DIR)/$(PKG_NAME)/current/archives \
> $(DEPOT_PKG_DIR)/$(PKG_NAME)/current/.ARCHIVES; \
|> \
$(DEPOT_PKG_DIR)/$(PKG_NAME)/current/archives \
$(DEPOT_PKG_DIR)/$(PKG_NAME)/current/.ARCHIVES \
$(DEPOT_PKG_DIR)/$(PKG_NAME)/current/runtime \
$(DEPOT_DIR)/<packages>
!collect_pkg = |> ^ COLLECT %o^ cp %f %o \
|> $(DEPOT_PKG_DIR)/$(PKG_NAME)/current/%b \
$(DEPOT_DIR)/<packages>
VERSIONS_SED_FILE = $(TUP_CWD)/versions.sed
PKG_SED_FILE = $(TUP_CWD)/pkg.sed
RAW_LISTING = $(TUP_CWD)/raw-list
BIN_LISTING = $(TUP_CWD)/bin-list
PKG_LISTING = $(TUP_CWD)/pkg-list
SDK_INCLUDE = $(TUP_CWD)/sdk.tup
ERRATA_DIR = $(TUP_CWD)/errata
!archives_to_depot = |> ^ varse %d archives^ tup varsed %f %o |> $(DEPOT_PKG_DIR)/%d/@(DEPOT_VERSION)/archives
CC = @(CC_WRAPPER) `pkg-config genode-base --variable cc`
CXX = @(CXX_WRAPPER) `pkg-config genode-base --variable cxx`
LD = `pkg-config genode-base --variable ld`
AR = `pkg-config genode-base --variable ar`
!runtime_to_depot = |> ^ validate %d runtime^ \
xmllint -schema $(ERRATA_DIR)/runtime.xsd --noout %f ; cp %f %o \
|> $(DEPOT_PKG_DIR)/%d/@(DEPOT_VERSION)/runtime $(DEPOT_DIR)/<runtimes>
!cc = |> ^ CC %f^ $(CC) $(DEFINES) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) -c %f -o %o |>
!cxx = |> ^ CC %f^ $(CC) $(DEFINES) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) -c %f -o %o |>
!ld = |> ^ LD %o^ $(LD) $(LDFLAGS) %f -o %o |>
!raw_to_depot = |> ^ raw/%d/%b^ cp -r %f %o |> $(DEPOT_RAW_DIR)/%d/@(DEPOT_VERSION)/%b
ifndef DEPOT_KEY
!publish_bin = |> |>
!publish_raw = |> |>
!publish_pkg = |> |>
else
SIGN_CMD = gpg --detach-sign --digest-algo SHA256 --no-tty --local-user @(DEPOT_KEY)
!publish_bin = |> ^o publish %d binary^ \
tar cfJ %o -C $(DEPOT_BIN_DIR)/%d . ; $(SIGN_CMD) < %o > %o.sig \
|> $(PUBLIC_BIN_DIR)/%d/@(DEPOT_VERSION).tar.xz \
| $(PUBLIC_BIN_DIR)/%d/@(DEPOT_VERSION).tar.xz.sig
!publish_raw = |> ^o publish %d raw^ \
tar cfJ %o -C $(DEPOT_RAW_DIR)/%d . ; $(SIGN_CMD) < %o > %o.sig \
|> $(PUBLIC_RAW_DIR)/%d/@(DEPOT_VERSION).tar.xz \
| $(PUBLIC_RAW_DIR)/%d/@(DEPOT_VERSION).tar.xz.sig
!publish_pkg = |> ^o publish %d package^ \
tar cfJ %o -C $(DEPOT_PKG_DIR)/%d . ; $(SIGN_CMD) < %o > %o.sig \
|> $(PUBLIC_PKG_DIR)/%d/@(DEPOT_VERSION).tar.xz \
| $(PUBLIC_PKG_DIR)/%d/@(DEPOT_VERSION).tar.xz.sig
!public_signature = |> ^ sign %b^ $(SIGN_CMD) < %f > %o |> %f.sig
endif
export PKG_CONFIG_PATH
PKG_CONFIG = PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(SDK_DIR)/pkgconfig pkg-config

View File

@ -1,14 +1,20 @@
TARGET_NAME = hello-world
include_rules
PKGS = genode-base genode-prg
PKG_CONFIGS = genode-base genode-prg
: foreach *.cc |> $(CC) `pkg-config --cflags $(PKGS)` -c %f -o %o |> %B.o {objs}
: {objs} |> $(LD) `pkg-config --libs $(PKGS)` %f -o %o |> %d {binary}
CXXFLAGS += `$(PKG_CONFIG) -cflags $(PKG_CONFIGS)`
LDFLAGS += `$(PKG_CONFIG) -libs $(PKG_CONFIGS)`
: {binary} |> !strip_to_depot |>
: foreach *.cc |> !cxx |> %B.o {objs}
: {objs} |> !ld |> %d {binary}
: archives | {binary} |> !archives_to_depot |> {package}
: runtime | {binary} |> !runtime_to_depot |> {package}
: {binary} |> !collect_bin |>
: |> !publish_bin |>
: |> !publish_pkg |>
PKG_DEPENDS += \
_/src/$(BIN_NAME) \
: runtime |> !collect_pkg_runtime |>
include $(BIN_RULES)
include $(PKG_RULES)

View File

@ -2,7 +2,8 @@
#include <base/component.h>
#include <base/log.h>
void Component::construct(Genode::Env &)
void Component::construct(Genode::Env &env)
{
Genode::log("Hello world!");
env.parent().exit(0);
}

8
build-x86_64/tup.config Normal file
View File

@ -0,0 +1,8 @@
CONFIG_TUP_ARCH=x86_64
CONFIG_SCULPT_VERSION=19.02
CONFIG_PUBLIC_USER=foobar
CONFIG_PUBLIC_KEY=6E10414EE7160781F5FEE8FFB14D043A26B3D2C7
CONFIG_PUBLIC_SRC_LIBC=genodelabs/src/libc/2019-03-17
CONFIG_PUBLIC_SRC_VFS=genodelabs/src/vfs/2019-03-18

12
errata/bin.mk.awk Normal file
View File

@ -0,0 +1,12 @@
{ if ($1 == "local") {
{ tar="public/$(PUBLIC_USER)/bin/$(PUBLIC_ARCH)/"$3"/"$4".tar.xz" }
{ print "all: " tar ".sig" }
{ print tar": "FILENAME }
{ print " @echo tar $@" }
{ print " @mkdir -p $(dir $@)" }
{ print " @tar cfJ $@ --exclude=.ARCHIVES --transform=\"s|^\\.|"$4"|\" -C $(dir $<) ." }
}}

14
errata/bin.tup Normal file
View File

@ -0,0 +1,14 @@
ifeq ($(BIN_NAME),)
error BIN_NAME is empty
endif
ifeq ($(BIN_VERSION),)
error BIN_VERSION is empty
endif
: |> !bin |>
# Finalize the metadata with the macro defined in the
# ../Tuprules.tup. The macro cannot be defined here
# because the "include" directive is not available for
# relative paths during "include_rules" so this file
# cannot be included by intermediate Tuprules.tup.

13
errata/pkg.mk.awk Normal file
View File

@ -0,0 +1,13 @@
{ ver=substr($7,0,6) }
{ tar="public/$(PUBLIC_USER)/pkg/"$6"/"ver".tar.xz" }
{ sig=tar".sig" }
{ print "all: " tar ".sig" }
{ print tar": depot/pkg/"$6"/current/.ARCHIVES" }
{ print " @echo tar $@" }
{ print " @mkdir -p $(dir $@) "ver }
{ print " @sed -f pkg.sed $< > "ver"/archives" }
{ print " @cp $(dir $<)/runtime "ver }
{ print " @tar cfJ $@ "ver }
{ print " @rm -r "ver }

0
errata/pkg.tup Normal file
View File

8
errata/raw.mk.awk Normal file
View File

@ -0,0 +1,8 @@
{ tar="public/$(PUBLIC_USER)/raw/"$3"/"$4".tar.xz" }
{ print "all: " tar ".sig" }
{ print tar": "FILENAME }
{ print " @echo tar $@" }
{ print " @mkdir -p $(dir $@)" }
{ print " @tar cfJ $@ --exclude=.ARCHIVES --transform=\"s|^\\.|"$4"|\" -C $(dir $<) ." }

14
errata/raw.tup Normal file
View File

@ -0,0 +1,14 @@
ifeq ($(RAW_NAME),)
error RAW_NAME is empty
endif
ifeq ($(RAW_VERSION),)
error RAW_VERSION is empty
endif
: |> !raw |>
# Finalize the metadata with the macro defined in the
# ../Tuprules.tup. The macro cannot be defined here
# because the "include" directive is not available for
# relative paths during "include_rules" so this file
# cannot be included by intermediate Tuprules.tup.

View File

@ -24,6 +24,7 @@
<xs:element name="rom" type="template_service"/>
<xs:element name="rtc" type="template_service"/>
<xs:element name="terminal" type="template_service"/>
<xs:element name="usb" type="template_service"/>
</xs:choice>
</xs:complexType>
@ -62,6 +63,7 @@
<xs:attribute name="ram" type="Number_of_bytes" />
<xs:attribute name="caps" type="xs:positiveInteger" />
<xs:attribute name="binary" type="xs:string" />
<xs:attribute name="config" type="xs:string" />
</xs:complexType>
</xs:element>

6
index.xml Normal file
View File

@ -0,0 +1,6 @@
<index>
<index name="Examples">
<pkg path="_/pkg/hello-world" info="C++ hello world"/>
<pkg path="_/pkg/hello_nim" info="Nim hello world"/>
</index>
</index>

View File

@ -1,25 +0,0 @@
include_rules
ifndef SCULPT_VERSION
error CONFIG_SCULPT_VERSION is undefined
endif
DEPOT_INDEX_FILE = $(DEPOT_DIR)/index/@(SCULPT_VERSION)
ifneq (@(DEPOT_USER),local)
: index.xml |> tup varsed %f - | xmllint - > %o |> $(DEPOT_INDEX_FILE) {index}
else
: $(DEPOT_DIR)/<runtimes> |> ^ generate index^ \
echo '<index>' > %o; \
echo %<runtimes> | tr ' ' '\n' | sort |\
sed \
-e 's|\.\./depot/| <pkg path="|' \
-e 's|runtime|"/>|' \
- >> %o; \
echo '</index>' >> %o |> $(DEPOT_INDEX_FILE) {index}
endif
ifdef DEPOT_KEY
: {index} |> xz -c %f > %o |> $(PUBLIC_DIR)/index/%b.xz {dist}
: {dist} |> !public_signature |>
endif

View File

@ -1,7 +0,0 @@
<index>
<index name="Example">
<pkg path="@DEPOT_USER@/pkg/hello-world/@DEPOT_VERSION@" info="An example"/>
</index>
</index>

View File

@ -1,2 +1,13 @@
# Nim default variables
NIM_RELEASE_FLAG = -d:release
# Drop the relase flag with the line "NIM_RELEASE_FLAG="
NIM_SRC_DIR = src
# Build everything in this directory
BIN_VERSION = $(GIT_VERSION)
# Use the git version as the binary package version
NIMBLE_BINARIES_INCLUDE = $(TUP_CWD)/binaries.tup
NIMBLE_PACKAGE_INCLUDE = $(TUP_CWD)/package.tup

View File

@ -1,9 +1,7 @@
# Drop the relase flag with the line "NIM_RELEASE_FLAG="
NIM_RELEASE_FLAG = -d:release
!nim_build = |> ^o Nimble %B^ \
nimble cpp $(NIM_RELEASE_FLAG) $(NIM_FLAGS) --os:genode -d:posix --parallelBuild:1 -o:%B %f \
|> %B ./<binaries>
!nim_build = |> ^o Nimble %B^ nimble cpp $(NIM_RELEASE_FLAG) --os:genode -d:posix -o:%B %f |> %B ./<binaries>
: foreach src/*.nim |> !nim_build |> {output}
: foreach {output} |> !strip_to_depot |> {binary}
: {binary} |> !publish_bin |>
: foreach $(NIM_SRC_DIR)/*.nim |> !nim_build |> {binary}
: foreach {binary} |> !collect_bin |>
: |> !bin |>

10
nim/hello_nim/Tupfile Normal file
View File

@ -0,0 +1,10 @@
TARGET_NAME = hello_nim
PKG_DEPENDS += \
@(PUBLIC_SRC_LIBC) \
@(PUBLIC_SRC_VFS) \
_/src/$(TARGET_NAME) \
include_rules
include $(NIMBLE_BINARIES_INCLUDE)
include $(NIMBLE_PACKAGE_INCLUDE)

View File

@ -0,0 +1,12 @@
# Package
version = "0.1.0"
author = "Emery Hemingway"
description = "Hello world example"
license = "None"
srcDir = "src"
bin = @["hello_nim"]
# Dependencies
requires "nim >= 0.19", "genode >= 18.05"

14
nim/hello_nim/runtime Normal file
View File

@ -0,0 +1,14 @@
<runtime ram="4M" caps="128" binary="hello_nim">
<requires/>
<content>
<rom label="hello_nim"/>
<rom label="libc.lib.so"/>
<rom label="libm.lib.so"/>
<rom label="vfs.lib.so"/>
</content>
<config/>
</runtime>

View File

@ -0,0 +1,8 @@
import genode
# The Genode module must be imported
# to resolve link dependencies
componentConstructHook = proc (env: GenodeEnv) =
echo("Hello, World!")
quit()
# exit must be explicit

View File

@ -1,7 +1,4 @@
include_rules
: archives | ./<binaries> |> !archives_to_depot |> {package}
: runtime | ./<binaries> |> !runtime_to_depot |> {package}
: {package} |> !publish_pkg |>
PKG_VERSION = $(GIT_VERSION)
: runtime | ./<binaries> |> !collect_pkg_runtime |>
: |> !pkg |>

View File

@ -1,8 +0,0 @@
CONFIG_SCULPT_VERSION=19.02
CONFIG_SDK_USER=ehmry
CONFIG_SDK_VERSION=19.02
CONFIG_UPSTREAM_USER=ehmry
CONFIG_UPSTREAM_VERSION=19.02
CONFIG_DEPOT_USER=local
CONFIG_DEPOT_VERSION=current
#CONFIG_DEPOT_KEY=6E10414EE7160781F5FEE8FFB14D043A26B3D2C7