Created
December 3, 2023 08:20
-
-
Save furandon-pig/75cea66c637dd7001add1e33d9ee0f68 to your computer and use it in GitHub Desktop.
NetBSD-currentの最新の配布物をダウンロードするスクリプトです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
BASE_URL=http://nyftp.netbsd.org/pub/NetBSD-daily/HEAD/latest | |
ARCH=amd64 | |
rm -rf working | |
mkdir -p working | |
cd working | |
if [ ! -f tmp.txt ]; then | |
curl -sL -o tmp.txt http://nyftp.netbsd.org/pub/NetBSD-daily/HEAD/ | |
fi | |
latest_dir=`cat tmp.txt \ | |
| grep latest \ | |
| sed \ | |
-e "s/^.*<\/a><td>//" \ | |
-e "s/<td.*$//" \ | |
-e "s/ /_/g" \ | |
-e "s/://g"` | |
cd .. | |
echo "[`LANG=C date`] download directory: $latest_dir" | |
if [ -d $latest_dir ]; then | |
echo "[`LANG=C date`] latest release already downloaded." | |
fi | |
mkdir -p $latest_dir | |
cd $latest_dir | |
download_files=" | |
$BASE_URL/$ARCH/binary/sets/kern-GENERIC.tar.xz | |
$BASE_URL/$ARCH/binary/sets/base.tar.xz | |
$BASE_URL/$ARCH/binary/sets/comp.tar.xz | |
$BASE_URL/$ARCH/binary/sets/etc.tar.xz | |
$BASE_URL/$ARCH/binary/sets/man.tar.xz | |
$BASE_URL/$ARCH/binary/sets/modules.tar.xz | |
$BASE_URL/$ARCH/binary/sets/misc.tar.xz | |
$BASE_URL/$ARCH/binary/sets/MD5 | |
" | |
for f in $download_files | |
do | |
fname=`echo $f | sed -e "s/^.*\///"` | |
if [ ! -f $fname ]; then | |
echo "[`LANG=C date`] download ${fname}..." | |
curl -sLO $f | |
fi | |
done | |
for f in $download_files | |
do | |
fname=`echo $f | sed -e "s/^.*\///"` | |
expect_md5=`grep -w $fname MD5 | awk '{ print $4 }'` | |
file_md5=`md5 $fname | awk '{ print $4 }'` | |
_err=0 | |
if [ "$expect_md5" != "$file_md5" -a "$fname" != "MD5" ]; then | |
echo "[`LANG=C date`] illigal md5 checksum: ${fname}..." | |
echo "[`LANG=C date`] original : $expect_md5" | |
echo "[`LANG=C date`] download : $file_md5" | |
_err=$((_err+1)) | |
fi | |
if [ $_err -ne 0 ]; then | |
echo "[`LANG=C date`] Error: checksum mismatch." | |
exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment