pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / by-name / ve / ventoy / 000-nixos-sanitization.patch
blob1d7afc5159c7b2e918d59e35617ad385ae56766f
1 A shameless merge of many patches floating around; indeed it was made by reading
2 and applying them manually.
4 diff -Naur ventoy-1.0.81-old/CreatePersistentImg.sh ventoy-1.0.81-new/CreatePersistentImg.sh
5 --- ventoy-1.0.81-old/CreatePersistentImg.sh 2022-10-25 08:26:21.000000000 -0300
6 +++ ventoy-1.0.81-new/CreatePersistentImg.sh 2022-11-02 10:29:07.355891607 -0300
7 @@ -119,17 +119,13 @@
8 sync
10 if [ -n "$config" ]; then
11 - if [ -d ./persist_tmp_mnt ]; then
12 - rm -rf ./persist_tmp_mnt
13 - fi
15 - mkdir ./persist_tmp_mnt
16 - if mount $freeloop ./persist_tmp_mnt; then
17 - echo '/ union' > ./persist_tmp_mnt/$config
18 + path_to_persist_mnt="`mktemp -d`"
19 + if mount $freeloop "$path_to_persist_mnt"; then
20 + echo '/ union' > "$path_to_persist_mnt"/$config
21 sync
22 - umount ./persist_tmp_mnt
23 + umount "$path_to_persist_mnt"
25 - rm -rf ./persist_tmp_mnt
26 + rm -rf "$path_to_persist_mnt"
29 if [ ! -z "$passphrase" ]; then
30 diff -Naur ventoy-1.0.81-old/tool/ventoy_lib.sh ventoy-1.0.81-new/tool/ventoy_lib.sh
31 --- ventoy-1.0.81-old/tool/ventoy_lib.sh 2022-10-25 08:26:21.000000000 -0300
32 +++ ventoy-1.0.81-new/tool/ventoy_lib.sh 2022-11-02 09:46:29.764568349 -0300
33 @@ -6,6 +6,8 @@
34 VENTOY_SECTOR_SIZE=512
35 VENTOY_SECTOR_NUM=65536
37 +LOGFILE="/var/log/ventoy.log"
39 ventoy_false() {
40 [ "1" = "2" ]
42 @@ -29,7 +31,7 @@
45 vtdebug() {
46 - echo "$*" >> ./log.txt
47 + echo "$*" >> $LOGFILE
50 vtoy_gen_uuid() {
51 @@ -51,31 +53,7 @@
54 check_tool_work_ok() {
56 - if echo 1 | hexdump > /dev/null; then
57 - vtdebug "hexdump test ok ..."
58 - else
59 - vtdebug "hexdump test fail ..."
60 - ventoy_false
61 - return
62 - fi
64 - if mkexfatfs -V > /dev/null; then
65 - vtdebug "mkexfatfs test ok ..."
66 - else
67 - vtdebug "mkexfatfs test fail ..."
68 - ventoy_false
69 - return
70 - fi
72 - if vtoycli fat -T; then
73 - vtdebug "vtoycli fat test ok ..."
74 - else
75 - vtdebug "vtoycli fat test fail ..."
76 - ventoy_false
77 - return
78 - fi
81 vtdebug "tool check success ..."
82 ventoy_true
84 @@ -311,7 +289,7 @@
85 else
86 vtdebug "format disk by fdisk ..."
88 -fdisk $DISK >>./log.txt 2>&1 <<EOF
89 +fdisk $DISK >>$LOGFILE 2>&1 <<EOF
93 diff -Naur ventoy-1.0.81-old/tool/VentoyWorker.sh ventoy-1.0.81-new/tool/VentoyWorker.sh
94 --- ventoy-1.0.81-old/tool/VentoyWorker.sh 2022-10-25 08:26:21.000000000 -0300
95 +++ ventoy-1.0.81-new/tool/VentoyWorker.sh 2022-11-02 10:33:25.813135227 -0300
96 @@ -106,7 +106,7 @@
97 if check_tool_work_ok; then
98 vtdebug "check tool work ok"
99 else
100 - vterr "Some tools can not run on current system. Please check log.txt for details."
101 + vterr "Some tools can not run on current system. Please check $LOGFILE for details."
102 exit 1
105 @@ -159,19 +159,6 @@
106 exit 1
110 -#check tmp_mnt directory
111 -if [ -d ./tmp_mnt ]; then
112 - vtdebug "There is a tmp_mnt directory, now delete it."
113 - umount ./tmp_mnt >/dev/null 2>&1
114 - rm -rf ./tmp_mnt
115 - if [ -d ./tmp_mnt ]; then
116 - vterr "tmp_mnt directory exists, please delete it first."
117 - exit 1
118 - fi
122 if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then
123 vtdebug "install Ventoy ..."
125 @@ -567,16 +554,16 @@
126 PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"')
128 #reserve disk uuid
129 - rm -f ./diskuuid.bin
130 - dd status=none conv=fsync if=${DISK} skip=384 bs=1 count=16 of=./diskuuid.bin
131 + path_to_diskuuid="`mktemp`"
132 + dd status=none conv=fsync if=${DISK} skip=384 bs=1 count=16 of="$path_to_diskuuid"
134 dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=440
135 - dd status=none conv=fsync if=./diskuuid.bin of=$DISK bs=1 count=16 seek=384
136 - rm -f ./diskuuid.bin
137 + dd status=none conv=fsync if="$path_to_diskuuid" of=$DISK bs=1 count=16 seek=384
138 + rm -f "$path_to_diskuuid"
140 #reserve data
141 - rm -f ./rsvdata.bin
142 - dd status=none conv=fsync if=${DISK} skip=2040 bs=512 count=8 of=./rsvdata.bin
143 + path_to_rsvdata="`mktemp`"
144 + dd status=none conv=fsync if=${DISK} skip=2040 bs=512 count=8 of="$path_to_rsvdata"
146 if [ "$PART1_TYPE" = "EE" ]; then
147 vtdebug "This is GPT partition style ..."
148 @@ -598,8 +585,8 @@
149 xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2047 seek=1
152 - dd status=none conv=fsync if=./rsvdata.bin seek=2040 bs=512 count=8 of=${DISK}
153 - rm -f ./rsvdata.bin
154 + dd status=none conv=fsync if="$path_to_rsvdata" seek=2040 bs=512 count=8 of=${DISK}
155 + rm -f "$path_to_rsvdata"
157 check_umount_disk "$DISK"
159 diff -Naur ventoy-1.0.81-old/Ventoy2Disk.sh ventoy-1.0.81-new/Ventoy2Disk.sh
160 --- ventoy-1.0.81-old/Ventoy2Disk.sh 2022-10-25 08:26:21.000000000 -0300
161 +++ ventoy-1.0.81-new/Ventoy2Disk.sh 2022-11-02 09:50:17.649369332 -0300
162 @@ -32,48 +32,4 @@
163 echo '**********************************************'
164 echo ''
167 -if ! [ -f ./boot/boot.img ]; then
168 - if [ -d ./grub ]; then
169 - echo "Don't run Ventoy2Disk.sh here, please download the released install package, and run the script in it."
170 - else
171 - echo "Please run under the correct directory!"
172 - fi
173 - exit 1
176 -echo "############# Ventoy2Disk $* [$TOOLDIR] ################" >> ./log.txt
177 -date >> ./log.txt
179 -#decompress tool
180 -echo "decompress tools" >> ./log.txt
181 -cd ./tool/$TOOLDIR
183 -ls *.xz > /dev/null 2>&1
184 -if [ $? -eq 0 ]; then
185 - [ -f ./xzcat ] && chmod +x ./xzcat
187 - for file in $(ls *.xz); do
188 - echo "decompress $file" >> ./log.txt
189 - xzcat $file > ${file%.xz}
190 - [ -f ./${file%.xz} ] && chmod +x ./${file%.xz}
191 - [ -f ./$file ] && rm -f ./$file
192 - done
195 -cd ../../
196 -chmod +x -R ./tool/$TOOLDIR
199 -if [ -f /bin/bash ]; then
200 - /bin/bash ./tool/VentoyWorker.sh $*
201 -else
202 - ash ./tool/VentoyWorker.sh $*
205 -if [ -n "$OLDDIR" ]; then
206 - CURDIR=$(pwd)
207 - if [ "$CURDIR" != "$OLDDIR" ]; then
208 - cd "$OLDDIR"
209 - fi
211 +./tool/VentoyWorker.sh $*
212 diff -Naur ventoy-1.0.81-old/VentoyPlugson.sh ventoy-1.0.81-new/VentoyPlugson.sh
213 --- ventoy-1.0.81-old/VentoyPlugson.sh 2022-10-25 08:26:21.000000000 -0300
214 +++ ventoy-1.0.81-new/VentoyPlugson.sh 2022-11-02 09:51:36.758360872 -0300
215 @@ -43,39 +43,6 @@
216 exit 1
220 -if ! [ -f "$OLDDIR/tool/plugson.tar.xz" ]; then
221 - echo "Please run under the correct directory!"
222 - exit 1
225 -echo "############# VentoyPlugson $* [$TOOLDIR] ################" >> ./VentoyPlugson.log
226 -date >> ./VentoyPlugson.log
228 -echo "decompress tools" >> ./VentoyPlugson.log
229 -cd ./tool/$TOOLDIR
231 -ls *.xz > /dev/null 2>&1
232 -if [ $? -eq 0 ]; then
233 - [ -f ./xzcat ] && chmod +x ./xzcat
235 - for file in $(ls *.xz); do
236 - echo "decompress $file" >> ./VentoyPlugson.log
237 - xzcat $file > ${file%.xz}
238 - [ -f ./${file%.xz} ] && chmod +x ./${file%.xz}
239 - [ -f ./$file ] && rm -f ./$file
240 - done
243 -cd ../../
244 -chmod +x -R ./tool/$TOOLDIR
246 -if ! [ -f "$OLDDIR/tool/$TOOLDIR/Plugson" ]; then
247 - echo "$OLDDIR/tool/$TOOLDIR/Plugson does not exist!"
248 - exit 1
252 PATH=./tool/$TOOLDIR:$PATH
254 HOST="127.0.0.1"
255 @@ -217,11 +184,3 @@
257 wait $wID
261 -if [ -n "$OLDDIR" ]; then
262 - CURDIR=$(pwd)
263 - if [ "$CURDIR" != "$OLDDIR" ]; then
264 - cd "$OLDDIR"
265 - fi
267 diff -Naur ventoy-1.0.81-old/VentoyWeb.sh ventoy-1.0.81-new/VentoyWeb.sh
268 --- ventoy-1.0.81-old/VentoyWeb.sh 2022-10-25 08:26:21.000000000 -0300
269 +++ ventoy-1.0.81-new/VentoyWeb.sh 2022-11-02 09:53:13.773791254 -0300
270 @@ -15,12 +15,6 @@
271 echo ""
274 -uid=$(id -u)
275 -if [ $uid -ne 0 ]; then
276 - print_err "Please use sudo or run the script as root."
277 - exit 1
280 OLDDIR=$(pwd)
282 if uname -m | egrep -q 'aarch64|arm64'; then
283 @@ -85,8 +79,8 @@
284 exit 1
287 -LOGFILE=log.txt
288 -#delete the log.txt if it's more than 8MB
289 +LOGFILE=/var/log/ventoy.log
290 +#delete the logfile if it's more than 8MB
291 if [ -f $LOGFILE ]; then
292 logsize=$(stat -c '%s' $LOGFILE)
293 if [ $logsize -gt 8388608 ]; then
294 @@ -94,7 +88,6 @@
299 if [ -f ./tool/$TOOLDIR/V2DServer.xz ]; then
300 xz -d ./tool/$TOOLDIR/V2DServer.xz
301 chmod +x ./tool/$TOOLDIR/V2DServer