Skip to content

Commit

Permalink
update: add `-l' for offline usage
Browse files Browse the repository at this point in the history
While there, mop up MIRROR and FLAVOUR style after their revamp
for version 16.1.6.
  • Loading branch information
fichtner committed Mar 9, 2016
1 parent 02d00b9 commit edbe10e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
8 changes: 6 additions & 2 deletions update/opnsense-update.8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.\"
.\" Copyright (c) 2015 Franco Fichtner <franco@opnsense.org>
.\" Copyright (c) 2015-2016 Franco Fichtner <franco@opnsense.org>
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -33,6 +33,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl bfikps
.Op Fl l Ar directory
.Op Fl m Ar mirror
.Op Fl n Ar flavour
.Op Fl r Ar release
Expand All @@ -56,7 +57,7 @@ The default is
attempting to update all components at once.
.Pp
The options are as follows:
.Bl -tag -width ".Fl r Ar release" -offset indent
.Bl -tag -width ".Fl l Ar directory" -offset indent
.It Fl b
Update the base system only.
.It Fl c
Expand All @@ -67,6 +68,9 @@ Force an update even when the latest release is already installed.
Ignore the signature verification result.
.It Fl k
Update the kernel only.
.It Fl l Ar directory
Instead of downloading, point to a local directory where the base and
kernel sets are stored.
.It Fl m Ar mirror
Change the set fetch and package location to
.Ar mirror .
Expand Down
26 changes: 20 additions & 6 deletions update/opnsense-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ DO_RELEASE=
DO_FLAVOUR=
DO_MIRROR=
DO_KERNEL=
DO_LOCAL=
DO_FORCE=
DO_BASE=
DO_PKGS=
DO_SKIP=

while getopts bcfikm:n:pr:sv OPT; do
while getopts bcfikl:m:n:pr:sv OPT; do
case ${OPT} in
b)
DO_BASE="-b"
Expand All @@ -86,13 +87,14 @@ while getopts bcfikm:n:pr:sv OPT; do
k)
DO_KERNEL="-k"
;;
l)
DO_LOCAL="-l ${OPTARG}"
;;
m)
DO_MIRROR="-m ${OPTARG}"
MIRROR=${OPTARG}
;;
n)
DO_FLAVOUR="-n ${OPTARG}"
FLAVOUR=${OPTARG}
;;
p)
DO_PKGS="-p"
Expand Down Expand Up @@ -124,7 +126,7 @@ fi

if [ -n "${DO_FLAVOUR}" ]; then
# replace the package repo name
sed -i '' '/'"${URL_KEY}"'/s/${ABI}.*/${ABI}\/'"${FLAVOUR}"'\",/' ${ORIGIN}
sed -i '' '/'"${URL_KEY}"'/s/${ABI}.*/${ABI}\/'"${DO_FLAVOUR#"-n "}"'\",/' ${ORIGIN}
fi

if [ -n "${DO_MIRROR}" ]; then
Expand All @@ -144,7 +146,7 @@ if [ -n "${DO_PKGS}" ]; then
pkg clean -ya
if [ -n "${DO_BASE}${DO_KERNEL}" ]; then
# script may have changed, relaunch...
opnsense-update ${DO_BASE} ${DO_KERNEL} \
opnsense-update ${DO_BASE} ${DO_KERNEL} ${DO_LOCAL} \
${DO_FORCE} ${DO_RELEASE} ${DO_MIRROR}
fi
# stop here to prevent the second pass
Expand Down Expand Up @@ -189,12 +191,22 @@ BASESET=base-${RELEASE}-${ARCH}.txz
WORKDIR=${WORKPREFIX}/${$}
KERNELDIR=/boot/kernel

if [ -n "${DO_LOCAL}" ]; then
WORKDIR=${DO_LOCAL#"-l "}
fi

fetch_set()
{
STAGE1="fetch -q ${MIRROR}/sets/${1}.sig -o ${WORKDIR}/${1}.sig"
STAGE2="fetch -q ${MIRROR}/sets/${1} -o ${WORKDIR}/${1}"
STAGE3="opnsense-verify -q ${WORKDIR}/${1}"

if [ -n "${DO_LOCAL}" ]; then
# already fetched, just test
STAGE1="test -f ${WORKDIR}/${1}.sig"
STAGE2="test -f ${WORKDIR}/${1}"
fi

if [ -n "${DO_INSECURE}" ]; then
# no signature, no cry
STAGE1=":"
Expand Down Expand Up @@ -290,6 +302,8 @@ if [ -n "${DO_BASE}" ]; then
echo ${RELEASE}-${ARCH} > ${MARKER}.base
fi

rm -rf ${WORKDIR}
if [ -z "${DO_LOCAL}" ]; then
rm -rf ${WORKDIR}
fi

echo "Please reboot."

0 comments on commit edbe10e

Please sign in to comment.