[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: jigdo-file: Does not report package rejections because checksum mismatch



On Thu, 28 Dec 2017, "Thomas Schmitt" <scdbackup@gmx.net> wrote:
...
> Especially in need of attention:
>
> - I could not find a clear description how "wget" determines the local
>   file paths from URLs and option --directory-prefix="$imageTmp".
>   My current conversion from URL to path is purely heuristic therefore:
>
>     localPath="$imageTmp"/`echo "$url" | \
>                            sed -e 's/^[hH][tT][tT][pP]:\/\///' \
>                                -e 's/^[hH][tT][tT][pP][sS]:\/\///' \
>                                -e 's/^[fF][tT][pP]:\/\///' \
>                                -e 's/^[fF][iI][lL][eE]:\/\///'`

A rather less laboured way of getting the same effect with sed would be:

  sed -e 's,^\(https\?\|ftp\|file\)://,,i'

[ Things to note about that:
     s,,, in place of s/// means that no escaping of / is needed
     the 'i' flag at the end makes the match case insensitive
     s\? means match zero or one 's'
]

However, I doubt that it's important to worry about the potential for
unexpectedly removing a prefix of e.g. cdrom:// or ://, in which case
you could dispense with sed and instead do this:

  localpath="$imageTmp/${url#[[:alpha:]]*://}"

> - I introduced a dependency on "awk", which was not used in jigdo-lite
>   before. The task is to obtain the first word of jigdo-file's output:
>
>     fileMD5=`$jigdoFile md5 "$localPath" 2>/dev/null | awk '{print $1}'`

The way it's done elsewhere in the script (which I happen to think is
pretty horrible, but that's what is already there) is using set, thus:

  set -- `$jigdoFile md5sum --report=quiet "$localPath"`

which leaves the value that you are after in $1.

I also happen to think that using `` rather than $() is pretty horrible
in this day and age, but that's what's currently there throughout the
script, so I guess one should stick with that, or fix it everywhere.

Cheers, Phil.
-- 
|)|  Philip Hands  [+44 (0)20 8530 9560]  HANDS.COM Ltd.
|-|  http://www.hands.com/    http://ftp.uk.debian.org/
|(|  Hugo-Klemm-Strasse 34,   21075 Hamburg,    GERMANY

Attachment: signature.asc
Description: PGP signature


Reply to: