Skip to content

Commit 4959c5c

Browse files
committed
Merge branch 'main' into camera-streamer
2 parents 90c4c9c + 50e0c3c commit 4959c5c

File tree

7 files changed

+103
-61
lines changed

7 files changed

+103
-61
lines changed

.github/workflows/custopize.yml

Lines changed: 65 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
workflow_dispatch:
77
inputs:
88
octopi_version:
9-
description: "OctoPi version (leave empty to use latest stable release)"
9+
description: "OctoPi version (leave empty to use latest stable release, may also be 'version:url')"
1010
required: false
1111
default: ''
1212
octoprint_version:
@@ -45,70 +45,86 @@ jobs:
4545
console.log(`Version from workflow dispatch: ${version}`);
4646
}
4747
48-
if (version) {
49-
console.log(`Fetching release of ${version}`);
50-
51-
const query = `query {
52-
repository(owner: "guysoft", name: "Octopi") {
53-
release(tagName:"${version}") {
54-
tagName
55-
releaseAssets(first:5) {
56-
nodes {
57-
name
58-
downloadUrl
59-
}
60-
}
61-
}
62-
}
63-
}`;
48+
if (version && version.includes(":")) {
49+
// version is in "version:url" format
50+
const pos = version.indexOf(":")
51+
const octopiVersion = version.slice(0, pos);
52+
const octopiUrl = version.slice(pos + 1);
6453
65-
const result = await github.graphql(query);
66-
console.log({result});
54+
console.log(`OctoPi version: ${octopiVersion}`)
55+
console.log(`OctoPi download URL: ${octopiUrl}`)
6756
68-
release = result.repository.release;
57+
core.exportVariable("OCTOPI_VERSION", octopiVersion)
58+
core.exportVariable("OCTOPI_URL", octopiUrl)
6959
7060
} else {
71-
console.log("Fetching latest release");
72-
73-
const query = `query {
74-
repository(owner:"guysoft", name:"OctoPi") {
75-
latestRelease {
76-
tagName
77-
releaseAssets(first:5) {
78-
nodes {
79-
name
80-
downloadUrl
61+
if (version) {
62+
// version provided
63+
console.log(`Fetching release of ${version}`);
64+
65+
const query = `query {
66+
repository(owner: "guysoft", name: "Octopi") {
67+
release(tagName:"${version}") {
68+
tagName
69+
releaseAssets(first:5) {
70+
nodes {
71+
name
72+
downloadUrl
73+
}
8174
}
8275
}
8376
}
84-
}
85-
}`;
77+
}`;
78+
79+
const result = await github.graphql(query);
80+
console.log({result});
81+
82+
release = result.repository.release;
83+
84+
} else {
85+
// no version provided
86+
console.log("Fetching latest release");
87+
88+
const query = `query {
89+
repository(owner:"guysoft", name:"OctoPi") {
90+
latestRelease {
91+
tagName
92+
releaseAssets(first:5) {
93+
nodes {
94+
name
95+
downloadUrl
96+
}
97+
}
98+
}
99+
}
100+
}`;
86101
87-
const result = await github.graphql(query);
88-
console.log({result});
102+
const result = await github.graphql(query);
103+
console.log({result});
89104
90-
release = result.repository.latestRelease;
91-
}
105+
release = result.repository.latestRelease;
106+
}
92107
93-
if (!release || !release.tagName || !release.releaseAssets || !release.releaseAssets.nodes) core.setFailed("Could not find OctoPi release");
108+
if (!release || !release.tagName || !release.releaseAssets || !release.releaseAssets.nodes) core.setFailed("Could not find OctoPi release");
94109
95-
const octopiVersion = release.tagName;
110+
const octopiVersion = release.tagName;
96111
97-
let octopiUrl = null;
98-
for (const asset of release.releaseAssets.nodes) {
99-
if (asset.name.startsWith("octopi-") && asset.name.includes("-armhf-") && asset.name.endsWith(".zip")) {
100-
octopiUrl = asset.downloadUrl;
101-
break;
112+
let octopiUrl = null;
113+
for (const asset of release.releaseAssets.nodes) {
114+
if (asset.name.startsWith("octopi-") && asset.name.includes("-armhf-") && asset.name.endsWith(".zip")) {
115+
octopiUrl = asset.downloadUrl;
116+
break;
117+
}
102118
}
103-
}
104119
105-
if (!octopiUrl) core.setFailed("Could not find OctoPi download URL");
120+
if (!octopiUrl) core.setFailed("Could not find OctoPi download URL");
106121
107-
console.log(`OctoPi version: ${octopiVersion}`)
108-
console.log(`OctoPi download URL: ${octopiUrl}`)
122+
console.log(`OctoPi version: ${octopiVersion}`)
123+
console.log(`OctoPi download URL: ${octopiUrl}`)
109124
110-
core.exportVariable("OCTOPI_VERSION", octopiVersion)
111-
core.exportVariable("OCTOPI_URL", octopiUrl)
125+
core.exportVariable("OCTOPI_VERSION", octopiVersion)
126+
core.exportVariable("OCTOPI_URL", octopiUrl)
127+
}
112128
113129
- name: "🔎 Determine OctoPrint version"
114130
run: |

Taskfile.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
version: "3"
22

3+
vars:
4+
DOCKERIMG: '{{ default "ghcr.io/octoprint/custopizer:latest" .DOCKERIMG }}'
5+
36
tasks:
47
build:
58
cmds:
69
- |
7-
{{if eq OS "windows"}}powershell {{end}}docker run --rm --privileged -v {{.USER_WORKING_DIR | toSlash}}/workspace:/CustoPiZer/workspace -v {{.USER_WORKING_DIR | toSlash}}/scripts:/CustoPiZer/workspace/scripts ghcr.io/octoprint/custopizer:latest
10+
{{if eq OS "windows"}}powershell {{end}}docker run --rm --privileged -v {{.USER_WORKING_DIR | toSlash}}/workspace:/CustoPiZer/workspace -v {{.USER_WORKING_DIR | toSlash}}/scripts:/CustoPiZer/workspace/scripts {{.DOCKERIMG}}
811
preconditions:
912
- test -d workspace
1013
- test -f workspace/input.img
14+
15+
inspect:
16+
cmds:
17+
- |
18+
{{if eq OS "windows"}}powershell {{end}}docker run -it --rm --privileged -v {{.USER_WORKING_DIR | toSlash}}/workspace/output.img:/image.img {{.DOCKERIMG}} /CustoPiZer/enter_image /image.img
19+
preconditions:
20+
- test -d workspace
21+
- test -f workspace/output.img

scripts/00-enforce-32bit-kernel

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@ export LC_ALL=C
66
source /common.sh
77
install_cleanup_trap
88

9+
env
10+
11+
# if we are building on a 64bit image, no need to do anything
12+
if [ "$EDITBASE_ARCH" == "aarch64" ] || [ "$EDITBASE_ARCH" == "arm64" ]; then
13+
exit 0
14+
fi
15+
916
## Taken from https://github.com/piwheels/piwheels/commit/63f2ac1f24ece782627dc47e9519f98222b27490
1017

1118
# Enforce 32-bit kernel as the 64-bit kernel is used by default (also on RPi OS 32-bit) since RPi Linux 6.1
12-
if [ -f /boot/config.txt ]; then
13-
sed -i '/^[[:blank:]]*arm_64bit=/d' /boot/config.txt # remove setting first
14-
sed -i '1iarm_64bit=0' /boot/config.txt # readd setting to top of file to assure it is effective on all RPi models
19+
CONFIG=$BOOT_PATH/config.txt
20+
if [ -f $CONFIG ]; then
21+
sed -i '/^[[:blank:]]*arm_64bit=/d' $CONFIG # remove setting first
22+
sed -i '1iarm_64bit=0' $CONFIG # readd setting to top of file to assure it is effective on all RPi models
1523
else
16-
echo 'arm_64bit=0' > /boot/config.txt
24+
echo 'arm_64bit=0' > $CONFIG
1725
fi

scripts/01-add-yq

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export LC_ALL=C
66
source /common.sh
77
install_cleanup_trap
88

9-
# if pb is there, we don't need to do anything
9+
# if yq is there, we don't need to do anything
1010
[ -f /usr/local/bin/yq ] && exit 0
1111

12-
curl -L -o /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.43.1/yq_linux_arm
12+
curl -L -o /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION:-v4.45.1}/yq_linux_arm"
1313
chmod +x /usr/local/bin/yq

scripts/02-update-octoprint

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ install_cleanup_trap
88

99
BUNDLED="OctoPrint-FileCheck OctoPrint-FirmwareCheck OctoPrint-PiSupport"
1010

11+
USER=pi
12+
VENV=/opt/octopi/oprint
13+
[ -f $VENV ] || VENV=/home/pi/oprint
14+
1115
if [ -n "$OCTOPRINT_VERSION" ]; then
1216
# fetch from GitHub since PyPI might not yet be synced through right after a fresh release
13-
sudo -u pi /home/pi/oprint/bin/pip install -U https://github.com/OctoPrint/OctoPrint/archive/refs/tags/$OCTOPRINT_VERSION.zip $BUNDLED
17+
sudo -u $USER $VENV/bin/pip install -U https://github.com/OctoPrint/OctoPrint/archive/refs/tags/$OCTOPRINT_VERSION.zip $BUNDLED
1418
else
15-
sudo -u pi /home/pi/oprint/bin/pip install -U OctoPrint $BUNDLED
19+
sudo -u $USER $VENV/bin/pip install -U OctoPrint $BUNDLED
1620
fi
1721

1822
# make sure to mark the file check wizard as seen
1923
if [ $(/usr/local/bin/yq '.server.seenWizards.file_check' /home/pi/.octoprint/config.yaml) == "null" ]; then
20-
sudo -u pi FILECHECK_WIZARD=$(sudo -u pi /home/pi/oprint/bin/python -c "import octoprint_file_check; print(octoprint_file_check.WIZARD_VERSION)") /usr/local/bin/yq -i '.server.seenWizards.file_check = env(FILECHECK_WIZARD)' /home/pi/.octoprint/config.yaml
24+
sudo -u $USER FILECHECK_WIZARD=$(sudo -u $USER $VENV/bin/python -c "import octoprint_file_check; print(octoprint_file_check.WIZARD_VERSION)") /usr/local/bin/yq -i '.server.seenWizards.file_check = env(FILECHECK_WIZARD)' /home/pi/.octoprint/config.yaml
2125
fi

scripts/03-update-boot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export LC_ALL=C
66
source /common.sh
77
install_cleanup_trap
88

9-
apt-get install --yes --reinstall raspberrypi-bootloader raspberrypi-kernel
9+
apt-get install --yes raspberrypi-bootloader raspberrypi-kernel
1010

1111
kernel_version=$(dpkg -s raspberrypi-kernel | grep -i version | awk '{print $2}')
1212
if [ "$kernel_version" = "1:1.20230317-1" ]; then

scripts/82-fix-welcome-banner

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ export LC_ALL=C
66
source /common.sh
77
install_cleanup_trap
88

9-
# if we already have the octopi.txt file updated, we don't need to do anything
9+
# if there's no welcome script at /home/pi/scripts/welcome, we don't need to do anything
10+
[ ! -f '/home/pi/scripts/welcome' ] && exit 0
11+
12+
# if we already have the file updated, we don't need to do anything
1013
grep -q 'from octoprint._version import' /home/pi/scripts/welcome || exit 0
1114

1215
sed -i 's#^_OCTOPRINT_VERSION=.*$#_OCTOPRINT_VERSION=$($HOME/oprint/bin/python -c "from octoprint.util.version import get_octoprint_version_string; print(get_octoprint_version_string())" || echo "unknown")#' /home/pi/scripts/welcome

0 commit comments

Comments
 (0)