diff --git a/Makefile b/Makefile index e6beebbbb73..3e82325d378 100644 --- a/Makefile +++ b/Makefile @@ -37,13 +37,37 @@ clobber: TARGET = clobber setup: TARGET = setup test: TARGET = test component-hook: TARGET = component-hook +generate-package-kdl: TARGET = generate-package-kdl .DEFAULT: publish -download setup prep build install pre-publish publish validate clean clobber \ -test component-hook unpack patch: $(SUBDIRS) +download prep build install pre-publish publish validate clean clobber test component-hook generate-package-kdl unpack patch: $(SUBDIRS) $(SUBDIRS): FORCE @+echo "$(TARGET) $@" ; $(GMAKE) -s -C $@ $(TARGET) FORCE: + +# Bootstrap pkgdev before running component setup +setup: bootstrap-pkgdev $(SUBDIRS) + +bootstrap-pkgdev: + @echo "Bootstrapping pkgdev via cargo from toasterson/forge" + cargo install --git https://github.com/toasterson/forge pkgdev + +update-pkgdev: + @echo "Updating pkgdev via cargo from toasterson/forge" + cargo install --git https://github.com/toasterson/forge pkgdev --force + +# Generate repology metadata using pkgdev +.PHONY: repology +repology: bootstrap-pkgdev + @echo "Generating repology metadata with pkgdev" + pkgdev generate --output=repology-metadata.json repology + +# Clean generated package.kdl files and missing-metadata list +.PHONY: clean-package-kdl +clean-package-kdl: + @echo "Cleaning generated package.kdl files and components.missing-metadata" + @/usr/bin/find components -type f -name package.kdl -exec rm -f {} + + @rm -f $(WS_TOP)/components.missing-metadata components.missing-metadata diff --git a/components/Makefile b/components/Makefile index 06af460559b..bbe00840f37 100644 --- a/components/Makefile +++ b/components/Makefile @@ -73,6 +73,7 @@ publish-branch: download: TARGET = download update-metadata: TARGET = update-metadata +generate-package-kdl: TARGET = generate-package-kdl prep: TARGET = prep build: TARGET = build install: TARGET = install @@ -102,6 +103,8 @@ download prep: $(COMPONENT_DIRS.nosetup) update-metadata: $(COMPONENT_DIRS.nolog) +generate-package-kdl: $(COMPONENT_DIRS.nolog) + component-hook: $(COMPONENT_DIRS.nosetup) clean: $(COMPONENT_DIRS.nosetup) diff --git a/make-rules/common.mk b/make-rules/common.mk index b0e44442bc6..6756361d241 100644 --- a/make-rules/common.mk +++ b/make-rules/common.mk @@ -240,3 +240,5 @@ COMPONENT_BUILD_CMAKE_ARGS += -j$(PARALLEL_JOBS) COMPONENT_BUILD_GMAKE_ARGS += -j$(PARALLEL_JOBS) COMPONENT_BUILD_SETUP_PY_ARGS += -j$(PARALLEL_JOBS) endif + +include $(WS_MAKE_RULES)/forge.mk diff --git a/make-rules/forge.mk b/make-rules/forge.mk new file mode 100644 index 00000000000..36b0854affe --- /dev/null +++ b/make-rules/forge.mk @@ -0,0 +1,64 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# +# +# Copyright 2023 Till Wegmueller +# + +# Allow overriding via environment and default to relying on PATH +PKGDEV ?= pkgdev + +# Ensure Cargo-installed tools (e.g., pkgdev) are on PATH +PATH := $(PATH):$(HOME)/.cargo/bin +export PATH + +.PHONY: generate-package-kdl + +# Generate package.kdl using pkgdev with component metadata +generate-package-kdl: + @compname="$(COMPONENT_NAME)"; \ + [ -z "$$compname" ] && compname="$$(/usr/bin/basename "$$PWD")"; \ + if [ -f "package.kdl" ]; then \ + echo "Skipping package.kdl generation for $$compname: package.kdl already exists"; \ + exit 0; \ + fi; \ + missing=""; \ + [ -z "$(COMPONENT_NAME)" ] && missing="$$missing COMPONENT_NAME"; \ + [ -z "$(COMPONENT_FMRI)" ] && missing="$$missing COMPONENT_FMRI"; \ + [ -z "$(COMPONENT_SUMMARY)" ] && missing="$$missing COMPONENT_SUMMARY"; \ + [ -z "$(COMPONENT_CLASSIFICATION)" ] && missing="$$missing COMPONENT_CLASSIFICATION"; \ + [ -z "$(COMPONENT_LICENSE)" ] && missing="$$missing COMPONENT_LICENSE"; \ + [ -z "$(COMPONENT_LICENSE_FILE)" ] && missing="$$missing COMPONENT_LICENSE_FILE"; \ + [ -z "$(COMPONENT_VERSION)" ] && missing="$$missing COMPONENT_VERSION"; \ + [ -z "$(COMPONENT_PROJECT_URL)" ] && missing="$$missing COMPONENT_PROJECT_URL"; \ + [ -z "$(COMPONENT_ARCHIVE_URL)" ] && missing="$$missing COMPONENT_ARCHIVE_URL"; \ + [ -z "$(COMPONENT_ARCHIVE_HASH)" ] && missing="$$missing COMPONENT_ARCHIVE_HASH"; \ + if [ -n "$$missing" ]; then \ + echo "Skipping package.kdl generation for $$compname: missing variables:$$missing"; \ + if [ -n "$(WS_TOP)" ]; then echo "$$compname" >> "$(WS_TOP)/components.missing-metadata"; fi; \ + exit 0; \ + else \ + echo "generating package.kdl for $$compname"; \ + $(PKGDEV) create $(COMPONENT_FMRI); \ + for package in $(REQUIRED_PACKAGES) ; do \ + $(PKGDEV) edit add dependency --dev --kind require $$package ; \ + done; \ + $(PKGDEV) edit set project-name "$(COMPONENT_NAME)"; \ + $(PKGDEV) edit set summary "$(COMPONENT_SUMMARY)"; \ + $(PKGDEV) edit set classification "$(COMPONENT_CLASSIFICATION)"; \ + $(PKGDEV) edit set license "$(COMPONENT_LICENSE)" -f "$(COMPONENT_LICENSE_FILE)"; \ + $(PKGDEV) edit set version "$(COMPONENT_VERSION)"; \ + $(PKGDEV) edit set project-url "$(COMPONENT_PROJECT_URL)"; \ + $(PKGDEV) edit add source archive "$(COMPONENT_ARCHIVE_URL)" "$(COMPONENT_ARCHIVE_HASH)"; \ + if [ -d "patches" ]; then $(PKGDEV) edit add source patch patches; fi; \ + if [ "$(strip $(BUILD_STYLE))" = "configure" ]; then \ + $(PKGDEV) edit add build --gate $(WS_TOP)/userland-gate.kdl configure $(foreach var,$(CONFIGURE_OPTIONS),"$(var)"); \ + fi; \ + fi diff --git a/make-rules/ips.mk b/make-rules/ips.mk index 037ab95663b..7102a7e0532 100644 --- a/make-rules/ips.mk +++ b/make-rules/ips.mk @@ -320,7 +320,7 @@ PUBLISH_STAMP ?= $(BUILD_DIR)/.published-$(MACH) # Do all that is needed to ensure the package is consistent for publishing, # except actually pushing to a repo, separately from the push to the repo. pre-publish: build install $(PRE_PUBLISH_STAMP) -publish: pre-publish update-metadata $(PUBLISH_STAMP) +publish: generate-package-kdl pre-publish update-metadata $(PUBLISH_STAMP) sample-manifest: $(GENERATED).p5m diff --git a/userland-gate.kdl b/userland-gate.kdl new file mode 100644 index 00000000000..a09fdce159f --- /dev/null +++ b/userland-gate.kdl @@ -0,0 +1,19 @@ +name "userland" +version "0.5.11" +branch "2025.0.0" +publisher "openindiana.org" + +metadata-transform matcher="--libexecdir" replacement="--libexecdir=${LIBEXECDIR}" +metadata-transform matcher="--bindir" replacement="--bindir=${BINDIR}" +metadata-transform matcher="--sbindir" replacement="--sbindir=${SBINDIR}" +metadata-transform matcher="--mandir" replacement="--mandir=${MANDIR}" +metadata-transform matcher="--libdir" replacement="--libdir=${LIBDIR}" +metadata-transform matcher="--with-jobs" drop=true +metadata-transform matcher="CC" drop=true +metadata-transform matcher="CXX" drop=true +metadata-transform matcher="F77" drop=true +metadata-transform matcher="FC" drop=true +metadata-transform matcher="FFLAGS" drop=true +metadata-transform matcher="CFLAGS" drop=true +metadata-transform matcher="LDFLAGS" drop=true +metadata-transform matcher="PKG_CONFIG_PATH" drop=true \ No newline at end of file