Skip to content

Commit 4a45df8

Browse files
authored
Merge branch 'testing' into package/perf/initial
2 parents 5f73e76 + 8c5a939 commit 4a45df8

File tree

6 files changed

+388
-20
lines changed

6 files changed

+388
-20
lines changed

package/kernelctl/force_reinstall_on_toltecctl_reenable

Whitespace-only changes.

package/kernelctl/kernelctl

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2022 The Toltec Contributors
3+
# SPDX-License-Identifier: MIT
4+
5+
# kernel staging dir
6+
kernelctl_dir=/opt/usr/share/kernelctl
7+
8+
# Formatting
9+
bf="\033[1m" # bold
10+
sf="\033[0m" # standard
11+
gr="\033[1;32m" # green
12+
bl="\033[1;34m" # blue
13+
14+
# change our working directory to / to ease filesystem operations
15+
cd /
16+
17+
help() {
18+
read -r -d '' msg <<- EOM
19+
Usage: $(basename "$0") COMMAND
20+
Manage your booting kernel.
21+
22+
${gr}Available commands:${sf}
23+
${bf} backup <kernel_name> ${sf}Backup current kernel and name it <kernel_name>. This is guaranteed to work only with vanilla (i.e. upstream) kernels.
24+
${bf} help ${sf}Show this help message.
25+
${bf} list ${sf}List available kernels.
26+
${bf} show ${sf}Show the current configured kernel.
27+
${bf} delete <kernel> ${sf}Delete kernel from the staging dir. WARNING this is irreversible.
28+
${bf} set <kernel> ${sf}Change booting kernel.
29+
30+
${bf} <kernel> ${sf}Kernel name or number (from 'list' command) or "default" to revert to the upstram kernel.
31+
EOM
32+
echo -e "$msg"
33+
}
34+
35+
# backup current kernel
36+
backup() {
37+
if [[ "$1" = "vanilla" ]]; then
38+
kernel_name="vanilla-$(< /etc/version)"
39+
else
40+
kernel_name=$1
41+
fi
42+
43+
kernel_file="$kernelctl_dir"/"$kernel_name".tar.bz2
44+
45+
if [[ -e "$kernel_file" ]]; then
46+
read -r -d "" msg <<- EOM
47+
It looks like there is already copy of $kernel_name in the staging area.
48+
If you really want to back it up again please run
49+
50+
$(basename "$0") delete $kernel_name
51+
$(basename "$0") backup $kernel_name
52+
EOM
53+
echo -e "$msg"
54+
exit 1
55+
else
56+
tar cpjf "$kernel_file" lib/modules/* boot/zImage* boot/*.dtb
57+
rm -f "$kernelctl_dir"/current.tar.bz2
58+
ln "$kernel_file" "$kernelctl_dir"/current.tar.bz2
59+
fi
60+
}
61+
62+
# get available kernels
63+
get_kernel_names() {
64+
mapfile -t kernel_names < <(find "$kernelctl_dir" -path "*.tar.bz2" ! -name current.tar.bz2 -print0 | xargs -0 -I"{}" basename {} .tar.bz2)
65+
}
66+
67+
# get current kernel
68+
get_current_kernel_name() {
69+
current_kernel_name=$(find "$kernelctl_dir" -samefile "$kernelctl_dir"/current.tar.bz2 ! -name current.tar.bz2 -print0 | xargs -0 -I"{}" basename {} .tar.bz2)
70+
}
71+
72+
# translate input into a kernel name
73+
to_kernel_name() {
74+
local ker
75+
get_kernel_names
76+
if [[ "$1" =~ ^[0-9]+$ ]] && ((0 < $1 && $1 <= ${#kernel_names[@]})); then
77+
echo "${kernel_names[$(($1 - 1))]}"
78+
return
79+
elif [[ "$1" = "default" ]]; then
80+
ker="vanilla-$(< /etc/version)"
81+
else
82+
ker="$1"
83+
fi
84+
if [[ $(echo "${kernel_names[@]}" | grep -ow "$ker" | wc -w) -gt 0 ]]; then
85+
echo "$ker"
86+
else
87+
echo "Can't find $ker in the staging area."
88+
exit 1
89+
fi
90+
}
91+
92+
# list available kernels
93+
list() {
94+
get_kernel_names
95+
get_current_kernel_name
96+
echo -e "${gr}Available kernels:${sf}"
97+
for i in "${!kernel_names[@]}"; do
98+
if [[ "$current_kernel_name" = "${kernel_names[$i]}" ]]; then cur=" ${bl}*${sf}"; else cur=""; fi
99+
echo -e " ${bf}[$((i + 1))]${sf}\t${kernel_names[$i]}$cur"
100+
done
101+
}
102+
103+
# show the current configured kernel
104+
show() {
105+
get_current_kernel_name
106+
echo -e "${gr}Current kernel:${sf}"
107+
echo -e " ${bf}${current_kernel_name}${sf}"
108+
}
109+
110+
# actually switch kernels
111+
switch() {
112+
tar tjf "$1" | sort -r | xargs -r -I {} bash -c 'if [[ -d "{}" ]]; then rmdir "{}"; else rm "{}"; fi'
113+
tar xpjf "$2"
114+
}
115+
116+
# change the kernel that will boot next time
117+
set() {
118+
new_kernel_name=$(to_kernel_name "$1")
119+
new_kernel_file="${kernelctl_dir}/${new_kernel_name}.tar.bz2"
120+
current_kernel_file="${kernelctl_dir}/current.tar.bz2"
121+
if [[ ! -e "$current_kernel_file" ]]; then
122+
read -r -d '' msg <<- EOM
123+
${bf}There is no link to the current running kernel in the staging
124+
area, you might have accidentally deleted it!${sf}
125+
Try making a backup first.
126+
EOM
127+
echo -e "$msg"
128+
exit 1
129+
fi
130+
if switch "$current_kernel_file" "$new_kernel_file"; then
131+
rm -f "$current_kernel_file"
132+
ln "$new_kernel_file" "$current_kernel_file"
133+
/bin/sync
134+
echo "Reboot system to use your newly installed kernel."
135+
else
136+
read -r -d '' msg <<- EOM
137+
${bf}WARNING: failed to extract the new kernel!${sf}
138+
This may be due to a lack of space in the root partition.
139+
Attempting to revert to the current running kernel.
140+
EOM
141+
echo -e "$msg"
142+
if switch "$new_kernel_file" "$current_kernel_file"; then
143+
/bin/sync
144+
read -r -d '' msg <<- EOM
145+
Successfully reverted to the current running kernel.
146+
Please check that everything is in order before rebooting.
147+
EOM
148+
echo -e "$msg"
149+
else
150+
read -r -d '' msg <<- EOM
151+
Unable to revert to a working configuration.
152+
If you do not know how to proceed, please do not reboot your device,
153+
do not let the battery die, and seek assistance
154+
in the reMarkable's community Discord server: https://discord.gg/ATqQGfu
155+
EOM
156+
echo -e "$msg"
157+
exit 1
158+
fi
159+
fi
160+
}
161+
162+
# delete kernel from staging dir
163+
delete() {
164+
kernel_name=$(to_kernel_name "$1")
165+
echo "Deleting $kernel_name from the staging area is irreversible."
166+
echo "If the kernel was installed as a toltec package this may confuse the package manager"
167+
echo -n "Do you want to proceed? [N/y]: "
168+
read -r ans
169+
if [[ "$ans" = "y" || "$ans" = "Y" ]]; then
170+
rm "${kernelctl_dir}/${kernel_name}.tar.bz2"
171+
fi
172+
}
173+
174+
if [[ $0 = "${BASH_SOURCE[0]}" ]]; then
175+
if [[ $# -eq 0 ]]; then
176+
help
177+
exit 1
178+
fi
179+
180+
action="$1"
181+
shift
182+
183+
case $action in
184+
help | -h | --help)
185+
help
186+
;;
187+
list)
188+
list
189+
;;
190+
show)
191+
show
192+
;;
193+
backup)
194+
if [[ $# -ne 1 ]]; then
195+
help
196+
exit 1
197+
fi
198+
backup "$1"
199+
;;
200+
set)
201+
if [[ $# -ne 1 ]]; then
202+
help
203+
exit 1
204+
fi
205+
set "$1"
206+
;;
207+
delete)
208+
if [[ $# -ne 1 ]]; then
209+
help
210+
exit 1
211+
fi
212+
delete "$1"
213+
;;
214+
*)
215+
echo -e "Error: Invalid command '$action'\n"
216+
help
217+
exit 1
218+
;;
219+
esac
220+
fi

package/kernelctl/package

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2021 The Toltec Contributors
3+
# SPDX-License-Identifier: MIT
4+
5+
pkgnames=(kernelctl)
6+
pkgdesc="Manage aftermarket kernels"
7+
url=https://toltec-dev.org/
8+
pkgver=0.1-1
9+
timestamp=2022-03-14T00:00Z
10+
section="utils"
11+
maintainer="Salvatore Stella <etn45p4m@gmail.com>"
12+
license=MIT
13+
14+
source=(
15+
kernelctl
16+
force_reinstall_on_toltecctl_reenable
17+
)
18+
sha256sums=(
19+
SKIP
20+
SKIP
21+
)
22+
23+
package() {
24+
install -D -m 744 -t "$pkgdir"/opt/bin "$srcdir"/kernelctl
25+
install -d "$pkgdir"/opt/usr/share/kernelctl
26+
install -D -m 666 -t "$pkgdir"/usr/share/kernelctl/ "$srcdir"/force_reinstall_on_toltecctl_reenable
27+
}
28+
29+
configure() {
30+
kernelctl backup vanilla
31+
}

package/linux-mainline/package

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ archs=(rm2)
66
pkgnames=(linux-mainline)
77
pkgdesc="reMarkable 2 kernel based on the mainline kernel"
88
url=https://www.kernel.org
9-
pkgver=5.18.0-1
9+
pkgver=5.19.0-1
1010
timestamp=2022-05-22T21:50:09Z
1111
section=kernel
1212
maintainer="Alistair Francis <alistair@alistair23.me>"
@@ -15,8 +15,8 @@ license=GPL-2.0-only
1515
flags=(nostrip)
1616

1717
image=base:v2.3
18-
source=("https://github.com/alistair23/linux/archive/f9fe680995e01398f0813077711fe1b744251c5b.tar.gz")
19-
sha256sums=(d38c883a31f5f87483377e78b4b3a2eb1ce73ada38fc25949e692dd0b2dd7895)
18+
source=("https://github.com/alistair23/linux/archive/6df274810d20448125834115e2181de288fdc8a4.tar.gz")
19+
sha256sums=(a7538198dbef21868d2c52e8b379576c8791726809bd5886176ab88d1f9df49f)
2020

2121
build() {
2222
ARCH=arm make imx_v6_v7_defconfig
@@ -38,19 +38,13 @@ package() {
3838
# Create the kernel archive
3939
local archive="mainline-${pkgver%-*}.tar.bz2"
4040
install -d "$pkgdir"/opt/usr/share/kernelctl
41-
tar --owner root:0 --group root:0 --mtime=$timestamp \
42-
-cjf "$pkgdir"/opt/usr/share/kernelctl/"$archive" -C "$staging" .
41+
(cd "$staging" && tar --owner root:0 --group root:0 --mtime=$timestamp \
42+
-cjf "$pkgdir"/opt/usr/share/kernelctl/"$archive" boot/* lib/modules/*)
4343
}
4444

4545
configure() {
4646
echo "The new kernel files have been copied, but not installed."
47-
echo "Before installing them, make a backup of the existing kernel:"
48-
echo " mkdir -p /home/root/boot-backup"
49-
echo " cp -rvf /boot/* /home/root/boot-backup/"
50-
echo
51-
echo "Then replace it with the new kernel and reboot:"
52-
echo " tar -xvf /opt/usr/share/kernelctl/mainline-${pkgver%-*}.tar.bz2 -C /"
53-
echo " /bin/sync"
47+
echo "Please use kernelctl to select the kernel to boot."
5448
echo
5549
echo "Known issues with the mainline kernel:"
5650
echo " - No support for low power mode (suspend uses more power then it should)"
@@ -59,11 +53,3 @@ configure() {
5953
echo " - Wacom stylus doesn't work in Xochitl (works everywhere else though)"
6054
echo " - No OTG control support"
6155
}
62-
63-
postremove() {
64-
echo "To restore to the original kernel, run and then reboot"
65-
echo " rm -rf /lib/modules/${pkgver%-*}/"
66-
echo " cp -f /home/root/boot-backup/zImage /boot/"
67-
echo " cp -f /home/root/boot-backup/zero-sugar.dtb /boot/"
68-
echo " /bin/sync"
69-
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2022 The Toltec Contributors
3+
# SPDX-License-Identifier: MIT
4+
5+
archs=(rm1 rm2)
6+
pkgnames=(linux-stracciatella)
7+
pkgdesc="RemarkableAS's vanilla kernel with a few extra flakes"
8+
url=https://github.com/Etn40ff/linux-remarkable
9+
pkgver=5.4.70-1
10+
timestamp=2022-06-26T23:50:04+02:00
11+
section="kernel"
12+
maintainer="Salvatore Stella <etn45p4m@gmail.com>"
13+
makedepends=(build:flex build:bison build:libssl-dev build:bc build:lzop build:libgmp-dev build:libmpc-dev build:kmod)
14+
license=GPL-2.0-only
15+
flags=(nostrip)
16+
installdepends=(kernelctl)
17+
image=base:v2.3
18+
source=(https://github.com/Etn40ff/linux-remarkable/archive/c6aa07709109f9b5879628396052f60a97ec9197.tar.gz)
19+
sha256sums=(529fe57ddc25bbaed5f0b3a9f7f79b51ab9ea3388d2acf8a933a8a4c77bd93c0)
20+
21+
build() {
22+
if [[ $arch = rm1 ]]; then
23+
ARCH=arm make zero-gravitas_defconfig
24+
elif [[ $arch = rm2 ]]; then
25+
ARCH=arm make zero-sugar_defconfig
26+
fi
27+
ARCH=arm make -j8
28+
}
29+
30+
package() {
31+
# Prepare files for the kernel archive
32+
local staging="$srcdir"/staging
33+
mkdir -p "$staging/boot"
34+
35+
cp --no-dereference {"$srcdir"/arch/arm,"$staging"}/boot/zImage
36+
if [[ $arch = rm1 ]]; then
37+
cp --no-dereference "$srcdir"/arch/arm/boot/dts/zero-gravitas.dtb "$staging"/boot/zero-gravitas.dtb
38+
elif [[ $arch = rm2 ]]; then
39+
cp --no-dereference "$srcdir"/arch/arm/boot/dts/zero-sugar.dtb "$staging"/boot/zero-sugar.dtb
40+
fi
41+
42+
ARCH=arm make -C "$srcdir" modules_install INSTALL_MOD_PATH="$staging"
43+
rm "$staging"/lib/modules/*/{source,build}
44+
45+
# Create the kernel archive
46+
local archive="stracciatella-${pkgver%-*}.tar.bz2"
47+
install -d "$pkgdir"/opt/usr/share/kernelctl
48+
(cd "$staging" && tar --owner root:0 --group root:0 --mtime=$timestamp \
49+
-cjf "$pkgdir"/opt/usr/share/kernelctl/"$archive" boot/* lib/modules/*)
50+
}
51+
52+
configure() {
53+
if [[ $(< /etc/version) -le 20210709090000 ]]; then
54+
echo "WARNING: Your system is too old; this kernel will most likely not work unless you add the appropriate firmware blobs to /lib/firmware."
55+
echo "Please consider updating your system instead."
56+
fi
57+
echo "The new kernel files have been copied, but not installed."
58+
echo "Please use kernelctl to select the kernel to boot."
59+
}

0 commit comments

Comments
 (0)