/usr/share/apt-zip/methods/wget-dos is in apt-zip 0.18.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | #!/bin/bash -e
error()
{
echo >&2 "apt-zip/methods/$(basename $0) ERROR: $*"
exit 1
}
warn()
{
echo >&2 "apt-zip/methods/$(basename $0) WARNING: $*"
}
print_header()
{
cat $1 <<-EOF
:: This file was auto-generated by apt-zip-list ${APTZIPVERSION}
:: Method: wget-dos - Options: ${OPTIONS}
EOF
}
add_check()
{
cat >>${SCRIPT}.bat <<-EOF
set to_check=$1
goto check
:$1_searched
EOF
[ "$WARNINSTALLED" ] && WARNINSTALLED+=" and "
WARNINSTALLED+="$1"
}
###############
# Stuff dependant on TAR option
# DOS: not yet
###############
# Stuff dependant on restart option
# DOS: not yet
[ "$OPTION_RESTART" != 0 -o "$OPTION_TAR" != 0 ] && error "Sorry, options not supported (yet)"
###############
# Make the batch file for downloading and checking
#
print_header >${SCRIPT}.utils
cat >>${SCRIPT}.utils <<-EOF
set file_to_check=%2
goto check_file
:get_file
wget -t3 -nv -O partial\\%2 %1
set file_to_check=partial\\%2
goto check_file
:file_ok
move partial\\%2 .
EOF
[ "$SLEEPTIME" -ne "0" ] && echo "if %HAS_sleep.exe%==1 sleep $SLEEPTIME" >>${SCRIPT}.utils
cat >>${SCRIPT}.utils <<-EOF
goto end
:check_file
if not exist %file_to_check% goto failed
EOF
[ ! "${USECHECKSUMS}" = 'no' ] && cat >>${SCRIPT}.utils <<-EOF
if "%3"=="" goto checksum_ok
if "%3"=="0" goto checksum_ok
if %HAS_sha256sum.exe%==1 echo %3 *%file_to_check% | sha256sum -c
if errorlevel 1 goto failed
:checksum_ok
EOF
cat >>${SCRIPT}.utils <<-EOF
if "%file_to_check%"=="partial\\%2" goto file_ok
echo %2 already downloaded.
goto end
:failed
if "%file_to_check%"=="%2" goto get_file
echo Failed to get %2!
:end
EOF
###############
# Make the main batch file which sets all up
#
SCRIPTNAME=${SCRIPT##*/}
WARNINSTALLED=
print_header >${SCRIPT}.bat
echo "@echo off" >>${SCRIPT}.bat
add_check wget.exe
[ ! "${USECHECKSUMS}" = 'no' ] && add_check sha256sum.exe
[ "$SLEEPTIME" -ne "0" ] && add_check sleep.exe
#FIXME: could not make dir?
cat >>${SCRIPT}.bat <<-EOF
set to_check=
if %HAS_wget.exe%==0 goto main_failed
mkdir partial >NUL
copy ${SCRIPTNAME}.utils u.bat >NUL
copy ${SCRIPTNAME} main.bat >NUL
call main.bat
set file_to_check=
del u.bat main.bat >NUL
goto end
:check
set HAS_tmp=0
if exist %to_check% set HAS_tmp=1
for %%d in (%path%) do if exist %%d\%to_check% set HAS_tmp=1
if %HAS_tmp%==0 echo Warning: %to_check% not found!
set HAS_%to_check%=%HAS_tmp%
set HAS_tmp=
goto %to_check%_searched
:main_failed
echo Critical error!
:end
set HAS_wget.exe=
set HAS_sha256sum.exe=
set HAS_sleep.exe=
EOF
###############
# Feed the data to the core function
#
print_header
echo "echo Download will be of size: $DWLSIZE in $PACKCOUNT files"
# '%' needs to be escaped twice here, so it will stay as a character inside a filename
if [ ! "${USECHECKSUMS}" = 'no' ]; then
awk '{gsub(/%/,"%%%%",$2); printf "call u.bat \"%s\" %s %s\n",$1,$2,$4}'
else
awk '{gsub(/%/,"%%%%",$2); printf "call u.bat \"%s\" %s\n",$1,$2}'
fi
warn "Make sure you have $WARNINSTALLED installed on the target machine."
|