ich habe mit ein update Script geschrieben welches das CHDK auf der SD-Karte updatet, dabei ist mir aufgefallen das er auf eine FAT16 Partition keine Dateinamen länger als 8 Zeichen ablegen kann, aber in den CHDK-Verzeichnissen sind einige Dateien drin die länger sind.
Hier ist das Script
Syntax: [ Download ] [ Verstecken ]
Benutze Bash Syntax Highlighting
#!/bin/bash
toinstall_verno="930"
#media_dir="/media/"
meatinfo_filename="metainfo.txt"
firmwares_pattern="/home/gchoinka/Dokumente/robo-chdk/firmwares/chdk-de/rev_%s/%s-%s-full_BETA_rev_%s.zip"
#tmpdir="/home/gchoinka/Dokumente/robo-chdk/scripts/install_firmware/tmp/"$RANDOM"dir/"
tmpdir="/tmp/"$RANDOM"dir/"
ptpcam="$HOME/Dokumente/robo-chdk/chdk-de/tools/ptpcam/ptpcam"
export PATH=$PATH:$(dirname $ptpcam)
ptpcam="ptpcam"
mkdir -p "$tmpdir"
ln -f -s -T "$tmpdir" $(dirname "$tmpdir")"/last.dir"
#wie viele cams sind angeschlossen
ncams=$($ptpcam --list-devices | grep -E "[0-9]{3}/[0-9]{3}\s*0x[^/]*/0x\S*" | wc -l)
for ((i=1; i <= $ncams; ++i))
do
current_cam=$($ptpcam --list-devices | grep -E "[0-9]{3}/[0-9]{3}\s*0x[^/]*/0x\S*"| head -n $i | tail -n 1)
busid=$(echo $current_cam | head -c 3)
devid=$(echo $current_cam | head -c 7 | tail -c 3)
#sucht nach einer metainfo.txt datei im sd root verzeichniss
current_metainfo_filename="$tmpdir/$meatinfo_filename"
$ptpcam --chdk="download A/$meatinfo_filename $current_metainfo_filename"
cp "$current_metainfo_filename" "$current_metainfo_filename.bak"
if [ -f "$current_metainfo_filename" ]
then
source "$current_metainfo_filename"
orginal=$(printf $firmwares_pattern $chdk_verno $cam $cam_ver $chdk_verno)
new=$(printf $firmwares_pattern $toinstall_verno $cam $cam_ver $toinstall_verno)
unzip -o "$new" -d "$tmpdir/"
#erzeugt eine neue
cat > $current_metainfo_filename << EOF
#bash systax for variable
var_num="$var_num"
##on which side is the cam
#camside="right"
#camside="left"
camside="$camside"
##what chdk version is on this sd card
#chdk="en"
chdk="$chdk"
chdk_verno="$toinstall_verno"
#cam firmware version
cam="$cam"
cam_ver="$cam_ver"
EOF
ndirs=$(cd "$tmpdir" ; find . -iname "*" -type d| wc -l)
for ((k=2; k < $ndirs; ++k))
do
dir=$(cd "$tmpdir" ; find . -iname "*" -type d | head -n $k | tail -n 1 | tail -c +2)
echo $ptpcam --chdk='lua os.mkdir("A'$dir'")'
$ptpcam --chdk='lua os.mkdir("A'$dir'")'
done
nfiles=$(cd "$tmpdir" ; find . -iname "*" -type f | wc -l)
for ((k=1; k < $nfiles; ++k))
do
file=$(cd "$tmpdir" ; find . -iname "*" -type f | head -n $k | tail -n 1 | tail -c +3)
echo $ptpcam --chdk='upload '$tmpdir$file' A/'$file''
$ptpcam --chdk='upload '$tmpdir$file' A/'$file''
done
fi
done
$ptpcam --chdk='reboot'
toinstall_verno="930"
#media_dir="/media/"
meatinfo_filename="metainfo.txt"
firmwares_pattern="/home/gchoinka/Dokumente/robo-chdk/firmwares/chdk-de/rev_%s/%s-%s-full_BETA_rev_%s.zip"
#tmpdir="/home/gchoinka/Dokumente/robo-chdk/scripts/install_firmware/tmp/"$RANDOM"dir/"
tmpdir="/tmp/"$RANDOM"dir/"
ptpcam="$HOME/Dokumente/robo-chdk/chdk-de/tools/ptpcam/ptpcam"
export PATH=$PATH:$(dirname $ptpcam)
ptpcam="ptpcam"
mkdir -p "$tmpdir"
ln -f -s -T "$tmpdir" $(dirname "$tmpdir")"/last.dir"
#wie viele cams sind angeschlossen
ncams=$($ptpcam --list-devices | grep -E "[0-9]{3}/[0-9]{3}\s*0x[^/]*/0x\S*" | wc -l)
for ((i=1; i <= $ncams; ++i))
do
current_cam=$($ptpcam --list-devices | grep -E "[0-9]{3}/[0-9]{3}\s*0x[^/]*/0x\S*"| head -n $i | tail -n 1)
busid=$(echo $current_cam | head -c 3)
devid=$(echo $current_cam | head -c 7 | tail -c 3)
#sucht nach einer metainfo.txt datei im sd root verzeichniss
current_metainfo_filename="$tmpdir/$meatinfo_filename"
$ptpcam --chdk="download A/$meatinfo_filename $current_metainfo_filename"
cp "$current_metainfo_filename" "$current_metainfo_filename.bak"
if [ -f "$current_metainfo_filename" ]
then
source "$current_metainfo_filename"
orginal=$(printf $firmwares_pattern $chdk_verno $cam $cam_ver $chdk_verno)
new=$(printf $firmwares_pattern $toinstall_verno $cam $cam_ver $toinstall_verno)
unzip -o "$new" -d "$tmpdir/"
#erzeugt eine neue
cat > $current_metainfo_filename << EOF
#bash systax for variable
var_num="$var_num"
##on which side is the cam
#camside="right"
#camside="left"
camside="$camside"
##what chdk version is on this sd card
#chdk="en"
chdk="$chdk"
chdk_verno="$toinstall_verno"
#cam firmware version
cam="$cam"
cam_ver="$cam_ver"
EOF
ndirs=$(cd "$tmpdir" ; find . -iname "*" -type d| wc -l)
for ((k=2; k < $ndirs; ++k))
do
dir=$(cd "$tmpdir" ; find . -iname "*" -type d | head -n $k | tail -n 1 | tail -c +2)
echo $ptpcam --chdk='lua os.mkdir("A'$dir'")'
$ptpcam --chdk='lua os.mkdir("A'$dir'")'
done
nfiles=$(cd "$tmpdir" ; find . -iname "*" -type f | wc -l)
for ((k=1; k < $nfiles; ++k))
do
file=$(cd "$tmpdir" ; find . -iname "*" -type f | head -n $k | tail -n 1 | tail -c +3)
echo $ptpcam --chdk='upload '$tmpdir$file' A/'$file''
$ptpcam --chdk='upload '$tmpdir$file' A/'$file''
done
fi
done
$ptpcam --chdk='reboot'
Erstellt in 0.028 Sekunden, mit GeSHi 1.0.8.9
Die Ausgabe des Scriptes habe ich angehängt.
Hier ist ein Auszug der Ausgabe bei den ich das mit den zu langen Dateinamen bemerkt habe.
Syntax: [ Download ] [ Verstecken ]
- ptpcam --chdk=upload /tmp/4891dir/CHDK/SCRIPTS/EXAM/lotto.lua A/CHDK/SCRIPTS/EXAM/lotto.lua
- ptpcam --chdk=upload /tmp/4891dir/CHDK/SCRIPTS/EXAM/metronome.lua A/CHDK/SCRIPTS/EXAM/metronome.lua
- unexpected return code 0x2002
- upload failed!
- ptpcam --chdk=upload /tmp/4891dir/CHDK/SCRIPTS/EXAM/eggtimer.bas A/CHDK/SCRIPTS/EXAM/eggtimer.bas
- ptpcam --chdk=upload /tmp/4891dir/CHDK/SCRIPTS/EXAM/stopwatch.lua A/CHDK/SCRIPTS/EXAM/stopwatch.lua
- unexpected return code 0x2002
- upload failed!
- ptpcam --chdk=upload /tmp/4891dir/CHDK/SCRIPTS/EXAM/countdown.lua A/CHDK/SCRIPTS/EXAM/countdown.lua
- unexpected return code 0x2002
- upload failed!
- ptpcam --chdk=upload /tmp/4891dir/CHDK/SCRIPTS/MD/MD_FAST.txt A/CHDK/SCRIPTS/MD/MD_FAST.txt
Meine Frage ist:
ist das 8+3 Dateinamen auf FAT16 Problem bekannt
und besteht Bedarf an einen updateOverPtp-Script? (Mein Bash-Script ist ein Hack)