From 0f437199b65025a903d568be87747cf5eb4b9805 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Sun, 26 Jun 2022 01:59:38 +0400 Subject: Support for *linux.7z archives --- download.sh | 6 +++--- generate.sh | 18 ++++++------------ lists/alps.txt | 7 +++++++ process.sh | 26 ++++++++++++++++++-------- 4 files changed, 34 insertions(+), 23 deletions(-) mode change 100755 => 100644 generate.sh create mode 100644 lists/alps.txt diff --git a/download.sh b/download.sh index d3ac068..791819e 100755 --- a/download.sh +++ b/download.sh @@ -48,7 +48,8 @@ function check { [ $fail -ne 0 ] && return $fail size=$(du -sm "downloads/$name" | awk '{ print $1 }') - [ $size -lt 2 ] && return 1 + [ -z "$size" ] && return 1 + [ "$size" -lt 2 ] && return 1 return 0 } @@ -63,14 +64,13 @@ for name in $(cat $list); do fail=$? if [ $fail -ne 0 ]; then - echo curl -L --cookie cookies.jar "$url_u/$name" -o "downloads/$name" #&> /dev/null + curl -L --cookie cookies.jar "$url_u/$name" -o "downloads/$name" &> /dev/null check "$?" "$name" fail=$? fail_nonu=1 fi if [ $fail -ne 0 ]; then - exit 1; rm -f downloads/$name fail=0 diff --git a/generate.sh b/generate.sh old mode 100755 new mode 100644 index ae4fdad..517c2e9 --- a/generate.sh +++ b/generate.sh @@ -7,7 +7,8 @@ function prepare { 7z x -owork $1 &> /dev/null [ $? -ne 0 ] && 7z x -owork $1 - for file_name in `find work -maxdepth 1 -name "???"`; do mv $file_name/* work/ ; done + for file_name in `find work -maxdepth 1 -type d -name "???"`; do mv $file_name/* work/ ; done + for file_name in `find work -maxdepth 1 -type d -regextype posix-extended -iregex ".*($name|mtb$name|velo$name)"`; do mv $file_name/* work/ ; done } function clean { @@ -19,25 +20,18 @@ if [ -z "$1" ]; then exit 1 fi -file=$1 +file="$1" +name="$2" +img="$3" echo "====> Generating Garmin maps for $file" -if [[ "$file" =~ "velo" ]]; then - typ=velo*.TYP - name=`basename $file .exe | cut -c 5-` - img=maps/velo-$name.img -else - name=`basename $file .exe | cut -c 4-` - img=maps/mtb-$name.img -fi - if [ -f $img ]; then echo "Already existing, skipping..." exit 0 fi -prepare $file +prepare "$file" if [ ! -f work/$typ ]; then [ -f work/clas*.TYP ] && typ=clas*.TYP diff --git a/lists/alps.txt b/lists/alps.txt new file mode 100644 index 0000000..cfcae47 --- /dev/null +++ b/lists/alps.txt @@ -0,0 +1,7 @@ +mtbaustria.exe +mtbfrancelinux.7z +mtbgermanylinux.7z +mtbitaly.exe +mtbslovenia.exe +mtbspain.exe +mtbswitzerland.exe diff --git a/process.sh b/process.sh index 06bba28..865a5c2 100755 --- a/process.sh +++ b/process.sh @@ -1,17 +1,27 @@ #! /bin/bash -for name in `ls downloads/*.exe`; do - if [[ "$name" =~ "velo" ]]; then - mapname=`basename $name .exe | cut -c 5-` - img=maps/velo-$mapname.img - else - mapname=`basename $name .exe | cut -c 4-` - img=maps/mtb-$mapname.img +for name in `find . -regextype posix-extended -iregex './downloads/.*(linux.7z|.exe)'`; do + if [[ "$name" =~ "linux.7z" ]]; then + if [[ "$name" =~ "velo" ]]; then + mapname=`basename $name linux.7z | cut -c 5-` + img=maps/velo-$mapname.img + else + mapname=`basename $name linux.7z | cut -c 4-` + img=maps/mtb-$mapname.img + fi + else + if [[ "$name" =~ "velo" ]]; then + mapname=`basename $name .exe | cut -c 5-` + img=maps/velo-$mapname.img + else + mapname=`basename $name .exe | cut -c 4-` + img=maps/mtb-$mapname.img + fi fi [ -f $img ] && continue - ./generate.sh $name + bash ./generate.sh "$name" "$mapname" "$img" if [ $? -ne 0 ]; then break fi -- cgit v1.2.3