update: introduce core.lock for all packages

This commit is contained in:
Franco Fichtner 2019-01-02 12:46:11 +01:00
parent 26181f5240
commit 881e40b481
3 changed files with 57 additions and 31 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2018 Franco Fichtner <franco@opnsense.org>
Copyright (c) 2015-2019 Franco Fichtner <franco@opnsense.org>
Copyright (c) 2012-2014 Baptiste Daroussin <bapt@FreeBSD.org>
Copyright (c) 2013 Bryan Drewery <bdrewery@FreeBSD.org>
All rights reserved.

View File

@ -1,5 +1,5 @@
.\"
.\" Copyright (c) 2015-2018 Franco Fichtner <franco@opnsense.org>
.\" Copyright (c) 2015-2019 Franco Fichtner <franco@opnsense.org>
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd December 12, 2018
.Dd January 2, 2019
.Dt OPNSENSE-UPDATE 8
.Os
.Sh NAME
@ -41,9 +41,9 @@
.Op Fl r Ar release
.Op Fl t Ar type
.Nm
.Op Fl cfLU Op Fl bk
.Op Fl cf Op Fl bk
.Nm
.Op Fl ST Op Fl bkp
.Op Fl LSTU Op Fl bkp
.Nm
.Fl M
.Sh DESCRIPTION
@ -109,8 +109,7 @@ or
and ingored temporarily by
.Sq Fl f .
.It Fl l Ar directory
Instead of downloading, point to a local directory where the base and
kernel sets are stored.
Instead of downloading, point to a local directory where sets are located.
.It Fl M
Return the full release URL of the selected mirror.
.It Fl m Ar mirror_url
@ -149,13 +148,10 @@ Skip update phase; useful in conjunction with
and
.Sq Fl n .
.It Fl S
Check the size of the requested remote base, kernel or package set.
Return the download size of the requested remote set.
.It Fl T
Print the kernel
.Pq Sq Fl k
or base
.Pq Sq Fl b
lock status, exiting with an error if the respective set is locked.
Probe the lock status of the requested set,
exiting with an error if the respective set is locked.
.It Fl t Ar type
Switch to the release package
.Ar type ,
@ -209,6 +205,12 @@ and
The file is used to list files to be removed after installation
which are no longer required.
It is embedded into the base set.
.It Pa /usr/local/opnsense/version/core.lock
The lock for preventing an update to all packages,
operated by
.Sq Fl \&Lp
and
.Sq Fl \&Up .
.It Pa /usr/local/opnsense/version/kernel
The file is used to check if a kernel upgrade is necessary.
It is embedded into the kernel set.

View File

@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (c) 2015-2018 Franco Fichtner <franco@opnsense.org>
# Copyright (c) 2015-2019 Franco Fichtner <franco@opnsense.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@ -63,6 +63,11 @@ if [ -f ${VERSIONDIR}/base.lock ]; then
LOCKED_BASE=1
fi
LOCKED_PKGS=
if [ -f ${VERSIONDIR}/core.lock ]; then
LOCKED_PKGS=1
fi
INSTALLED_KERNEL=
if [ -f ${VERSIONDIR}/kernel ]; then
INSTALLED_KERNEL=$(cat ${VERSIONDIR}/kernel)
@ -263,6 +268,8 @@ elif [ "${DO_TYPE}" = "-T" ]; then
exit 1
elif [ -n "${DO_KERNEL}" -a -n "${LOCKED_KERNEL}" ]; then
exit 1
elif [ -n "${DO_PKGS}" -a -n "${LOCKED_PKGS}" ]; then
exit 1
fi
exit 0
fi
@ -282,6 +289,9 @@ if [ -n "${DO_LOCK}" ]; then
if [ -n "${DO_BASE}" ]; then
touch ${VERSIONDIR}/base.lock
fi
if [ -n "${DO_PKGS}" ]; then
touch ${VERSIONDIR}/core.lock
fi
exit 0
elif [ -n "${DO_UNLOCK}" ]; then
if [ -n "${DO_KERNEL}" ]; then
@ -290,9 +300,37 @@ elif [ -n "${DO_UNLOCK}" ]; then
if [ -n "${DO_BASE}" ]; then
rm -f ${VERSIONDIR}/base.lock
fi
if [ -n "${DO_PKGS}" ]; then
rm -f ${VERSIONDIR}/core.lock
fi
exit 0
fi
# DO_CHECK is not included, must be forced because we need both modes
if [ -z "${DO_FORCE}${DO_SIZE}" ]; then
# disable kernel if locked
if [ -n "${DO_KERNEL}" -a -n "${LOCKED_KERNEL}" -a \
-z "${DO_UPGRADE}" ]; then
echo "Kernel locked at ${INSTALLED_KERNEL}, skipping."
DO_KERNEL=
fi
# disable base if locked
if [ -n "${DO_BASE}" -a -n "${LOCKED_BASE}" -a \
-z "${DO_UPGRADE}" ]; then
echo "Base locked at ${INSTALLED_BASE}, skipping."
DO_BASE=
fi
# disable packages if locked
if [ -n "${DO_PKGS}" -a -n "${LOCKED_PKGS}" -a \
-z "${DO_UPGRADE}" ]; then
echo "Package update locked, skipping."
DO_PKGS=
DO_TYPE=
fi
fi
if [ -n "${DO_TYPE}" ]; then
OLD=$(opnsense-version -n)
NEW=${DO_TYPE#"-t "}
@ -324,23 +362,6 @@ if [ -n "${DO_TYPE}" ]; then
fi
fi
# DO_CHECK is not included, must be forced because we need both modes
if [ -z "${DO_FORCE}${DO_SIZE}" ]; then
# disable kernel if locked
if [ -n "${DO_KERNEL}" -a -n "${LOCKED_KERNEL}" -a \
-z "${DO_UPGRADE}" ]; then
echo "Kernel locked at ${INSTALLED_KERNEL}, skipping."
DO_KERNEL=
fi
# disable base if locked
if [ -n "${DO_BASE}" -a -n "${LOCKED_BASE}" -a \
-z "${DO_UPGRADE}" ]; then
echo "Base locked at ${INSTALLED_BASE}, skipping."
DO_BASE=
fi
fi
if [ -n "${DO_CHECK}" ]; then
if [ -n "${DO_KERNEL}" ]; then
if [ "${VERSION}" != "${INSTALLED_KERNEL}" ]; then
@ -634,6 +655,9 @@ install_pkgs()
}
if [ "${DO_PKGS}" = "-p" ]; then
if [ -z "${DO_FORCE}" -o -n "${DO_UPGRADE}" ]; then
rm -f ${VERSIONDIR}/core.lock
fi
fetch_set ${PACKAGESSET}
fi