Merge branch 'feature/development-environment-quick-install' into development

This commit is contained in:
project-repo 2023-04-16 11:16:24 +02:00
commit 3cfb18f481
18 changed files with 408 additions and 54 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
build
fuzz_corpus
fuzzing-directory

193
README.md
View file

@ -1,6 +1,6 @@
# Cagebreak: A Wayland Tiling Compositor
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/6532/badge)](https://bestpractices.coreinfrastructure.org/projects/6532) [![Packaging status](https://repology.org/badge/tiny-repos/cagebreak.svg)](https://repology.org/project/cagebreak/versions) [![AUR package](https://repology.org/badge/version-for-repo/aur/cagebreak.svg?minversion=2.1.0)](https://repology.org/project/cagebreak/versions)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/6532/badge)](https://bestpractices.coreinfrastructure.org/projects/6532) [![Packaging status](https://repology.org/badge/tiny-repos/cagebreak.svg)](https://repology.org/project/cagebreak/versions) [![AUR package](https://repology.org/badge/version-for-repo/aur/cagebreak.svg?minversion=2.1.1)](https://repology.org/project/cagebreak/versions)
## Quick Introduction
@ -260,6 +260,135 @@ need to ask for the distribution the user was having the issue on.)).
You should use Arch Linux if you want to modify Cagebreak
for yourself.
#### Development Environment
CAVEAT: This script works exclusively on Arch Linux, which, as outlined above,
is the development distribution of Cagebreak.
Cloning the Cagebreak repository and building it is sufficient as a starting point.
All other dependencies can be installed by invoking
```
meson compile devel-install -C build
```
if meson is already available or
```
./scripts/install-development-environment
```
otherwise.
#### Scripts
Cagebreak provides a few convenience tools to facilitate development.
##### Fuzzing
If your fuzzing corpus is located in the directory `fuzz_corpus` you can
just call:
```
meson compile fuzz -C build
```
If you want to use a different directory, configure cagebreak with
`-Dcorpus=OTHERDIRECTORY` or call `./scripts/fuzz OTHERDIRECTORY`.
##### Adjusting Epoch
To facilitate the creation of reproducible man pages an arbitrary release
time has to be set in `meson.build`:
```
meson compile adjust-epoch -C build
```
or
```
./scripts/adjust-epoch
```
##### Git tag
If you are on the master branch, everything is ready and you want to create
a release tag you can call:
```
meson compile git-tag -C build
```
If you want to use another signing key than the prespecified one, configure
Cagebreak with `-Dgpg_id=GPGID`.
```
./scripts/git-tag GPGID CBVERSION
```
can be used alternatively.
##### Output Hashes
Hashes of release versions of all binaries can be output to `local-hashes.txt`
via:
```
meson compile output-hashes -C build
```
Or
```
./scripts/output-hashes VERSION
```
if meson is unavailable.
##### Create Signatures
Creation of signatures for releases can be achieved through:
```
meson compile create-sigs -C build
```
Configure Cagebreak with `-Dgpg_id=GPGID` for a different gpg signing
key.
Without meson use:
```
./scripts/create-signatures GPGID
```
##### Set Version Number
Once the version number is set within meson.build, you can use
```
meson compile set-ver -C build
```
to set the version number in the man pages and README repology minversion.
Use of the script without meson is discouraged because meson.build is
not touched by the script.
##### Create Release Artefacts
The following command generates the release artefacts which must be created
once a release is completely ready to be published (the commit is tagged with
the version of the master branch, etc.):
```
meson compile create-artefacts -C build
```
Use of the script version is discouraged.
### GCC and -fanalyzer
Cagebreak should compile with any reasonably new gcc or clang. Consider
@ -364,7 +493,7 @@ find bugs in other areas of the code.
#### Caveat
Currently, there are memory leaks which do not seem to stem from our code but rather
the code of wl-roots or some other library we depend on. We are working on the problem.
the code of wlroots or some other library we depend on. We are working on the problem.
In the meantime, add `-Db_detect-leaks=0` to the meson command to exclude memory leaks.
### Reproducible Builds
@ -466,6 +595,9 @@ The release procedure outlines the process for a release to occur.
* [ ] Adjust version number
* [ ] meson.build
* [ ] git tag
* [ ] Update internal wiki
* [ ] Adjust version number in meson.build
* [ ] `meson compile set-ver -C build`
* [ ] Relevant Documentation completed
* [ ] New features
* [ ] tests added and old test scripts adjusted
@ -474,43 +606,32 @@ The release procedure outlines the process for a release to occur.
* [ ] cagebreak-config
* [ ] cagebreak-socket
* [ ] example config
* [ ] Set EPOCH to release day in man generation in meson.build
* [ ] FAQ.md
* [ ] Changelog.md for major and minor releases but not patches
* [ ] Check features for SECURITY.md relevance (changes to socket scope
for example)
* [ ] Synchronize any socket changes to cagebreak-socket man page
* [ ] Updated internal wiki
* [ ] Added new files to meson.build or hardcoded testing variable
* [ ] Fixed bugs documented in Bugs.md
* [ ] Document fixed bugs in Bugs.md
* [ ] Include issue discussion from github, where applicable
* [ ] Added new files to meson.build or hardcoded testing variable
* [ ] Testing
* [ ] Manual testing
* [ ] Libfuzzer testing
* [ ] `meson compile fuzz -C build` for at least one hour
* [ ] Arch Build System is up to date
* [ ] wlr_xdg_shell version check
* [ ] Cagebreak is reproducible on multiple machines
* [ ] Documented reproducible build artefacts
* [ ] Hashes of the artefacts in Hashes.md
* [ ] Renamed previous signatures
* [ ] Created gpg signature of the artefacts
* [ ] `gpg --detach-sign -u keyid cagebreak`
* [ ] `gpg --detach-sign -u keyid cagebreak.1`
* [ ] `gpg --detach-sign -u keyid cagebreak-config.5`
* [ ] `gpg --detach-sign -u keyid cagebreak-socket.7`
* [ ] release-non-auto-checks
* [ ] `meson compile create-signatures -C build`
* [ ] Use `meson compile output-hashes -C build` to add Hashes or aid in repro check
* [ ] Commit and push signatures and hashes
* [ ] `meson test -C build`
* [ ] `git add` relevant files
* [ ] `git commit`
* [ ] `git push origin development`
* [ ] Determined commit and tag message (Start with "Release version_number\n\n")
* [ ] Mentioned fixed Bugs.md issues ("Fixed Issue n")
* [ ] Mentioned other important changes
* [ ] `git checkout master`
* [ ] `git merge --squash development`
* [ ] `git commit` and insert message
* [ ] `git tag -u keyid version HEAD` and insert message
* [ ] `git tag -v version` and check output
* [ ] `meson test -C build/` last check before the push
* [ ] `meson compile git-tag -C build`
* [ ] `meson compile create-artefacts -C build`
* [ ] `meson test -C build` THIS MUST PASS WITHOUT ANY FAILURES WHATSOEVER
* [ ] `git push --tags origin master`
* [ ] `git checkout development` (merge to development depends on whether release was a hotfix)
* [ ] `git merge master`
@ -518,32 +639,6 @@ The release procedure outlines the process for a release to occur.
* [ ] `git checkout hotfix` (hotfix is to be kept current with master after releases)
* [ ] `git merge master`
* [ ] `git push --tags origin hotfix`
* [ ] `git archive --prefix=cagebreak/ -o release_version.tar.gz tags/version .`
* [ ] Create release-artefacts_version.tar.gz
* [ ] `mkdir release-artefacts_version`
* [ ] `cp build/cagebreak release-artefacts_version/`
* [ ] `cp build/cagebreak.sig release-artefacts_version/`
* [ ] `cp build/cagebreak.1 release-artefacts_version/`
* [ ] `cp build/cagebreak.1.sig release-artefacts_version/`
* [ ] `cp build/cagebreak-config.5 release-artefacts_version/`
* [ ] `cp build/cagebreak-config.5.sig release-artefacts_version/`
* [ ] `cp build/cagebreak-socket.7 release-artefacts_version/`
* [ ] `cp build/cagebreak-socket.7.sig release-artefacts_version/`
* [ ] `cp LICENSE release-artefacts_version/`
* [ ] `cp README.md release-artefacts_version/`
* [ ] `cp SECURITY.md release-artefacts_version/`
* [ ] `cp FAQ.md release-artefacts_version/`
* [ ] `export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) ; tar --sort=name --mtime= --owner=0 --group=0 --numeric-owner -czf release-artefacts_version.tar.gz release-artefacts_version`
* [ ] Checked archive
* [ ] tar -xvf release_version.tar.gz
* [ ] cd cagebreak
* [ ] meson setup build -Dxwayland=true -Dman-pages=true --buildtype=release
* [ ] ninja -C build
* [ ] gpg --verify ../signatures/cagebreak.sig build/cagebreak
* [ ] cd ..
* [ ] rm -rf cagebreak
* [ ] `gpg --detach-sign -u keyid release_version.tar.gz`
* [ ] `gpg --detach-sign -u keyid release-artefacts_version.tar.gz`
* [ ] Upload archives and signatures as release assets
## Roadmap

View file

@ -1,4 +1,4 @@
cagebreak-config(5) "Version 2.1.0" "Cagebreak Manual"
cagebreak-config(5) "VERSION 2.1.1" "Cagebreak Manual"
# NAME

View file

@ -1,4 +1,4 @@
cagebreak-socket(7) "Version 2.1.0" "Cagebreak Manual"
cagebreak-socket(7) "VERSION 2.1.1" "Cagebreak Manual"
# NAME

View file

@ -1,4 +1,4 @@
cagebreak(1) "Version 2.1.0" "Cagebreak Manual"
cagebreak(1) "VERSION 2.1.1" "Cagebreak Manual"
# NAME

View file

@ -3,7 +3,7 @@
project(
'cagebreak',
'c',
version : '2.1.0',
version : '2.1.1',
license : 'MIT',
default_options : ['c_std=c11', 'warning_level=3']
)
@ -344,6 +344,30 @@ summary = [
]
message('\n'.join(summary))
run_target('devel-install',
command : ['scripts/install-development-environment'])
run_target('fuzz',
command : ['scripts/fuzz', get_option('corpus')])
run_target('adjust-epoch',
command : ['scripts/adjust-epoch'])
run_target('git-tag',
command : ['scripts/git-tag', get_option('gpg_id'), meson.project_version()])
run_target('output-hashes',
command : ['scripts/output-hashes', meson.project_version()])
run_target('create-sigs',
command : ['scripts/create-signatures', get_option('gpg_id')])
run_target('set-ver',
command : ['scripts/set-version', meson.project_version()])
run_target('create-artefacts',
command : ['scripts/create-release-artefacts', get_option('gpg_id'), meson.project_version()])
# Test Suite
test('Build without warnings', find_program('test/build-w-o-warnings'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel')
@ -360,3 +384,4 @@ test('Signature validity', find_program('test/gpg-signatures'), suite: 'release'
test('Hashes.md', find_program('test/hashes-md'), args : [ meson.project_version() ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'release')
test('Non-auto tests', find_program('test/non-auto-tests'), args : [ meson.project_version() ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'release')
test('Git tag', find_program('test/git-tag'), args : [ meson.project_version() ], suite: 'release')
test('Release-artefacts', find_program('test/check-artefacts'), args : [ meson.project_version() ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'release')

View file

@ -4,3 +4,5 @@ option('xwayland', type: 'boolean', value: 'false', description: 'Enable support
option('man-pages', type: 'boolean', value: 'false', description: 'Build man pages (requires pandoc)')
option('fuzz', type: 'boolean', value: 'false', description: 'Enable building fuzzer targets')
option('version_override', type: 'string', description: 'Set the project version to the string specified. Used for creating hashes for reproducible builds.')
option('corpus', type: 'string', value: 'fuzz_corpus', description: 'Set fuzzing corpus directory')
option('gpg_id', type: 'string', value: '4E82C72C6B3E58A7BC4FF8554909F84CA83BB867', description: 'Set gpg signing key for cagebreak')

13
scripts/adjust-epoch Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
# Copyright 2023, project-repo and the cagebreak contributors
# SPDX-License-Identifier: MIT
if [[ -n ${MESON_SOURCE_ROOT} ]]
then
# shellcheck disable=2164
cd "${MESON_SOURCE_ROOT}"
fi
# shellcheck disable=2034
ssepoch=$(date +%s)
sed -i -e "/secssinceepoch \=/s/[0-9]*$/$ssepoch/" meson.build

View file

@ -0,0 +1,40 @@
#!/bin/bash
# Copyright 2023, project-repo and the cagebreak contributors
# SPDX-License-Identifier: MIT
if [[ -n ${MESON_SOURCE_ROOT} ]]
then
# shellcheck disable=2164
cd "${MESON_SOURCE_ROOT}"
fi
readonly gpg_id="${1}"
readonly version="${2}"
git archive --prefix=cagebreak/ -o "release_${version}".tar.gz tags/version .
rm -rf "release-artefacts_${version}"
mkdir "release-artefacts_${version}"
rm -rf temp-rel-artefacts
meson setup temp-rel-artefacts -Dxwayland=true -Dman-pages=true --buildtype=release
ninja -C temp-rel-artefacts
cp LICENSE "release-artefacts_${version}"
cp SECURITY.md "release-artefacts_${version}"
cp FAQ.md "release-artefacts_${version}"
cp README.md "release-artefacts_${version}"
cp temp-rel-artefacts/cagebreak "release-artefacts_${version}"
cp temp-rel-artefacts/cagebreak.1 "release-artefacts_${version}"
cp temp-rel-artefacts/cagebreak-config.5 "release-artefacts_${version}"
cp temp-rel-artefacts/cagebreak-socket.7 "release-artefacts_${version}"
cp signatures/cagebreak*.sig "release-artefacts_${version}"
# shellcheck disable=2155
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) ; tar --sort=name --mtime= --owner=0 --group=0 --numeric-owner -czf "release-artefacts_${version}.tar.gz" "release-artefacts_${version}"
gpg -u "${gpg_id}" --detach-sign "release-artefacts_${version}.tar.gz"
gpg -u "${gpg_id}" --detach-sign "release_${version}.tar.gz"
rm -rf temp-rel-artefacts

37
scripts/create-signatures Executable file
View file

@ -0,0 +1,37 @@
#!/bin/bash
# Copyright 2023, project-repo and the cagebreak contributors
# SPDX-License-Identifier: MIT
if [[ -n ${MESON_SOURCE_ROOT} ]]
then
# shellcheck disable=2164
cd "${MESON_SOURCE_ROOT}"
fi
readonly gpg_id="${1}"
# shellcheck disable=2155
readonly old_tags=$(git tag| tail -1)
mv signatures/cagebreak.sig "signatures/${old_tags}-cagebreak.sig"
mv signatures/cagebreak.1.sig "signatures/${old_tags}-cagebreak.1.sig"
mv signatures/cagebreak-config.5.sig "signatures/${old_tags}-cagebreak-config.5.sig"
mv signatures/cagebreak-socket.7.sig "signatures/${old_tags}-cagebreak-socket.7.sig"
git add "signatures/${old_tags}-cagebreak.sig"
git add "signatures/${old_tags}-cagebreak.1.sig"
git add "signatures/${old_tags}-cagebreak-config.5.sig"
git add "signatures/${old_tags}-cagebreak-socket.7.sig"
rm -rf temp-sigs
meson setup temp-sigs -Dxwayland=true -Dman-pages=true --buildtype=release
ninja -C temp-sigs
gpg -u "${gpg_id}" --detach-sign temp-sigs/cagebreak
gpg -u "${gpg_id}" --detach-sign temp-sigs/cagebreak.1
gpg -u "${gpg_id}" --detach-sign temp-sigs/cagebreak-config.5
gpg -u "${gpg_id}" --detach-sign temp-sigs/cagebreak-socket.7
cp temp-sigs/*.sig signatures/
rm -rf temp-sigs

17
scripts/fuzz Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
# Copyright 2023, project-repo and the cagebreak contributors
# SPDX-License-Identifier: MIT
readonly fuzzing_corpus="${1}"
if [[ -n ${MESON_SOURCE_ROOT} ]]
then
# shellcheck disable=2164
cd "${MESON_SOURCE_ROOT}"
fi
rm -rf fuzzing-directory
CC=clang meson setup fuzzing-directory -Dfuzz=true -Db_sanitize=address,undefined -Db_lundef=false -Db_detect-leaks=0
ninja -C fuzzing-directory/
WLR_BACKENDS=headless ./fuzzing-directory/fuzz-parse -jobs=12 -max_len=50000 -close_fd_mask=3 "${fuzzing_corpus}"
rm -rf fuzzing-directory

8
scripts/git-tag Executable file
View file

@ -0,0 +1,8 @@
#!/bin/bash
# Copyright 2023, project-repo and the cagebreak contributors
# SPDX-License-Identifier: MIT
readonly gpg_id="${1}"
readonly version="${2}"
git tag -u "${gpg_id}" "${version}" HEAD

View file

@ -0,0 +1,13 @@
#!/bin/bash
# Copyright 2023, project-repo and the cagebreak contributors
# SPDX-License-Identifier: MIT
sudo pacman -Syu --noconfirm git grep sed xev meson ninja clang gcc shellcheck jq openbsd-netcat gnupg binutils alacritty wlroots wayland libxkbcommon cairo pango fontconfig libinput libevdev systemd-libs # systemd-libs is included because of libudev
if [[ -n ${MESON_SOURCE_ROOT} ]]
then
# shellcheck disable=2164
cd "${MESON_SOURCE_ROOT}"
fi
gpg --import keys/*

50
scripts/output-hashes Executable file
View file

@ -0,0 +1,50 @@
#!/bin/bash
# Copyright 2023, project-repo and the cagebreak contributors
# SPDX-License-Identifier: MIT
if [[ -n ${MESON_SOURCE_ROOT} ]]
then
# shellcheck disable=2164
cd "${MESON_SOURCE_ROOT}"
fi
readonly version="${1}"
rm -rf hashes
meson setup hashes -Dxwayland=true -Dman-pages=true --buildtype=release
ninja -C hashes
cb256=$(sha256sum hashes/cagebreak | cut -d " " -f1)
cb512=$(sha512sum hashes/cagebreak | cut -d " " -f1)
cb1man256=$(sha256sum hashes/cagebreak.1 | cut -d " " -f1)
cb1man512=$(sha512sum hashes/cagebreak.1 | cut -d " " -f1)
cb5man256=$(sha256sum hashes/cagebreak-config.5 | cut -d " " -f1)
cb5man512=$(sha512sum hashes/cagebreak-config.5 | cut -d " " -f1)
cb7man256=$(sha256sum hashes/cagebreak-socket.7 | cut -d " " -f1)
cb7man512=$(sha512sum hashes/cagebreak-socket.7 | cut -d " " -f1)
echo "${version} cagebreak
* sha 256: ${cb256}
* sha 512: ${cb512}
${version} cagebreak.1
* sha 256: ${cb1man256}
* sha 512: ${cb1man512}
${version} cagebreak-config.5
* sha 256: ${cb5man256}
* sha 512: ${cb5man512}
${version} cagebreak-socket.7
* sha 256: ${cb7man256}
* sha 512: ${cb7man512}
" > local-hashes.txt
rm -rf hashes

20
scripts/set-version Executable file
View file

@ -0,0 +1,20 @@
#!/bin/bash
# Copyright 2023, project-repo and the cagebreak contributors
# SPDX-License-Identifier: MIT
# TODO man pages
if [[ -n ${MESON_SOURCE_ROOT} ]]
then
# shellcheck disable=2164
cd "${MESON_SOURCE_ROOT}"
fi
# shellcheck disable=2034
version="${1}"
sed -i -e "s/minversion\=[0-9]*\.[0-9]*.[0-9]*/minversion=$version/" README.md
sed -i -e "s/Version [0-9]*\.[0-9]*.[0-9]*/VERSION $version/" man/cagebreak.1.md
sed -i -e "s/Version [0-9]*\.[0-9]*.[0-9]*/VERSION $version/" man/cagebreak-config.5.md
sed -i -e "s/Version [0-9]*\.[0-9]*.[0-9]*/VERSION $version/" man/cagebreak-socket.7.md

27
test/check-artefacts Normal file
View file

@ -0,0 +1,27 @@
#! /bin/sh
# Copyright 2023, project-repo and the cagebreak contributors
# SPDX-License-Identifier: MIT
RESULT=0
readonly version="${1}"
# shellcheck disable=SC2164
cd "${MESONCURRENTCONFIGDIR}"
gpg --verify "release_${version}.tar.gz.sig" || RESULT=1
gpg --verify "release-artefacts_${version}.tar.gz.sig" || RESULT=1
tar -xvf "release_${version}.tar.gz"
cd cagebreak || RESULT=1 && exit 1
meson setup build -Dxwayland=true -Dman-pages=true --buildtype=release
ninja -C build
gpg --verify ../signatures/cagebreak.sig build/cagebreak || RESULT=1
gpg --verify ../signatures/cagebreak.1.sig build/cagebreak.1 || RESULT=1
gpg --verify ../signatures/cagebreak-config.5.sig build/cagebreak-config.5 || RESULT=1
gpg --verify ../signatures/cagebreak-socket.7.sig build/cagebreak-socket.7 || RESULT=1
# shellcheck disable=2103
cd ..
rm -rf cagebreak
exit "${RESULT}"

View file

@ -10,7 +10,9 @@ readonly test_deps=$(cd "${MESONCURRENTCONFIGDIR}" ; find . -type f | grep test/
readonly examples_deps=$(cd "${MESONCURRENTCONFIGDIR}" ; find . -type f | grep examples/)
# shellcheck disable=2155,2164,2046
readonly example_scripts_deps=$(cd "${MESONCURRENTCONFIGDIR}" ; find . -type f | grep example_scripts/)
readonly deps="${declared_deps} ${hardcoded_deps} ${test_deps} ${examples_deps} ${example_scripts_deps}"
# shellcheck disable=2155,2164,2046
readonly scripts_deps=$(cd "${MESONCURRENTCONFIGDIR}" ; find . -type f | grep scripts/)
readonly deps="${declared_deps} ${hardcoded_deps} ${test_deps} ${examples_deps} ${example_scripts_deps} ${scripts_deps}"
# shellcheck disable=2046,2155
readonly curryear=$(date +%Y)

View file

@ -12,4 +12,7 @@ shellcheck --source-path=../example_scripts/ $(ls -Itesting-configurations) || R
cd "${MESONCURRENTCONFIGDIR}/example_scripts/" || RESULT=1
shellcheck ./* || RESULT=1
cd "${MESONCURRENTCONFIGDIR}/scripts/" || RESULT=1
shellcheck ./* || RESULT=1
exit "${RESULT}"