Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace packages.txt with calculated graph #2318

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/pull-request-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ addressed, and remove any items that are not relevant to this PR.
- [ ] Alternatively, the PR is marked as related to a pre-existing package request bug, such as a dependency
- [ ] REQUIRED - The package is available under an OSI-approved or FSF-approved license
- [ ] REQUIRED - The version of the package is still receiving security updates
- [ ] REQUIRED - The package is added to `packages.txt`

#### For security-related PRs
<!-- remove if unrelated -->
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
branches:
- gh-readonly-queue/main/**

env:
WOLFICTL: "docker run -it --rm --entrypoint=wolfictl ghcr.io/wolfi-dev/sdk:latest@sha256:fd8c71214f6455c75ec44ae99eb9f7ffc85f260ccce69d4367eb2e5d568facd9 wolfictl"
jobs:
changes:
name: Determine packages to test building
Expand All @@ -28,17 +30,13 @@ jobs:
- name: Build package list
id: package-list
run: |
# Ensure there is a newline at the end of packages.txt to avoid `read` from ignoring
# the last entry.
echo >> $GITHUB_WORKSPACE/packages.txt

printf "packages=" >> $GITHUB_OUTPUT

while read pkg; do
make list | while read pkg; do
for file in ${{ steps.changes.outputs.all_changed_files }}; do
[ "${file%.yaml}" = "$pkg" ] && printf "%s " ${file%.yaml} >> $GITHUB_OUTPUT
done
done < $GITHUB_WORKSPACE/packages.txt
done

printf "\n" >> $GITHUB_OUTPUT

Expand Down Expand Up @@ -72,7 +70,7 @@ jobs:
- name: 'Build Wolfi'
run: |
for package in ${{needs.changes.outputs.packages}}; do
make MELANGE="melange" MELANGE_EXTRA_OPTS="--create-build-log" REPO="$GITHUB_WORKSPACE/packages" BUILDWORLD=no packages/$package -j1
make MELANGE="melange" MELANGE_EXTRA_OPTS="--create-build-log" REPO="$GITHUB_WORKSPACE/packages" BUILDWORLD=no package/$package -j1
done

- name: Check for file
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wolfictl-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: docker://ghcr.io/wolfi-dev/wolfictl:latest@sha256:5876ee08b32ee3e9ff0d4c83867d168bbefe6b1e6cc5bee1f07442e5493ca6e4
with:
entrypoint: wolfictl
args: lint
args: lint --skip-rule no-makefile-entry-for-package
- name: Enforce YAML formatting
id: lint-yaml
uses: docker://ghcr.io/wolfi-dev/wolfictl:latest@sha256:5876ee08b32ee3e9ff0d4c83867d168bbefe6b1e6cc5bee1f07442e5493ca6e4
Expand Down
6 changes: 0 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ Wolfi packages are built using melange. If you want to learn how packages are bu

Start by cloning this repository and create a YAML file named `<your-package-name>.yaml` in its root directory. If you have any patches, create a folder with the same name and put them there.

Add a new entry for your package near the bottom of [`packages.txt`](packages.txt) like this:

```
your-package-name
```

Once you're done writing the new package configuration file, you can test it by triggering a build with `make packages/<your-package-name> BUILDWORLD=no USE_CACHE=no`.

note: `USE_CACHE=no` disables using a GCP cloud bucket for caching pipeline sources. This is mainly used for production setups and not needed for local development.
Expand Down
41 changes: 16 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ endif
TARGETDIR = packages/${ARCH}

MELANGE ?= $(shell which melange)
WOLFICTL ?= $(shell which wolfictl)
KEY ?= local-melange.rsa
REPO ?= $(shell pwd)/packages
CACHE_DIR ?= gs://wolfi-sources/
Expand All @@ -32,11 +33,8 @@ MELANGE_OPTS += -r ${WOLFI_PROD}
endif

# The list of packages to be built. The order matters.
# At some point, when ready, this should be replaced with `wolfictl text -t name .`
# non-standard source directories are provided by adding them separated by a comma,
# e.g.
# postgres-11,postgres
PKGLIST ?= $(shell cat packages.txt | grep -v '^\#' )
# wolfictl determines the list and order
PKGLIST ?= $(shell $(WOLFICTL) text --dir . --type name)

all: ${KEY} .build-packages

Expand All @@ -48,31 +46,24 @@ clean:

.PHONY: list list-yaml
list:
$(info $(PKGNAMELIST))
$(info $(PKGLIST))
@printf ''

list-yaml:
$(info $(addsuffix .yaml,$(PKGNAMELIST)))
$(info $(addsuffix .yaml,$(PKGLIST)))
@printf ''

.packagerules: Makefile .git/HEAD packages.txt
@echo "Solving build order, please wait..."
@grep -v '^\#' packages.txt | while read pkg; do \
pkgname=`echo $$pkg | cut -d, -f1`; \
pkgdir=`echo $$pkg | cut -d, -f2`; \
[ -z "$$pkgdir" ] && pkgdir=$$pkgname; \
pkgver=`${MELANGE} package-version $${pkgname}.yaml`; \
pkgtarget="${TARGETDIR}/$${pkgver}.apk"; \
echo "PKGNAMELIST += $$pkgname"; \
echo ".build-packages: $$pkgtarget"; \
echo "packages/$$pkgname: $$pkgtarget"; \
echo "$$pkgtarget: $${pkgname}.yaml \$${KEY}"; \
printf "\t%s\n" "@mkdir -p ./$${pkgdir}/"; \
printf "\t%s" "SDE=\$${SOURCE_DATE_EPOCH}; [ -z \"\$$\$$SDE\" ] && SDE=\`git log -1 --pretty=%ct --follow $${pkgname}.yaml\`;"; \
printf "\t%s\n\n" "SOURCE_DATE_EPOCH=\$$\$$SDE \$${MELANGE} build $${pkgname}.yaml \$${MELANGE_OPTS} --source-dir ./$${pkgdir}/ --log-policy builtin:stderr,\$${TARGETDIR}/buildlogs/$${pkgver}.log"; \
done > .packagerules
.build-packages: $(addprefix package/,${PKGLIST})

-include .packagerules
package/%:
$(eval yamlfile := $*.yaml)
$(eval pkgver := $(shell $(MELANGE) package-version $(yamlfile)))
$(MAKE) yamlfile=$(yamlfile) pkgname=$* packages/$(ARCH)/$(pkgver).apk

packages/$(ARCH)/%.apk: $(KEY)
@mkdir -p ./$(pkgname)/
$(eval SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct --follow $(yamlfile)))
@SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) $(MELANGE) build $(yamlfile) $(MELANGE_OPTS) --source-dir ./$(pkgname)/ --log-policy builtin:stderr,$(TARGETDIR)/buildlogs/$*.log

dev-container:
docker run --privileged --rm -it -v "${PWD}:${PWD}" -w "${PWD}" ghcr.io/wolfi-dev/sdk:latest@sha256:3ef78225a85ab45f46faac66603c9da2877489deb643174ba1e42d8cbf0e0644
docker run --privileged --rm -it -v "${PWD}:${PWD}" -w "${PWD}" ghcr.io/wolfi-dev/sdk:latest@sha256:3ba6e392eff7f09493c62b8a6bff4b9378ecccc27e5dc4ba0fa9f2a0e95c666f
1 change: 1 addition & 0 deletions bazel-5
1 change: 1 addition & 0 deletions bazel-6
6 changes: 0 additions & 6 deletions lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ makepkgs=$(make list-yaml)
for f in *.yaml; do
echo "---" $f

# Check that every package is listed in packages.txt
if ! echo "$makepkgs" | grep -wq "$f"; then
echo "missing $f in packages.txt"
exit 1
fi

# Don't specify packages.wolfi.dev/os as a repository, and remove it from the keyring.
# Packages from the bootstrap repo should be allowed, but otherwise packages
# should be fetched locally and the local repository should be appended at
Expand Down
1 change: 1 addition & 0 deletions mariadb-10.11
1 change: 1 addition & 0 deletions mariadb-10.6
1 change: 1 addition & 0 deletions postgresql-11
1 change: 1 addition & 0 deletions postgresql-12
1 change: 1 addition & 0 deletions postgresql-13
1 change: 1 addition & 0 deletions postgresql-14
1 change: 1 addition & 0 deletions postgresql-15