Commit Diff
Diff:
c0497da928e0051c8153874b2898eda84e5c81b1
afbcf246584d7b0f9e2b609b99a843376f9200f6
Commit:
afbcf246584d7b0f9e2b609b99a843376f9200f6
Tree:
a2da6b859b04624a06a144c01a84180afb254206
Author:
Fred. Galusik <dev1@galusik.xyz>
Committer:
Fred. Galusik <dev1@galusik.xyz>
Date:
Sat Oct 15 16:34:49 2016 UTC
Message:
check build date if curl is installed and some vars cleanup
blob - 70eaf8b074d096d0d1a1ae98e58dcfe4fa77a0fb
blob + c8c7393342c369ccd3316f0d246c73af8077edb4
--- snaps
+++ snaps
@@ -40,17 +40,20 @@
### VARS
###
-VERSION=0.8.1
+VERSION=1.0
+RL=60 # signify var
MIRRORSOURCE=$(awk -F '=' '/^installpath/ { gsub(/ /,"",$2); print $2 }' /etc/pkg.conf)
ARCH=$(uname -m)
if [ ! $MIRROR ]; then
- #MIRROR=$(echo $MIRRORSOURCE | sed -e 's@installpath = @@' -e "s@\%c\/packages\/\%a@snapshots\/${ARCH}@")
- MIRROR="$(echo $MIRRORSOURCE | cut -d'/' -f-3)/pub/OpenBSD/snapshots/${ARCH}/"
+ MIRROR="$(echo $MIRRORSOURCE | cut -d'/' -f-3)"
fi
-RL=60 # signify var
+BPATH=/pub/OpenBSD/snapshots/${ARCH}/
+PKGPATH=/pub/OpenBSD/snapshots/packages/${ARCH}/
+MIRRORB=${MIRROR}${BPATH}
+MIRRORPKG=${MIRROR}${PKGPATH}
BSDRD=bsd.rd
SHAF=SHA256
@@ -65,12 +68,13 @@ NOW=$(date "+ %Y-%m-%d %R")
REMOTESNAPS='https://framagit.org/fredg/snaps/raw/master/snaps'
LASTSNAPS=/tmp/snaps
+
###
###
###
toupgrade() {
- echo "Checking for new version..."
+ echo "\nChecking for new version..."
# some cleanup to not let ftp warn about not supporting resume
if [[ -f $LASTSNAPS ]]; then
rm -f $LASTSNAPS
@@ -81,12 +85,10 @@ toupgrade() {
if [ $? -eq 0 ]; then
if [ "$VERSION" != "$REMOTEVERSION" ]; then
- echo ""
echo "==> WARNING: snaps is not up-to-date !"
echo "Last version: $REMOTEVERSION"
echo "To upgrade, run 'snaps -u'"
else
- echo ""
echo "==> GOOD: snaps is up-to-date"
fi
fi
@@ -113,7 +115,7 @@ usage() {
echo "MIRROR is based upon /etc/pkg.conf and set to: $MIRROR"
echo ""
echo "You can set it manually:"
- echo "\$ doas MIRROR=http://mirrors.ircam.fr/pub/OpenBSD/snapshots/amd64/ snaps -G"
+ echo "\$ doas MIRROR=http://mirrors.ircam.fr snaps -G"
echo ""
}
@@ -126,7 +128,7 @@ s_root() {
s_log() {
- echo "$NOW FROM $MIRROR" >> $LOGF
+ echo "$NOW FROM $MIRRORB" >> $LOGF
}
@@ -148,7 +150,7 @@ get_rd() {
rm ${_i}
fi
echo "==> Fetching new ${_i}"
- $GET $MIRROR${_i} || exit 1
+ $GET $MIRRORB${_i} || exit 1
done
}
@@ -225,18 +227,44 @@ s_upports() {
echo ""
}
+s_when() {
+ # will only be done if curl from port/package is installed
+ CURL=/usr/local/bin/curl
+ if [[ -e $CURL ]]; then
+ CURLB="$($CURL -sI ${MIRRORB}${SHAF} | grep Last-Modified)"
+ CURLP="$($CURL -sI ${MIRRORPKG}${SHAF} | grep Last-Modified)"
+ echo "\n=== BASE AND PACKAGES BUILD DATE ==="
+ echo "Base ($ARCH) => $CURLB"
+ echo "Packages ($ARCH) => $CURLP"
+ echo ""
+ echo -n "Do you want to continue ? (y/n): "
+ read _c
+ case ${_c} in
+ y|Y)
+ ;;
+ *)
+ echo "Aborting..."
+ exit 1
+ ;;
+ esac
+ fi
+}
+
##
## Run
##
-toupgrade
+
case $1 in
-g)
+ toupgrade
get_rd
s_check
;;
-G)
s_root
+ toupgrade
s_log
+ s_when
get_rd
s_check
s_move
@@ -255,3 +283,4 @@ case $1 in
exit 1
;;
esac
+
Frédéric Galusik