diff options
author | Björn Esser <b.esser@pengutronix.de> | 2020-03-18 16:54:06 +0100 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2020-03-20 13:39:08 +0100 |
commit | f5c373673405a1d013cc8324d76e2183a3218eb3 (patch) | |
tree | 5a4d027d38d22e82573a8f31e1c88e5a6628b77f /rules/nodejs_packages.make | |
parent | a760b12e0d322cc8f34f5965fb2cb17e3b4b6a65 (diff) | |
download | ptxdist-f5c373673405a1d013cc8324d76e2183a3218eb3.tar.gz ptxdist-f5c373673405a1d013cc8324d76e2183a3218eb3.tar.xz |
nodejs_packages: new package
This is a dummy package to specify and install required Node.js packages for the
target system.
The management of those packages and their dependencies is handled with
Yarn (run through host-nodejs) to maintain a reproducible offline cache that is
stored in local_src/nodejs_packages.
Signed-off-by: Björn Esser <b.esser@pengutronix.de>
[uol: adjusted commit message and Kconfig menu file's help texts, integrated
Kconfig symbol NODEJS_PACKAGES_LICENSE, made NODEJS_PACKAGES_CACHE and YARN_LOCK
aware of PTXdist's concept of layers, made yarn, mkdir, install & cp more
verbose, suppressed echoing of diverse commands, removed one square bracket in a
shell test, let PTXdist bail out if yarn's frozen lock file does not exist at
all and wrapped install/cp into call of execute and world/execute]
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Message-Id: <20200318155406.27584-3-u.oelmann@pengutronix.de>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'rules/nodejs_packages.make')
-rw-r--r-- | rules/nodejs_packages.make | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/rules/nodejs_packages.make b/rules/nodejs_packages.make new file mode 100644 index 000000000..a20fff877 --- /dev/null +++ b/rules/nodejs_packages.make @@ -0,0 +1,98 @@ +# -*-makefile-*- +# +# Copyright (C) 2020 by Bjoern Esser <bes@pengutronix.de> +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +# +# We provide this package +# +PACKAGES-$(PTXCONF_NODEJS_PACKAGES) += nodejs_packages + +# +# Paths and names +# +NODEJS_PACKAGES_VERSION := 0.0.1 +NODEJS_PACKAGES := nodejs_packages-$(NODEJS_PACKAGES_VERSION) +NODEJS_PACKAGES_LOCAL := local_src/nodejs_packages +NODEJS_PACKAGES_URL := lndir://$(NODEJS_PACKAGES_LOCAL) +NODEJS_PACKAGES_DIR := $(BUILDDIR)/$(NODEJS_PACKAGES) +NODEJS_PACKAGES_CACHE := $(call ptx/in-path, PTXDIST_PATH_LAYERS, $(NODEJS_PACKAGES_LOCAL))/yarn_cache +NODEJS_PACKAGES_LICENSE := $(call remove_quotes, $(PTXCONF_NODEJS_PACKAGES_LICENSE)) + +NODEJS_PACKAGES_LIST := $(call remove_quotes, $(PTXCONF_NODEJS_PACKAGES_LIST)) + +YARN_LOCK := $(call ptx/in-path, PTXDIST_PATH_LAYERS, $(NODEJS_PACKAGES_LOCAL))/yarn.lock +YARN_OPTS := \ + --cwd "$(NODEJS_PACKAGES_DIR)" \ + --cache-folder "$(NODEJS_PACKAGES_CACHE)" \ + --link-duplicates \ + --production=true \ + --verbose + +ifdef PTXCONF_NODEJS_PACKAGES_OFFLINE +YARN_OPTS += \ + --frozen-lockfile \ + --offline +endif + +# ---------------------------------------------------------------------------- +# Compile +# ---------------------------------------------------------------------------- + +$(STATEDIR)/nodejs_packages.compile: + @$(call targetinfo) + @mkdir -vp $(NODEJS_PACKAGES_CACHE) + @printf "{ \ + \"name\": \"nodejs_packages\", \ + \"version\": \"$(NODEJS_PACKAGES_VERSION)\", \ + \"license\": \"UNLICENSED\", \ + \"private\": true \ + }" > $(NODEJS_PACKAGES_DIR)/package.json + @if [ ! -f $(YARN_LOCK) ]; then \ + if [ $(PTXCONF_NODEJS_PACKAGES_OFFLINE) = y ]; then \ + ptxd_bailout "Offline cache locked without existing 'yarn.lock'! \ + Please unlock and compile before locking again."; \ + fi; \ + touch $(YARN_LOCK); \ + ln -fs $(YARN_LOCK) $(NODEJS_PACKAGES_DIR)/yarn.lock; \ + fi + yarn $(YARN_OPTS) add $(NODEJS_PACKAGES_LIST) + @find $(NODEJS_PACKAGES_CACHE) -type f -name '.yarn-tarball.tgz' -delete + @$(call touch) + +# ---------------------------------------------------------------------------- +# Install +# ---------------------------------------------------------------------------- + +$(STATEDIR)/nodejs_packages.install: + @$(call targetinfo) + @$(call world/execute, HOST_UA_NODESET, \ + install -vdm 0755 $(NODEJS_PACKAGES_PKGDIR)/usr/lib) + @$(call execute, HOST_UA_NODESET, \ + cp -vpr $(NODEJS_PACKAGES_DIR)/node_modules \ + $(NODEJS_PACKAGES_PKGDIR)/usr/lib) + @$(call touch) + +# ---------------------------------------------------------------------------- +# Target-Install +# ---------------------------------------------------------------------------- + +$(STATEDIR)/nodejs_packages.targetinstall: + @$(call targetinfo) + + @$(call install_init, nodejs_packages) + @$(call install_fixup, nodejs_packages,PRIORITY,optional) + @$(call install_fixup, nodejs_packages,SECTION,base) + @$(call install_fixup, nodejs_packages,AUTHOR,"Bjoern Esser <bes@pengutronix.de>") + @$(call install_fixup, nodejs_packages,DESCRIPTION,missing) + + $(call install_tree, nodejs_packages, 0, 0, -, /usr/lib/node_modules/) + + @$(call install_finish, nodejs_packages) + + @$(call touch) + +# vim: syntax=make |