Skip to content

Commit f670f86

Browse files
committed
meta: Simplified bootstraping cutekit using uv.
1 parent fd4eb8f commit f670f86

File tree

15 files changed

+154
-149
lines changed

15 files changed

+154
-149
lines changed

.github/workflows/check-darwin.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,11 @@ jobs:
1212
with:
1313
fetch-depth: 0
1414

15-
- name: Setup Python
16-
uses: actions/setup-python@v3
17-
with:
18-
python-version: '3.13'
19-
2015
- name: Setup Build Environment
2116
run: ./ck tools setup && ./ck tools doctor
2217

2318
- name: Build Libraries (Host)
24-
run: ./ck builder build
19+
run: ./ck build
2520

2621
- name: Test Libraries (Host)
27-
run: ./ck builder test
22+
run: ./ck test

.github/workflows/checks-linux.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,14 @@ jobs:
1111
with:
1212
fetch-depth: 0
1313

14-
- name: Setup Python
15-
uses: actions/setup-python@v3
16-
with:
17-
python-version: '3.13'
18-
1914
- name: Setup Build Environment
2015
run: ./ck tools setup && ./ck tools doctor
2116

22-
2317
- name: Build Libraries
24-
run: ./ck builder build
18+
run: ./ck build
2519

2620
- name: Test Libraries
27-
run: ./ck builder test
21+
run: ./ck test
2822

2923
- name: Run Reftests
3024
run: ./ck reftests run --headless
31-
32-
- name: Check for formatting errors
33-
run: ./meta/scripts/style-check.sh || echo "Please run ./meta/scripts/style-format.sh"

ck

Lines changed: 3 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,7 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
set -e
44

5-
function is_ubuntu() {
6-
if [ -f /etc/os-release ]; then
7-
grep -q "ubuntu" /etc/os-release
8-
return $?
9-
fi
10-
return 1
11-
}
12-
13-
function is_debian() {
14-
if [ -f /etc/os-release ]; then
15-
grep -q "debian" /etc/os-release
16-
return $?
17-
fi
18-
return 1
19-
}
20-
21-
function is_darwin() {
22-
if [ "$(uname)" == "Darwin" ]; then
23-
return 0
24-
fi
25-
return 1
26-
}
27-
28-
function is_arch() {
29-
if [ -f /etc/os-release ]; then
30-
grep -q "Arch Linux" /etc/os-release
31-
return $?
32-
fi
33-
return 1
34-
}
35-
36-
if [ "$EUID" -eq 0 ]; then
37-
export CUTEKIT_ELEVATOR=""
38-
elif [ -z "$CUTEKIT_ELEVATOR" ]; then
39-
export CUTEKIT_ELEVATOR="sudo"
40-
fi
41-
42-
if [ -z "$CUTEKIT_PYTHON" ]; then
43-
if command -v python3.11 &> /dev/null; then
44-
export CUTEKIT_PYTHON="python3.11"
45-
elif command -v python3.12 &> /dev/null; then
46-
export CUTEKIT_PYTHON="python3.12"
47-
else
48-
export CUTEKIT_PYTHON="python3"
49-
fi
50-
fi
51-
525
if [ "$EUID" -eq 0 ]; then
536
echo "Please do not run this script as root."
547

@@ -61,71 +14,5 @@ if [ "$EUID" -eq 0 ]; then
6114
fi
6215
fi
6316

64-
if [ "$CUTEKIT_NOVENV" == "1" ]; then
65-
echo "CUTEKIT_NOVENV is set, skipping virtual environment setup."
66-
exec cutekit $@
67-
fi
68-
69-
if [ "$1" == "tools" -a "$2" == "nuke" ]; then
70-
rm -rf .cutekit/tools .cutekit/venv .cutekit/tools-ready
71-
exit 0
72-
fi
73-
74-
if [ ! -f .cutekit/tools-ready ]; then
75-
if [ ! \( "$1" == "tools" -a "$2" == "setup" \) ]; then
76-
echo "Tools not installed."
77-
echo "This script will install the tooling required to build Paper Muncher into $PWD/.cutekit"
78-
79-
read -p "Do you want to continue? [Y/n] " -n 1 -r
80-
echo
81-
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
82-
echo "Aborting."
83-
exit 1
84-
fi
85-
else
86-
echo "Installing tools..."
87-
fi
88-
89-
if is_ubuntu; then
90-
echo "Detected Ubuntu, installing dependencies automatically..."
91-
$CUTEKIT_ELEVATOR ./meta/scripts/setup-ubuntu.sh
92-
elif is_debian; then
93-
echo "Detected Debian, installing dependencies automatically..."
94-
$CUTEKIT_ELEVATOR ./meta/scripts/setup-debian.sh
95-
elif is_arch; then
96-
echo "Detected Arch Linux, installing dependencies automatically..."
97-
$CUTEKIT_ELEVATOR ./meta/scripts/setup-arch.sh
98-
elif is_darwin; then
99-
echo "Detected macOS, installing dependencies automatically..."
100-
./meta/scripts/setup-darwin.sh
101-
fi
102-
103-
mkdir -p .cutekit
104-
if [ ! -d .cutekit/venv ]; then
105-
echo "Setting up Python virtual environment..."
106-
$CUTEKIT_PYTHON -m venv .cutekit/venv
107-
fi
108-
source .cutekit/venv/bin/activate
109-
110-
echo "Installing Tools..."
111-
pip3 install -r meta/plugins/requirements.txt
112-
113-
touch .cutekit/tools-ready
114-
echo "Done!"
115-
fi
116-
117-
if [ "$1" == "tools" -a "$2" == "setup" ]; then
118-
echo "Tools already installed."
119-
exit 0
120-
fi
121-
122-
if is_ubuntu; then
123-
source ./meta/scripts/env-ubuntu.sh
124-
elif is_darwin; then
125-
source ./meta/scripts/env-darwin.sh
126-
fi
127-
128-
source .cutekit/venv/bin/activate
129-
export PATH="$PATH:.cutekit/venv/bin"
130-
131-
cutekit $@
17+
source ./meta/scripts/setup-any.sh
18+
meta/scripts/cutekit-wrapper.py $@

meta/packaging/build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
meta/packaging/debian-bookworm/build
6+
meta/packaging/ubuntu-jammy/build
7+
meta/packaging/ubuntu-noble/build

meta/packaging/debian-bookworm/build

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
rm -rf .cutekit/venv
33
rm -rf .cutekit/tools-ready
44
rm -rf sysroot/
5+
56
podman run \
67
--rm \
78
-v "$PWD:/src" \
@@ -10,10 +11,10 @@ podman run \
1011
debian:bookworm \
1112
bash -c " \
1213
./ck tools setup && \
13-
./ck install --release --prefix=/opt/paper-muncher --sysroot=/src/sysroot paper-muncher && \
14+
./ck install --release --prefix=/opt/${COMPONENT} --sysroot=/src/sysroot ${COMPONENT} && \
1415
mkdir /deb && \
1516
mkdir /deb/DEBIAN && \
1617
cp -r /src/sysroot/* /deb && \
1718
cp -r meta/packaging/debian-bookworm/debian/* /deb/DEBIAN && \
1819
mkdir -p /src/dist && \
19-
dpkg-deb --build /deb /src/dist/paper-muncher_$(CUTEKIT_VERSION)_bookworm_amd64.deb"
20+
dpkg-deb --build /deb /src/dist/${COMPONENT}_${VERSION}_bookworm_amd64.deb"

meta/packaging/ubuntu-jammy/build

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
rm -rf .cutekit/venv
33
rm -rf .cutekit/tools-ready
44
rm -rf sysroot/
5+
56
podman run \
67
--rm \
78
-v "$PWD:/src" \
89
-w "/src" \
910
-e CUTEKIT_ALLOW_ROOT=1 \
10-
-e CUTEKIT_PYTHON=python3.11 \
1111
ubuntu:jammy \
1212
bash -c " \
1313
./ck tools setup && \
14-
./ck install --release --prefix=/opt/paper-muncher --sysroot=/src/sysroot paper-muncher && \
14+
./ck install --release --prefix=/opt/${COMPONENT} --sysroot=/src/sysroot ${COMPONENT} && \
1515
mkdir /deb && \
1616
mkdir /deb/DEBIAN && \
1717
cp -r /src/sysroot/* /deb && \
1818
cp -r meta/packaging/ubuntu-jammy/debian/* /deb/DEBIAN && \
1919
mkdir -p /src/dist && \
20-
dpkg-deb --build /deb /src/dist/paper-muncher_$(CUTEKIT_VERSION)_jammy_amd64.deb"
20+
dpkg-deb --build /deb /src/dist/${COMPONENT}_${VERSION}_jammy_amd64.deb"

meta/packaging/ubuntu-noble/build

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
rm -rf .cutekit/venv
3+
rm -rf .cutekit/tools-ready
4+
rm -rf sysroot/
5+
6+
podman run \
7+
--rm \
8+
-v "$PWD:/src" \
9+
-w "/src" \
10+
-e CUTEKIT_ALLOW_ROOT=1 \
11+
ubuntu:noble \
12+
bash -c " \
13+
./ck tools setup && \
14+
./ck install --release --prefix=/opt/${COMPONENT} --sysroot=/src/sysroot ${COMPONENT} && \
15+
mkdir /deb && \
16+
mkdir /deb/DEBIAN && \
17+
cp -r /src/sysroot/* /deb && \
18+
cp -r meta/packaging/ubuntu-noble/debian/* /deb/DEBIAN && \
19+
mkdir -p /src/dist && \
20+
dpkg-deb --build /deb /src/dist/${COMPONENT}_${VERSION}_noble_amd64.deb"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Package: paper-muncher
2+
Description: Munch the web into crisp documents
3+
Version: 0.1.0-alpha
4+
Section: utils
5+
Priority: optional
6+
Architecture: amd64
7+
Maintainer: Odoo S.A. <[email protected]>
8+
Depends: liburing2, libseccomp2

meta/plugins/requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

meta/plugins/tools.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ def checkForSymbol(header: str, symbol: str) -> bool:
134134
)
135135

136136

137-
@cli.command("n", "tools/nuke", "Nuke the development tools")
138137
@cli.command("s", "tools/setup", "Setup the development environment")
139138
def _():
140139
raise RuntimeError("Don't use ck directly, use ./ck instead.")

meta/scripts/cutekit-wrapper.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env -S uv run --script
2+
3+
# /// script
4+
# requires-python = ">=3.12"
5+
# dependencies = [
6+
# "cutekit @ git+https://github.com/cute-engineering/cutekit.git@stable",
7+
# "Markdown~=3.7",
8+
# ]
9+
# ///
10+
11+
import cutekit
12+
import sys
13+
14+
sys.exit(cutekit.main())

meta/scripts/setup-any.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [ "$EUID" -eq 0 ]; then
6+
export CUTEKIT_ELEVATOR=""
7+
elif [ -x "$(command -v sudo)" ]; then
8+
export CUTEKIT_ELEVATOR="sudo"
9+
elif [ -x "$(command -v doas)" ]; then
10+
export CUTEKIT_ELEVATOR="doas"
11+
fi
12+
13+
14+
function is_ubuntu() {
15+
if [ -f /etc/os-release ]; then
16+
grep -q "ubuntu" /etc/os-release
17+
return $?
18+
fi
19+
return 1
20+
}
21+
22+
function is_debian() {
23+
if [ -f /etc/os-release ]; then
24+
grep -q "debian" /etc/os-release
25+
return $?
26+
fi
27+
return 1
28+
}
29+
30+
function is_darwin() {
31+
if [ "$(uname)" == "Darwin" ]; then
32+
return 0
33+
fi
34+
return 1
35+
}
36+
37+
function is_arch() {
38+
if [ -f /etc/os-release ]; then
39+
grep -q "Arch Linux" /etc/os-release
40+
return $?
41+
fi
42+
return 1
43+
}
44+
45+
if [ "$1" == "tools" -a "$2" == "setup" ]; then
46+
if is_ubuntu; then
47+
$CUTEKIT_ELEVATOR ./meta/scripts/setup-ubuntu.sh
48+
elif is_debian; then
49+
$CUTEKIT_ELEVATOR ./meta/scripts/setup-debian.sh
50+
elif is_arch; then
51+
$CUTEKIT_ELEVATOR ./meta/scripts/setup-arch.sh
52+
elif is_darwin; then
53+
./meta/scripts/setup-darwin.sh
54+
fi
55+
if [ ! -x "$(command -v uv)" ]; then
56+
curl -LsSf https://astral.sh/uv/install.sh | sh
57+
fi
58+
exit 0
59+
fi
60+
61+
if is_ubuntu; then
62+
source ./meta/scripts/env-ubuntu.sh
63+
elif is_darwin; then
64+
source ./meta/scripts/env-darwin.sh
65+
fi
66+
67+
if [ -d "$XDG_BIN_HOME" ]; then
68+
export PATH="$XDG_BIN_HOME:$PATH"
69+
fi
70+
71+
if [ -d "$XDG_DATA_HOME/../bin" ]; then
72+
export PATH="$XDG_DATA_HOME/../bin:$PATH"
73+
fi
74+
75+
if [ -d "$HOME/.local/bin" ]; then
76+
export PATH="$HOME/.local/bin:$PATH"
77+
fi

meta/scripts/setup-debian.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,11 @@
33
set -e
44

55
apt-get update -y --no-install-recommends
6-
apt-get install -y --no-install-recommends build-essential python3.11-venv lsb-release wget software-properties-common gnupg git ninja-build libsdl2-dev nasm liburing-dev ccache jq libseccomp-dev
6+
apt-get install -y --no-install-recommends build-essential git ninja-build libsdl2-dev nasm liburing-dev ccache jq libseccomp-dev
7+
8+
# Install llvm
9+
apt-get install -y --no-install-recommends wget lsb-release software-properties-common gnupg
710
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" llvm 20 all
11+
12+
# Install UV
13+
apt-get install -y --no-install-recommends curl

meta/scripts/setup-ubuntu.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ apt-get install -y --no-install-recommends \
1111
ccache \
1212
jq
1313

14-
# Setup python3.11
15-
apt-get install -y --no-install-recommends python3.11 python3.11-distutils python3.11-venv
16-
1714
# Build dependencies
1815
apt-get install -y --no-install-recommends libseccomp-dev liburing-dev libsdl2-dev
1916

2017
# Install llvm
2118
apt-get install -y --no-install-recommends wget lsb-release software-properties-common gnupg
2219
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" llvm 20 all
20+
21+
# Install UV
22+
apt-get install -y --no-install-recommends curl
23+

0 commit comments

Comments
 (0)