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

Add a Freedesktop SDK based image #173

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
63 changes: 63 additions & 0 deletions .github/workflows/bst-build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
on:
pull_request:
paths:
- '.github/workflows/bst-build-test.yml'
- 'buildstream/**'
branches:
- master
push:
paths:
- '.github/workflows/bst-build-test.yml'
- 'buildstream/**'
branches-ignore:
- master

name: BuildStream Build Test
jobs:
buildstream:
name: Build
runs-on: ubuntu-22.04

steps:
# This action maximize the space provided by the runner which makes it more viable for BuildStream
# As a volume mounted to the GitHub workspace directory
- uses: easimon/maximize-build-space@v10
with:
remove-dotnet: true
remove-android: true
remove-haskell: true
remove-codeql: true
remove-docker-images: true
# Keep 10 GiB to have the same environment as bst-push-image.yml
root-reserve-mb: 10240

- name: Install BuildStream
run: |
mkdir ~/.local/bin
wget https://gitlab.com/BuildGrid/buildbox/buildbox-integration/-/releases/1.1.0/downloads/buildbox-x86_64-linux-gnu.tgz
tar -xvzf buildbox-x86_64-linux-gnu.tgz -C ~/.local/bin
rm -rf buildbox-x86_64-linux-gnu.tgz

sudo apt-get install bubblewrap fuse3 git lzip patch python3
sudo apt-get install g++ python3-dev python3-pip

sudo apt-get install python3-{arpy,dulwich,requests,tomli}

pip3 install --user BuildStream==2.1.0

- name: Write BuildStream config
# Make BuildStream use the workspace volume
run: |
mkdir -p ~/.config
cat >> ~/.config/buildstream2.conf << EOF
sourcedir: ${GITHUB_WORKSPACE}/.bst/sources
cachedir: ${GITHUB_WORKSPACE}/.bst
logdir: ${GITHUB_WORKSPACE}/.bst/logs
EOF

- uses: actions/checkout@v4

- name: Build Image
working-directory: ./buildstream
run: |
bst --on-error continue build oci/tooling-ghcr-flatpak.bst
82 changes: 82 additions & 0 deletions .github/workflows/bst-push-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
on:
push:
paths:
- '.github/workflows/bst-push-image.yml'
- 'buildstream/**'
branches:
- master
concurrency:
group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}'
cancel-in-progress: true

name: BuildStream Push Image
env:
bst-filename: oci/tooling-ghcr-${{ github.repository_owner }}.bst
jobs:
buildstream:
name: Build and Push
runs-on: ubuntu-22.04

steps:
# This action maximize the space provided by the runner which makes it more viable for BuildStream
# As a volume mounted to the GitHub workspace directory
- uses: easimon/maximize-build-space@v10
with:
remove-dotnet: true
remove-android: true
remove-haskell: true
remove-codeql: true
remove-docker-images: true
# Keep 10 GiB rather than 1 to allow Podman to store an image
root-reserve-mb: 10240

- name: Install BuildStream
run: |
mkdir ~/.local/bin
wget https://gitlab.com/BuildGrid/buildbox/buildbox-integration/-/releases/1.1.0/downloads/buildbox-x86_64-linux-gnu.tgz
tar -xvzf buildbox-x86_64-linux-gnu.tgz -C ~/.local/bin
rm -rf buildbox-x86_64-linux-gnu.tgz

sudo apt-get install bubblewrap fuse3 git lzip patch python3
sudo apt-get install g++ python3-dev python3-pip

sudo apt-get install python3-{arpy,dulwich,requests,tomli}

pip3 install --user BuildStream==2.1.0

- name: Write BuildStream config
# Make BuildStream use the workspace volume
run: |
mkdir -p ~/.config
cat >> ~/.config/buildstream2.conf << EOF
sourcedir: ${GITHUB_WORKSPACE}/.bst/sources
cachedir: ${GITHUB_WORKSPACE}/.bst
logdir: ${GITHUB_WORKSPACE}/.bst/logs
EOF

- uses: actions/checkout@v4

- name: Create ${{ env.bst-filename }} if not present
working-directory: ./buildstream/elements
run: |
if [[ ! -f ${{ env.bst-filename }} ]]; then
cp oci/tooling-ghcr-flatpak.bst ${{ env.bst-filename }}

sed -i 's|ghcr.io/flatpak|ghcr.io/${{ github.repository_owner }}|g' ${{ env.bst-filename }}
fi

- name: Build Image
working-directory: ./buildstream
run: |
bst --on-error continue build ${{ env.bst-filename }}
bst --on-error continue artifact checkout ${{ env.bst-filename }} --tar image.tar
podman load -i image.tar

- name: Push To Registry
uses: redhat-actions/push-to-registry@v2
with:
image: flatpak-github-actions
tags: base-x86_64
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ github.token }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ node_modules
.vscode
package-lock.json
.flatpak
__pycache__
.bst
3 changes: 3 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[default.extend-identifiers]
flate2 = "flate2"

[files]
extend-exclude = ["**/dist/index.js"]
45 changes: 45 additions & 0 deletions buildstream/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## Test build locally

### Tooling without building OCI image
```
bst build tooling.bst
```

### OCI image
```
bst build oci/tooling-ghcr-flatpak.bst
```

## Update an element with Rust crates

Update the first elements source that have not cargo as kind then do following command, crates will then be updated.

```
bst source track components/NAME_OF_THE_ELEMENT.bst
```

## Update junctions

```
bst source track freedesktop-sdk.bst
bst source track gnome-build-meta.bst
```

Both junctions are now update to the latest commit of their release branch

### Note for future update
- Freedesktop SDK can't be updated until flatpak-builder-lint supports lxml 5

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could bundle older lxml though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to limit how much the Github Action builds since we have not much space, so no deep override on the Freedesktop junction.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Freedesktop SDK 23.08 broke the Python "API" by bumping lxml 4 to lxml 5, from far it does not look like a good thing to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you meant side-by-side instalation, I don't how to do that with pypi sources. It really looks like it is not possible.


## Upgrade junctions

1. Check on which Freedesktop SDK branch is used by GNOME Build Meta to know if Freedesktop SDK should/can be upgraded

2. Change `track` in junctions' sources to the new release branch.

3. Update junctions to track the last commit

4. Test build `tooling.bst`

### Note for future upgrade
- Check if a element in the components folder was added in Freedesktop SDK or GNOME Build Meta, if it does replace the local element by the junction
- git-lfs will be an element from Freedesktop SDK in 24.08, it is actually a GNOME Build Meta element for now
16 changes: 16 additions & 0 deletions buildstream/elements/components/binfmt-support.bst
Copy link

@alatiera alatiera Feb 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could avoid needing binfmt-support by adding a config in /etc/binfmt.d systemd should already be providing the binfmt service and it probably will work in the container too.

https://www.man7.org/linux/man-pages/man5/binfmt.d.5.html

Copy link
Contributor Author

@tytan652 tytan652 Feb 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Systemd services is a no-go/op in Docker

Copy link
Contributor Author

@tytan652 tytan652 Feb 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And binfmt requires privileged access

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
kind: autotools

build-depends:
- freedesktop-sdk.bst:public-stacks/buildsystem-autotools.bst

depends:
- freedesktop-sdk.bst:components/libpipeline.bst

variables:
conf-local: >-
--disable-upstart

sources:
- kind: tar
url: https://download.savannah.nongnu.org/releases/binfmt-support/binfmt-support-2.2.2.tar.gz
ref: cce14163f9b526283e6f0d00f3be1cfe239fa2c7574e5e0ba8ad3db74166a4a5
25 changes: 25 additions & 0 deletions buildstream/elements/components/flatpak-builder-lint.bst

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be really cool to have flatpak-builder-lint in gnomeos/gnome-build-meta too! wink wink :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad idea, the tool is too unstable to have it on gnome.

Copy link
Contributor Author

@tytan652 tytan652 Feb 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm even thinking about just installing poetry and some linter deps (e.g. desktop-file-utils), because of how much the linter changes (also lxml).

Edit: pip install poetry is fine to pick a specifix version of the linter, and the included linter is updated with its new runtime dependency.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine, it will only be exposed in gnomeos which is building everything from main anyway.

But for CI then we should have both a pinned version of the tool to avoid breaking everyone using the action, as well as installing it at runtime so we only need to bump the version in the action, not rebuild the age too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lxml 4 is still a blocker to add it to GNOME OS since its deps use lxml 5 forevery version relying on newer 23.08 or later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work, we use patches to appstream that are only available in org.flatpak.Builder, without those patches it's not usable. There is a cyclic dependency between the linter and org.flatpak.Builder.

Copy link
Contributor Author

@tytan652 tytan652 Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A problem that should be worked on and avoid to make it worse.

This PR was made before I discover, the mess that the appstream lib transition created.
So a BuildStream based solution will require upstreaming fine fixes.
It is out of question to duplicate patches and use them in this image rather than upstreaming.

Copy link
Contributor Author

@tytan652 tytan652 Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I might drop the linter in the base image (and let the deps) since upstream only support running the master branch which is not good.
This base image is meant to be re-built only when we update/add something not all the time because of one tool.

Copy link
Contributor

@bbhtt bbhtt Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm suggesting to drop this as it doesn't work. Upstream doesn't agree with some of the patches and at the moment it is not possible to come to a solution.

Also the expectation is that Flathub raise or lower new appstream checks as per our needs - that's not possible to do without patches sometimes. ximion/appstream#604 (comment)

Next time, it's probably best to introduce a new check here at a low severity and have Flathub raise it (and only make AppStream raise it too after some time has passed).

Also the linter doesn't do tags now, it's deployed from commits of the master branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the expectation is that Flathub raise or lower new appstream checks as per our needs - that's not possible to do without patches sometimes.

Because you do not create your own libappstream validator with its API rather than patching their executables, I can understand that you don't have the bandwidth to do it for now…
But libappstream (including libappstream-compose) API were made to create appstream tooling more easily with less "reinventing the wheel" situation.

Copy link
Contributor

@bbhtt bbhtt Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API too, doesn't allow lowering severity for most tags that we want to lower, afaik and it's out of the question right now because of maintainability reasons.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine, we can build/bundle whatever version we need for flathub

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine, we can build/bundle whatever version we need for flathub

It specifically requires the patches that live in org.flatpak.Builder package, not just a version of appstream.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea but we can match whatever the setup for that is, it's purpose built images basically for that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the patches are included then it is fine from me, otherwise without them the linter won't work at all.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
kind: manual

build-depends:
- freedesktop-sdk.bst:public-stacks/buildsystem-python-poetry.bst
- freedesktop-sdk.bst:components/python3-pip.bst

depends:
- freedesktop-sdk.bst:components/python3-lxml.bst
- freedesktop-sdk.bst:components/python3-requests.bst
- components/python3-jsonschema.bst
- components/python3-sentry-sdk.bst

runtime-depends:
- freedesktop-sdk.bst:components/desktop-file-utils.bst

config:
install-commands:
- pip install --root=%{install-root} --prefix=%{prefix} . --no-build-isolation

sources:
- kind: git_tag
url: github:flathub-infra/flatpak-builder-lint.git
track: master
track-tags: True
ref: v2.1.5-0-g3bbf1fef98e0a419d97f927a992187ff6d725402
36 changes: 36 additions & 0 deletions buildstream/elements/components/flatpak-builder.bst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
kind: meson

build-depends:
- freedesktop-sdk.bst:public-stacks/buildsystem-meson.bst

depends:
- freedesktop-sdk.bst:bootstrap-import.bst
- freedesktop-sdk.bst:components/curl.bst
- freedesktop-sdk.bst:components/flatpak.bst
- freedesktop-sdk.bst:components/fuse3.bst
- freedesktop-sdk.bst:components/json-glib.bst
- freedesktop-sdk.bst:components/libsoup.bst
- freedesktop-sdk.bst:components/libyaml.bst
- freedesktop-sdk.bst:components/docbook-xsl.bst
- freedesktop-sdk.bst:components/xmlto.bst

runtime-depends:
- freedesktop-sdk.bst:components/git.bst
- freedesktop-sdk.bst:components/tar.bst
- freedesktop-sdk.bst:components/gzip.bst
- freedesktop-sdk.bst:components/zip.bst

variables:
meson-local: >-
-Dtests=false
-Dfuse=3

sources:
- kind: git_repo
url: github:flatpak/flatpak-builder.git
# Stuck on 1.3.3, until the action is ready for 1.4
ref: 1.3.3-0-ga4d9dbc3ab3f339ee0be58e7ae7baa2b0fc721bc
- kind: git_module
path: subprojects/libglnx
url: gnome:libglnx.git
ref: 07e3e49d3e47dfd4265ffb5495111439131715ca
14 changes: 14 additions & 0 deletions buildstream/elements/components/gh-cli.bst

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto as flatpak-builder-lint probably, fits nicely with the devel tooling

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not versed on how to build this project from source, so I used a pre-built binary.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In gnome, we usually build non-gnome components from tarballs or git tags anyway. We only track main for gnome components we have ownership of

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
kind: manual

depends:
- freedesktop-sdk.bst:bootstrap-import.bst

config:
install-commands:
- |
install -Dm755 -t "%{install-root}%{bindir}" bin/gh

sources:
- kind: tar
url: github_files:cli/cli/releases/download/v2.40.1/gh_2.40.1_linux_amd64.tar.gz
ref: 7f34ee83a7dd17addd1d029bc66ec06d91773a93172e3e1e30e0ec3a9f923fe2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
kind: pyproject

build-depends:
- freedesktop-sdk.bst:public-stacks/buildsystem-python-hatchling.bst
- freedesktop-sdk.bst:components/python3-hatch-vcs.bst

depends:
- freedesktop-sdk.bst:components/python3.bst

sources:
- kind: pypi
name: jsonschema-specifications
ref:
sha256sum: 48a76787b3e70f5ed53f1160d2b81f586e4ca6d1548c5de7085d1682674764cc
suffix: f8/b9/cc0cc592e7c195fb8a650c1d5990b10175cf13b4c97465c72ec841de9e4b/jsonschema_specifications-2023.12.1.tar.gz
19 changes: 19 additions & 0 deletions buildstream/elements/components/python3-jsonschema.bst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
kind: pyproject

build-depends:
- freedesktop-sdk.bst:public-stacks/buildsystem-python-hatchling.bst
- freedesktop-sdk.bst:components/python3-hatch-fancy-pypi-readme.bst
- freedesktop-sdk.bst:components/python3-hatch-vcs.bst

depends:
- freedesktop-sdk.bst:components/python3-attrs.bst
- components/python3-jsonschema-specifications.bst
- components/python3-referencing.bst
- components/python3-rpds-py.bst

sources:
- kind: pypi
name: jsonschema
ref:
sha256sum: 4f614fd46d8d61258610998997743ec5492a648b33cf478c1ddc23ed4598a5fa
suffix: a8/74/77bf12d3dd32b764692a71d4200f03429c41eee2e8a9225d344d91c03aff/jsonschema-4.20.0.tar.gz
Loading