Import of pkgsrc-2014Q1
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
# $NetBSD: Makefile,v 1.6 2012/10/23 19:51:26 asau Exp $
|
||||
# $NetBSD: Makefile,v 1.8 2014/02/08 15:59:30 jmmv Exp $
|
||||
|
||||
DISTNAME= sysupgrade-1.4
|
||||
DISTNAME= sysupgrade-1.5
|
||||
PKGREVISION= 1
|
||||
CATEGORIES= sysutils
|
||||
MASTER_SITES= # empty
|
||||
DISTFILES= # empty
|
||||
MASTER_SITES= https://github.com/jmmv/sysupgrade/releases/download/sysupgrade-1.5/
|
||||
|
||||
MAINTAINER= jmmv@NetBSD.org
|
||||
COMMENT= Automate upgrades of NetBSD
|
||||
@@ -11,16 +11,18 @@ LICENSE= modified-bsd
|
||||
|
||||
PKG_INSTALLATION_TYPES= overwrite pkgviews
|
||||
|
||||
WRKSRC= ${WRKDIR}
|
||||
NO_CONFIGURE= YES
|
||||
|
||||
BUILD_SUBST+= -e 's,@SYSUPGRADE_CACHEDIR@,${CACHEDIR},g'
|
||||
BUILD_SUBST+= -e 's,@SYSUPGRADE_ETCDIR@,${PKG_SYSCONFDIR},g'
|
||||
GNU_CONFIGURE= yes
|
||||
TEST_TARGET= check
|
||||
USE_LANGUAGES= # empty
|
||||
USE_TOOLS= pkg-config
|
||||
|
||||
BUILD_DEFS+= VARBASE
|
||||
CACHEDIR= ${VARBASE}/cache/sysupgrade
|
||||
OWN_DIRS= ${CACHEDIR} root wheel
|
||||
SYSUPGRADE_CACHEDIR= ${VARBASE}/cache/sysupgrade
|
||||
OWN_DIRS= ${SYSUPGRADE_CACHEDIR} root wheel
|
||||
CONFIGURE_ARGS+= SYSUPGRADE_CACHEDIR=${SYSUPGRADE_CACHEDIR}
|
||||
|
||||
CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
|
||||
INSTALL_MAKE_FLAGS+= sysconfdir=${EGDIR}
|
||||
EGDIR= ${PREFIX}/share/examples/sysupgrade
|
||||
CONF_FILES+= ${EGDIR}/default.conf ${PKG_SYSCONFDIR}/sysupgrade.conf
|
||||
|
||||
@@ -31,50 +33,12 @@ PKG_SUGGESTED_OPTIONS= tests
|
||||
.include "../../mk/bsd.options.mk"
|
||||
|
||||
.if $(PKG_OPTIONS:Mtests)
|
||||
. include "../../devel/atf/buildlink3.mk"
|
||||
PLIST_SUBST+= TESTS=
|
||||
. include "../../devel/atf-libs/buildlink3.mk"
|
||||
|
||||
BUILD_SUBST+= -e 's,@ATF_SH@,${BUILDLINK_PREFIX.atf-libs}/bin/atf-sh,g'
|
||||
|
||||
do-build: build-tests
|
||||
build-tests:
|
||||
cp ${FILESDIR}/Kyuafile ${WRKSRC}
|
||||
sed ${BUILD_SUBST} ${FILESDIR}/sysupgrade_test.sh \
|
||||
>${WRKSRC}/sysupgrade_test
|
||||
chmod +x ${WRKSRC}/sysupgrade_test
|
||||
|
||||
INSTALLATION_DIRS+= tests/sysupgrade
|
||||
|
||||
do-install: install-tests
|
||||
install-tests:
|
||||
${INSTALL_DATA} ${WRKSRC}/Kyuafile ${DESTDIR}${PREFIX}/tests/sysupgrade
|
||||
${INSTALL_SCRIPT} ${WRKSRC}/sysupgrade_test \
|
||||
${DESTDIR}${PREFIX}/tests/sysupgrade/
|
||||
|
||||
do-test:
|
||||
cd ${WRKSRC} && PATH="${WRKSRC}:${PATH}" kyua test
|
||||
.else
|
||||
PLIST_SUBST+= TESTS=@comment
|
||||
.endif
|
||||
|
||||
do-build:
|
||||
sed ${BUILD_SUBST} ${FILESDIR}/sysupgrade.sh \
|
||||
| ${BUILDLINK_PREFIX.shtk}/bin/shtk build \
|
||||
-s ${SH} -m sysupgrade_main -o ${WRKSRC}/sysupgrade -
|
||||
.for file in sysupgrade.8 sysupgrade.conf.5 default.conf
|
||||
sed ${BUILD_SUBST} <${FILESDIR}/${file} >${WRKSRC}/${file}
|
||||
.endfor
|
||||
|
||||
INSTALLATION_DIRS+= bin ${PKGMANDIR}/man5 ${PKGMANDIR}/man8 \
|
||||
share/examples/sysupgrade
|
||||
|
||||
do-install:
|
||||
${INSTALL_SCRIPT} ${WRKSRC}/sysupgrade ${DESTDIR}${PREFIX}/bin/
|
||||
${INSTALL_MAN} ${WRKSRC}/sysupgrade.8 \
|
||||
${DESTDIR}${PREFIX}/${PKGMANDIR}/man8/
|
||||
${INSTALL_MAN} ${WRKSRC}/sysupgrade.conf.5 \
|
||||
${DESTDIR}${PREFIX}/${PKGMANDIR}/man5/
|
||||
${INSTALL_DATA} ${WRKSRC}/default.conf ${DESTDIR}${EGDIR}
|
||||
|
||||
BUILDLINK_API_DEPENDS.shtk+= shtk>=1.3
|
||||
.include "../../devel/shtk/buildlink3.mk"
|
||||
.include "../../mk/bsd.pkg.mk"
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
@comment $NetBSD: PLIST,v 1.2 2012/08/15 21:21:15 jmmv Exp $
|
||||
bin/sysupgrade
|
||||
@comment $NetBSD: PLIST,v 1.3 2013/07/28 23:37:14 jmmv Exp $
|
||||
man/man5/sysupgrade.conf.5
|
||||
man/man8/sysupgrade.8
|
||||
sbin/sysupgrade
|
||||
share/doc/sysupgrade/AUTHORS
|
||||
share/doc/sysupgrade/COPYING
|
||||
share/doc/sysupgrade/NEWS
|
||||
share/doc/sysupgrade/README
|
||||
share/examples/sysupgrade/default.conf
|
||||
${TESTS}tests/sysupgrade/Kyuafile
|
||||
${TESTS}tests/sysupgrade/sysupgrade_test
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
Things that sysupgrade could do
|
||||
===============================
|
||||
|
||||
- Deduce the current NetBSD release from /etc/release and the target
|
||||
release from etc.tgz and inform the user about the changes. This will be
|
||||
necessary if the upgrade process needs to apply specific tweaks depending
|
||||
on the affected NetBSD releases (which is not the case at the moment).
|
||||
|
||||
- Ability to automatically deduce the next upgrade target from a collection
|
||||
of directories (e.g. from FTP). We should be able to tell sysupgrade to
|
||||
follow along 6.0.x, or 6.x, or the daily builds and get it to pick the
|
||||
most recent available build. Having to manually scan FTP directories to
|
||||
select the correct build is... inconvenient.
|
||||
|
||||
- Ensure that the fetched sets belong to the current architecture. I have
|
||||
bitten once by mistakenly pointing my custom update scripts to the wrong
|
||||
platform directory, rendering the machine unusable as soon as base.tgz
|
||||
was unpacked.
|
||||
|
||||
- Download release checksums and validate files against them. The 'fetch'
|
||||
command should unconditionally download the checksums every time it is
|
||||
run and then deduce whether it needs to redownload (possibly-newer) sets
|
||||
or do nothing.
|
||||
|
||||
- Add destdir support to etcupdate(8) and allow the 'etcupdate' command to
|
||||
run when destdir is enabled.
|
||||
|
||||
- Maybe sysupgrade should be more interactive by default, letting the user
|
||||
know what exactly is going to happen before doing so (e.g. what will be
|
||||
the new version, where things are being downloaded from, etc.), and
|
||||
providing a "quiet mode" flag instead. etcupdate is interactive anyway,
|
||||
so adding more interactive steps (as long as they can be disabled) does
|
||||
not seem a big deal.
|
||||
|
||||
|
||||
Things that sysupgrade will NOT do
|
||||
==================================
|
||||
|
||||
- Non-trivial rollbacks. If rollbacks are ever implemented, they should
|
||||
be in the form of file system snapshots OR in the form of syspkgs.
|
||||
Getting sysupgrade to magically store files aside to allow a later
|
||||
rollback is just too fragile and hard to get right: rollbacks will
|
||||
rarely will be necessary, but when they are it's very likely that a
|
||||
tool like this is broken.
|
||||
5
sysutils/sysupgrade/distinfo
Normal file
5
sysutils/sysupgrade/distinfo
Normal file
@@ -0,0 +1,5 @@
|
||||
$NetBSD: distinfo,v 1.1 2013/07/28 23:37:14 jmmv Exp $
|
||||
|
||||
SHA1 (sysupgrade-1.5.tar.gz) = 3141ee4728d6d3b680ed04f552369031bb3b3b09
|
||||
RMD160 (sysupgrade-1.5.tar.gz) = 5b1d7c6d45643f2f03bff1df16739a6751d0ceda
|
||||
Size (sysupgrade-1.5.tar.gz) = 75833 bytes
|
||||
@@ -1,5 +0,0 @@
|
||||
syntax("kyuafile", 1)
|
||||
|
||||
test_suite("sysupgrade")
|
||||
|
||||
atf_test_program{name="sysupgrade_test"}
|
||||
@@ -1,36 +0,0 @@
|
||||
# $NetBSD: default.conf,v 1.2 2012/10/11 00:16:46 jmmv Exp $
|
||||
|
||||
# Configuration of automatic system upgrades by sysupgrade(8).
|
||||
#
|
||||
# See sysupgrade.conf(5) for details on the syntax of this file and the
|
||||
# meaning of the configuration variables. Note that not all the supported
|
||||
# configuration variables are listed in this sample configuration file.
|
||||
|
||||
# Path to the release files (local path or remote URL).
|
||||
#RELEASEDIR="ftp://ftp.NetBSD.org/pub/NetBSD/NetBSD-6.0/$(uname -m)"
|
||||
#RELEASEDIR="ssh://me@builder.example.net/home/sysbuild/release/$(uname -m)"
|
||||
RELEASEDIR="/home/sysbuild/release/$(uname -m)"
|
||||
|
||||
# Name of the kernel to be installed.
|
||||
KERNEL=AUTO # Guess from /netbsd (requires config(1)).
|
||||
|
||||
# Whitespace-separated list of sets to install.
|
||||
SETS=AUTO # Guess from /etc/mtree/set.* files.
|
||||
|
||||
# Whitespace-separated list of postinstall(8) checks to automatically fix.
|
||||
POSTINSTALL_AUTOFIX="obsolete"
|
||||
|
||||
# Whether to run etcupdate or not as part of an upgrade.
|
||||
#
|
||||
# Running etcupdate is the only interactive step in the upgrade process, so
|
||||
# setting this variable to 'no' effectively makes upgrades unattended. You
|
||||
# can later run etcupdate at a later step by hand.
|
||||
#ETCUPDATE=no
|
||||
|
||||
# Whether to delete the downloaded files after an upgrade or not.
|
||||
#
|
||||
# If you set ETCUPDATE=no, you will most likely want to disable
|
||||
# auto-cleaning as well. The reason for this is that, if you want to later
|
||||
# do "sysupgrade etcupdate" using the same etc.tgz file downloaded during
|
||||
# the upgrade, you will need the same etc.tgz file to be present.
|
||||
#AUTOCLEAN=no
|
||||
@@ -1,390 +0,0 @@
|
||||
.\" $NetBSD: sysupgrade.8,v 1.5 2013/02/16 11:17:19 jmmv Exp $
|
||||
.\" Copyright 2012 Google Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are
|
||||
.\" met:
|
||||
.\"
|
||||
.\" * Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" * Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" * Neither the name of Google Inc. nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
.\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.Dd October 10, 2012
|
||||
.Dt SYSUPGRADE 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm sysupgrade
|
||||
.Nd upgrades a NetBSD system to a newer version
|
||||
.Sh SYNOPSIS
|
||||
common_flags ::=
|
||||
.Op Fl c Ar config_name
|
||||
.Op Fl d Ar destdir
|
||||
.Op Fl o Ar variable=value
|
||||
.Pp
|
||||
.Em Major commands :
|
||||
.Pp
|
||||
.Nm
|
||||
.Op common_flags
|
||||
.Ar auto
|
||||
.Op Ar releasedir
|
||||
.Nm
|
||||
.Op common_flags
|
||||
.Ar config
|
||||
.Op Fl a
|
||||
.Pp
|
||||
.Em Standalone upgrade steps :
|
||||
.Pp
|
||||
.Nm
|
||||
.Op common_flags
|
||||
.Ar clean
|
||||
.Nm
|
||||
.Op common_flags
|
||||
.Ar etcupdate
|
||||
.Nm
|
||||
.Op common_flags
|
||||
.Ar fetch
|
||||
.Op Ar releasedir
|
||||
.Nm
|
||||
.Op common_flags
|
||||
.Ar kernel
|
||||
.Op Ar kernel_name
|
||||
.Nm
|
||||
.Op common_flags
|
||||
.Ar modules
|
||||
.Nm
|
||||
.Op common_flags
|
||||
.Ar sets
|
||||
.Op Ar set1 .. setN
|
||||
.Nm
|
||||
.Op common_flags
|
||||
.Ar postinstall
|
||||
.Op Ar arg1 .. argN
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
is a utility that automates the process of upgrading a possibly-running
|
||||
.Nx
|
||||
system to a newer release.
|
||||
.Pp
|
||||
.Nm
|
||||
works by first fetching the release sets from a remote site or from a local
|
||||
directory, then by upgrading the system using such release sets and finally by
|
||||
taking care of bringing the system configuration up to date.
|
||||
In other words,
|
||||
.Nm
|
||||
does nothing special on its own: it is just a utility that automates a highly
|
||||
manual process and relies on other tools within the system to perform its job.
|
||||
.Pp
|
||||
.Nm
|
||||
has a subcommand-based interface: every command performs a single step of the
|
||||
upgrade procedure, and the
|
||||
.Sq auto
|
||||
command orchestrates a complete upgrade by invoking the rest of the commands in
|
||||
a specific order.
|
||||
There are a set of options that apply to all commands (those stated before the
|
||||
command name), and every particular command may accept its own options and
|
||||
arguments as shown in the synopsis.
|
||||
.Pp
|
||||
The behavior of
|
||||
.Nm
|
||||
is defined by a configuration file that specifies how to apply an update to the
|
||||
system (see
|
||||
.Xr sysupgrade.conf 5 ) .
|
||||
For example, the configuration states which distribution sets ought to be
|
||||
installed, where they need to be downloaded from, and whether the system
|
||||
configuration files should be upgraded.
|
||||
.Pp
|
||||
The following options apply to all commands:
|
||||
.Bl -tag -width XoXvariableXvalueXX
|
||||
.It Fl c Ar config_file
|
||||
Specifies the configuration file to use.
|
||||
.Pp
|
||||
Default:
|
||||
.Pa @SYSUPGRADE_ETCDIR@/sysupgrade.conf
|
||||
.It Fl d Ar destdir
|
||||
Path to the
|
||||
.Nx
|
||||
system to upgrade.
|
||||
.Pp
|
||||
This optional flag can be used to upgrade a non-live system or for
|
||||
testing/development purposes.
|
||||
Note that some steps (particularly
|
||||
.Sq etcupdate )
|
||||
do not support this feature and thus will never be run if set.
|
||||
.Pp
|
||||
Default: not set (which means
|
||||
.Pa /
|
||||
is affected).
|
||||
.It Fl o Ar variable=value
|
||||
Applies an override to the loaded configuration.
|
||||
.Pp
|
||||
The
|
||||
.Ar variable
|
||||
part of the argument must be any of the recognized configuration variables
|
||||
described in
|
||||
.Xr sysupgrade.conf 5 .
|
||||
The
|
||||
.Ar value ,
|
||||
if not empty, specifies the value to set the configuration variable to.
|
||||
If
|
||||
.Ar value
|
||||
is empty, then the configuration variable is unset.
|
||||
.El
|
||||
.Ss The auto command
|
||||
The auto command is the most important command in
|
||||
.Nm ,
|
||||
and is probably the one you will find yourself using most frequently.
|
||||
This is the command that takes care of upgrading a full
|
||||
.Nx
|
||||
installation, and it does so by invoking the other commands in the tool in the
|
||||
specific order in which they are needed.
|
||||
.Pp
|
||||
The optional argument
|
||||
.Ar releasedir
|
||||
points to the release directory or URL to use, overriding the value of
|
||||
.Va RELEASEDIR
|
||||
in the configuration file (if any).
|
||||
If you are tracking daily builds from an FTP site, for example, you will
|
||||
probably want to avoid setting
|
||||
.Va RELEASEDIR
|
||||
in the configuration file and instead pass an URL each time you run this
|
||||
command.
|
||||
.Pp
|
||||
The standard upgrade procedure performed by this command is as follows:
|
||||
.Bl -enum
|
||||
.It
|
||||
.Sq fetch :
|
||||
Retrieve distribution sets into the local cache directory.
|
||||
.It
|
||||
.Sq modules :
|
||||
Unpack new kernel modules.
|
||||
.It
|
||||
.Sq kernel :
|
||||
Upgrade kernel.
|
||||
.It
|
||||
.Sq sets :
|
||||
Upgrade system sets, except configuration files.
|
||||
.It
|
||||
.Sq etcupdate :
|
||||
Merge new changes to configuration files.
|
||||
This is the only interactive step in the process and can be disabled for this
|
||||
reason by setting
|
||||
.Va ETCUPDATE
|
||||
to false.
|
||||
.It
|
||||
.Sq postinstall :
|
||||
Perform sanity checks and optionally apply unconditional fixes to the upgraded
|
||||
system.
|
||||
.It
|
||||
.Sq clean :
|
||||
Remove contents of the cache directory.
|
||||
This can be disabled by setting
|
||||
.Va AUTOCLEAN
|
||||
to false in case you want to keep the downloaded distribution files around.
|
||||
.El
|
||||
.Ss The clean command
|
||||
The clean command removes any distribution sets from the local cache directory.
|
||||
.Ss The config command
|
||||
The config command dumps the loaded configuration to the standard output.
|
||||
The format of the output is not a script, so it cannot be fed back into
|
||||
.Nm .
|
||||
The purpose of this command is to aid in debugging the configuration of the
|
||||
tool before performing any builds, particularly when the configuration
|
||||
files use shell logic to determine the value of any variables.
|
||||
.Pp
|
||||
The following options are accepted:
|
||||
.Bl -tag -width XaXX
|
||||
.It Fl a
|
||||
Process automatic variables such as
|
||||
.Va KERNEL
|
||||
and
|
||||
.Va SETS
|
||||
and display their deduced values instead of only showing the literal
|
||||
.Sq AUTO .
|
||||
.El
|
||||
.Ss The etcupdate command
|
||||
The etcupdate command invokes
|
||||
.Xr etcupdate 8
|
||||
to perform an interactive upgrade of the system configuration files in
|
||||
.Pa /etc .
|
||||
This is the only interactive process in a full system upgrade.
|
||||
.Pp
|
||||
In order for this command to do anything useful, the list of sets to install as
|
||||
specified by the
|
||||
.Va SETS
|
||||
configuration variable
|
||||
.Em must include
|
||||
.Sq etc ,
|
||||
and may optionally include
|
||||
.Sq xetc .
|
||||
.Pp
|
||||
Note that, due to defficiencies in the
|
||||
.Xr etcupdate 8
|
||||
utility, this command does not work when
|
||||
.Va DESTDIR
|
||||
is set.
|
||||
.Ss The fetch command
|
||||
The fetch command gets a copy of the release sets as pointed to by the
|
||||
.Va RELEASEDIR
|
||||
variable into a local cache directory, or from the directory indicated by the
|
||||
optional argument
|
||||
.Ar releasedir .
|
||||
.Pp
|
||||
If
|
||||
.Va RELEASEDIR
|
||||
points to a local directory, the utility just creates symlinks within the cache
|
||||
directory pointing to the original files.
|
||||
Otherwise, if
|
||||
.Va RELEASEDIR
|
||||
points to a remote FTP, HTTP or SSH site, the fetch command will retrieve the
|
||||
contents of the release directory into the local cache directory.
|
||||
.Pp
|
||||
Please note that all the commands that access distribution sets do so by looking
|
||||
for such files in the cache directory
|
||||
.Em even when the release directory is in a local path .
|
||||
This means that, for such commands to work, you must run fetch beforehand.
|
||||
.Ss The kernel command
|
||||
The kernel command upgrades the kernel to a newer version.
|
||||
The kernel to install is determined by the optional argument
|
||||
.Ar kernel_name
|
||||
if present, or otherwise from the
|
||||
.Va KERNEL
|
||||
variable.
|
||||
The kernel is expected to be found in a
|
||||
.Sq netbsd-<NAME>.gz
|
||||
file in the release directory.
|
||||
.Pp
|
||||
The previous kernel is backed up as
|
||||
.Pa <destdir>/onetbsd .
|
||||
.Ss The modules command
|
||||
The modules command upgrades the kernel modules to a newer version.
|
||||
This operation only takes place if the sets to be installed, as specified by the
|
||||
.Va SETS
|
||||
variable, contains the
|
||||
.Sq modules
|
||||
set.
|
||||
.Ss The sets command
|
||||
The sets command upgrades all non-kernel, non-modules and non-configuration sets
|
||||
of the system to a newer version.
|
||||
In other words, this command installs sets like
|
||||
.Sq base
|
||||
or
|
||||
.Sq tests
|
||||
but explicitly skips sets of the forms
|
||||
.Sq *etc
|
||||
and
|
||||
.Sq modules .
|
||||
The presence of any
|
||||
.Sq kern-*
|
||||
sets in the list will cause this command to fail.
|
||||
.Pp
|
||||
The list of sets to be installed is determined by the optional arguments passed
|
||||
to the command or, if none, from the value of the
|
||||
.Va SETS
|
||||
configuration variable.
|
||||
.Ss The postinstall command
|
||||
The postinstall command invokes the
|
||||
.Xr postinstall 8
|
||||
utility to perform checks and fixes on the system after all new files have been
|
||||
put in place.
|
||||
.Pp
|
||||
The
|
||||
.Va POSTINSTALL_AUTOFIX
|
||||
variable can optionally include a list of
|
||||
.Xr postinstall 8
|
||||
fixes to be applied to a system unconditionally.
|
||||
For example, listing
|
||||
.Sq obsolete
|
||||
in this variable is usually useful as this check fails often during upgrades and
|
||||
is safe to auto-fix.
|
||||
.Pp
|
||||
Any arguments supplied to the command are passed directly to
|
||||
.Xr postinstall 8 ,
|
||||
which comes handy in those cases where you have to manually fix a broken test.
|
||||
.Sh FILES
|
||||
.Bl -tag -width XXXX
|
||||
.It Pa @SYSUPGRADE_ETCDIR@/sysupgrade.conf
|
||||
Default configuration file.
|
||||
.It Pa @SYSUPGRADE_CACHEDIR@
|
||||
Location where distribution sets are temporarily stored.
|
||||
The
|
||||
.Sq fetch
|
||||
command writes files into this directory and the
|
||||
.Sq clean
|
||||
command clears its contents.
|
||||
.It Pa /home/sysbuild/release/<machine>
|
||||
Standard location of the releases built by the
|
||||
.Xr sysbuild 1
|
||||
utility.
|
||||
.El
|
||||
.Sh EXAMPLES AND TROUBLESHOOTING
|
||||
The most common way of executing
|
||||
.Nm
|
||||
is by using the
|
||||
.Sq auto
|
||||
command and relying in the default configuration file:
|
||||
.Bd -literal -offset indent
|
||||
$ sysupgrade auto
|
||||
.Ed
|
||||
.Pp
|
||||
If you wish to track minor stable releases, you may want to do something like
|
||||
this every time a new release is published:
|
||||
.Bd -literal -offset indent
|
||||
$ sysupgrade auto \\
|
||||
ftp://ftp.NetBSD.org/pub/NetBSD/NetBSD-6.<minor>/$(uname -m)
|
||||
.Ed
|
||||
.Pp
|
||||
If the upgrade process fails due to an aborted FTP or HTTP connection, simply
|
||||
rerun
|
||||
.Nm
|
||||
in
|
||||
.Sq auto
|
||||
mode and it will resume the download where it left off.
|
||||
.Pp
|
||||
If the
|
||||
.Sq postinstall
|
||||
step fails due to broken checks, you can manually resume that stage and complete
|
||||
the upgrade by doing:
|
||||
.Bd -literal -offset indent
|
||||
$ sysupgrade postinstall fix <names of the failed checks>
|
||||
$ sysupgrade clean
|
||||
.Ed
|
||||
.Pp
|
||||
If you have decided to run
|
||||
.Xr etcupdate 8
|
||||
by hand separately from
|
||||
.Nm ,
|
||||
you could do:
|
||||
.Bd -literal -offset indent
|
||||
$ sysupgrade -o AUTOCLEAN=no -o ETCUPDATE=no auto
|
||||
\&... and later, at your earliest convenience ...
|
||||
$ sysupgrade etcupdate
|
||||
$ sysupgrade clean
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr sysbuild 1 ,
|
||||
.Xr sysupgrade.conf 5 ,
|
||||
.Xr etcupdate 8 ,
|
||||
.Xr postinstall 8
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
utility was developed by
|
||||
.An Julio Merino
|
||||
.Aq jmmv@NetBSD.org .
|
||||
@@ -1,167 +0,0 @@
|
||||
.\" $NetBSD: sysupgrade.conf.5,v 1.4 2012/10/11 07:56:13 wiz Exp $
|
||||
.\" Copyright 2012 Google Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are
|
||||
.\" met:
|
||||
.\"
|
||||
.\" * Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" * Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" * Neither the name of Google Inc. nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
.\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.Dd October 10, 2012
|
||||
.Dt SYSUPGRADE.CONF 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm sysupgrade.conf
|
||||
.Nd configuration file to control NetBSD system upgrades
|
||||
.Sh DESCRIPTION
|
||||
Configuration files for
|
||||
.Xr sysupgrade 8
|
||||
are simple shell scripts that set, or explicitly clear, a collection of known
|
||||
configuration variables.
|
||||
.Pp
|
||||
The following configuration variables are recognized:
|
||||
.Bl -tag
|
||||
.It Va AUTOCLEAN
|
||||
Whether to automatically delete the downloaded files or not as part of the
|
||||
.Sq auto
|
||||
command.
|
||||
.Pp
|
||||
If you set
|
||||
.Va ETCUPDATE
|
||||
to false, you will probably want to disable autocleaning.
|
||||
This will let you run the
|
||||
.Sq etcupdate
|
||||
command on your own at a later stage reusing the same distribution sets used to
|
||||
upgrade the system.
|
||||
.Pp
|
||||
Default: yes.
|
||||
.It Va CACHEDIR
|
||||
Path to the local directory into which distribution sets are temporarily fetched
|
||||
while applying a system upgrade.
|
||||
Note that all
|
||||
.Nm
|
||||
commands that need access to the distribution sets (pretty much all of them)
|
||||
will read from this directory.
|
||||
If you plan on issuing different upgrade steps at different times, this
|
||||
directory should persist across the different executions.
|
||||
.Pp
|
||||
Default:
|
||||
.Pa @SYSUPGRADE_CACHEDIR@
|
||||
.It Va DESTDIR
|
||||
Path to the root of the system to be upgraded.
|
||||
This is prepended to all other paths affected by
|
||||
.Xr sysupgrade 8
|
||||
and can be used to perform upgrades of non-live systems or for testing
|
||||
purposes.
|
||||
.Pp
|
||||
Default: not set (which means
|
||||
.Pa /
|
||||
is affected).
|
||||
.It Va ETCUPDATE
|
||||
Whether to run
|
||||
.Xr etcupdate 8
|
||||
as part of an automated upgrade.
|
||||
You may want to disable this because this is the only interactive step in the
|
||||
upgrade process.
|
||||
.Pp
|
||||
If set to false, the
|
||||
.Sq auto
|
||||
subcommand will skip this step.
|
||||
In this case, you are also recommended to set
|
||||
.Va AUTOCLEAN
|
||||
to
|
||||
.Sq no
|
||||
so that you are not required to redownload the distribution files just to run
|
||||
.Xr etcupdate 8
|
||||
later.
|
||||
.Pp
|
||||
Default: yes.
|
||||
.It Va KERNEL
|
||||
Name of the kernel to install.
|
||||
There must be a
|
||||
.Sq netbsd-<KERNEL>.gz
|
||||
file in the release directory matching this name.
|
||||
.Pp
|
||||
If this is set to the magic value
|
||||
.Sq AUTO ,
|
||||
.Xr sysupgrade 8
|
||||
will attempt to automatically determine the name of the current kernel by using
|
||||
.Xr config 1
|
||||
on
|
||||
.Pa <DESTDIR>/netbsd .
|
||||
If the guessing fails, an error is raised to prevent installing a mismatching
|
||||
kernel.
|
||||
.Pp
|
||||
Default: AUTO.
|
||||
.It Va POSTINSTALL_AUTOFIX
|
||||
Whitespace-separated list of
|
||||
.Xr postinstall 8
|
||||
checks that will be unconditionally fixed as part of an upgrade.
|
||||
.Pp
|
||||
It is recommended that you include
|
||||
.Sq obsolete
|
||||
in this list at the very least: this check often fails because it is common for
|
||||
newer releases to drop existing files, and fixing it should be harmless.
|
||||
Note that old shared libraries are never cleaned by this check, so existing
|
||||
third-party binaries should not stop working even after auto-fixing this check.
|
||||
.Pp
|
||||
Default: empty.
|
||||
.It Va RELEASEDIR
|
||||
Location of the release directory (which must hold a
|
||||
.Pa binary/sets/
|
||||
subdirectory).
|
||||
This can be either a local path or a URL.
|
||||
.Pp
|
||||
If the location is a URL, any of the HTTP, FTP or SSH protocols are supported.
|
||||
In the case of SSH, the URL takes the form:
|
||||
.Sq ssh://[user[:password]@]<host>/<absolute_path> ,
|
||||
which is different to the syntax accepted by
|
||||
.Xr scp 1 .
|
||||
.Pp
|
||||
Default: not set.
|
||||
.It Va SETS
|
||||
Whitespace-separated list of distribution sets to install.
|
||||
If this is set to the magic value
|
||||
.Sq AUTO ,
|
||||
the list of sets is determined from the files in
|
||||
.Pa <DESTDIR>/etc/mtree .
|
||||
.Pp
|
||||
This list cannot include any
|
||||
.Sq kern-*
|
||||
sets; the kernel to be installed is determined by the
|
||||
.Va KERNEL
|
||||
variable.
|
||||
.Pp
|
||||
The presence of any configuration sets (such as
|
||||
.Sq etc
|
||||
or
|
||||
.Sq xetc )
|
||||
in this list enables the etcupdate and postinstall steps in the automated
|
||||
upgrade procedure.
|
||||
.Pp
|
||||
The presence of a modules set enables the modules step in the automated upgrade
|
||||
procedure.
|
||||
.Pp
|
||||
Default: AUTO.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr sysupgrade 8
|
||||
@@ -1,505 +0,0 @@
|
||||
# Copyright 2012 Google Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# \file sysupgrade.sh
|
||||
# Entry point and main program logic.
|
||||
|
||||
shtk_import cli
|
||||
shtk_import config
|
||||
shtk_import list
|
||||
shtk_import process
|
||||
|
||||
|
||||
# List of valid configuration variables.
|
||||
#
|
||||
# Please remember to update sysbuild(1) if you change this list.
|
||||
SYSUPGRADE_CONFIG_VARS="AUTOCLEAN CACHEDIR DESTDIR ETCUPDATE KERNEL
|
||||
POSTINSTALL_AUTOFIX RELEASEDIR SETS"
|
||||
|
||||
|
||||
# Directory in which to keep downloaded release files.
|
||||
#
|
||||
# Can be overriden for test purposes only.
|
||||
: ${SYSUPGRADE_CACHEDIR:="@SYSUPGRADE_CACHEDIR@"}
|
||||
|
||||
|
||||
# Paths to installed files.
|
||||
#
|
||||
# Can be overriden for test purposes only.
|
||||
: ${SYSUPGRADE_ETCDIR:="@SYSUPGRADE_ETCDIR@"}
|
||||
|
||||
|
||||
# Sets defaults for configuration variables that need a value.
|
||||
#
|
||||
# This function should be called before the configuration file has been loaded.
|
||||
# This means that the user can undefine a required configuration variable, but
|
||||
# we let him shoot himself in the foot if he so desires.
|
||||
sysupgrade_set_defaults() {
|
||||
# Please remember to update sysupgrade(8) if you change any default values.
|
||||
shtk_config_set AUTOCLEAN "yes"
|
||||
shtk_config_set CACHEDIR "${SYSUPGRADE_CACHEDIR}"
|
||||
shtk_config_set ETCUPDATE "yes"
|
||||
shtk_config_set KERNEL "AUTO"
|
||||
shtk_config_set SETS "AUTO"
|
||||
}
|
||||
|
||||
|
||||
# Interprets magic configuration values.
|
||||
#
|
||||
# This function should be called after the configuration file has been loaded.
|
||||
# It takes care of performing any required post-processing on the configuration
|
||||
# variables, such as expanding the magic AUTO keyword to the actual value.
|
||||
sysupgrade_auto_config() {
|
||||
if [ "$(shtk_config_get_default KERNEL "")" = "AUTO" ]; then
|
||||
local kernel="$(shtk_config_get_default DESTDIR "")/netbsd"
|
||||
if [ -e "${kernel}" ]; then
|
||||
local kernel_path="$(config -x "${kernel}" | head -n 1 \
|
||||
| cut -d \" -f 2)"
|
||||
local kernel_name="${kernel_path##*/}"
|
||||
[ -n "${kernel_name}" ] || shtk_cli_error "Failed to determine" \
|
||||
"kernel name; please set KERNEL explicitly"
|
||||
shtk_config_set KERNEL "${kernel_name}"
|
||||
else
|
||||
shtk_config_unset KERNEL
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$(shtk_config_get_default SETS "")" = "AUTO" ]; then
|
||||
local mtree="$(shtk_config_get_default DESTDIR "")/etc/mtree/"
|
||||
if [ -d "${mtree}" ]; then
|
||||
local all_sets="$(cd "${mtree}" && echo set.* \
|
||||
| sed -e 's,set\.,,g')"
|
||||
shtk_config_set SETS "${all_sets}"
|
||||
else
|
||||
shtk_config_unset SETS
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Dumps the loaded configuration.
|
||||
#
|
||||
# \params ... The options and arguments to the command.
|
||||
sysupgrade_config() {
|
||||
local eval_auto=no
|
||||
while getopts ':a' arg "${@}"; do
|
||||
case "${arg}" in
|
||||
a) # Evaluate automatic settings.
|
||||
eval_auto=yes
|
||||
;;
|
||||
|
||||
\?)
|
||||
shtk_cli_usage_error "Unknown option -${OPTARG}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((${OPTIND} - 1))
|
||||
|
||||
[ ${#} -eq 0 ] || shtk_cli_usage_error "config does not take any arguments"
|
||||
|
||||
[ "${eval_auto}" = no ] || sysupgrade_auto_config
|
||||
|
||||
for var in ${SYSUPGRADE_CONFIG_VARS}; do
|
||||
if shtk_config_has "${var}"; then
|
||||
echo "${var} = $(shtk_config_get "${var}")"
|
||||
else
|
||||
echo "${var} is undefined"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Gets the path to a file in the cache.
|
||||
#
|
||||
# \post The path to the file in the cache is printed on stdout.
|
||||
#
|
||||
# \param file The name of the file to query.
|
||||
get_cached_file() {
|
||||
local file="${1}"; shift
|
||||
|
||||
echo "$(shtk_config_get CACHEDIR)/${file}"
|
||||
}
|
||||
|
||||
|
||||
# Ensures that a given distribution file exists in the cache.
|
||||
#
|
||||
# \param file The name of the file to query.
|
||||
require_cached_file() {
|
||||
local file="${1}"; shift
|
||||
|
||||
local path="$(get_cached_file "${file}")"
|
||||
[ -f "${path}" ] || shtk_cli_error "Cannot find ${file}; did you run" \
|
||||
"'$(shtk_cli_progname) fetch' first?"
|
||||
}
|
||||
|
||||
|
||||
# Extracts a set into the destdir.
|
||||
#
|
||||
# The set to be extracted must have been previously fetched into the cache
|
||||
# directory by sysupgrade_fetch command.
|
||||
#
|
||||
# \param set_name Name of the set to extract, without the .tgz extension.
|
||||
extract_set() {
|
||||
local set_name="${1}"; shift
|
||||
|
||||
require_cached_file "${set_name}.tgz"
|
||||
|
||||
local destdir="$(shtk_config_get_default DESTDIR "")"
|
||||
local set_tgz="$(get_cached_file "${set_name}.tgz")"
|
||||
|
||||
shtk_cli_info "Extracting ${set_name} into ${destdir}/"
|
||||
[ -z "${destdir}" ] || shtk_process_run mkdir -p "${destdir}"
|
||||
progress -zf "${set_tgz}" tar -xp -C "${destdir}/" -f -
|
||||
}
|
||||
|
||||
|
||||
# Fetches the release sets into the cache directory.
|
||||
#
|
||||
# \param releasedir Optional override of the release directory to use.
|
||||
sysupgrade_fetch() {
|
||||
[ ${#} -lt 2 ] \
|
||||
|| shtk_cli_usage_error "fetch takes zero or one arguments"
|
||||
|
||||
[ -z "${1}" ] || shtk_config_set "RELEASEDIR" "${1}"
|
||||
|
||||
local releasedir="$(shtk_config_get RELEASEDIR)"
|
||||
local cachedir="$(shtk_config_get CACHEDIR)"
|
||||
local fetch_files=
|
||||
for set_name in $(shtk_config_get SETS); do
|
||||
fetch_files="${fetch_files} binary/sets/${set_name}.tgz"
|
||||
done
|
||||
if shtk_config_has KERNEL; then
|
||||
local kernel_name="$(shtk_config_get KERNEL)"
|
||||
fetch_files="${fetch_files} binary/kernel/netbsd-${kernel_name}.gz"
|
||||
fi
|
||||
|
||||
case "${releasedir}" in
|
||||
ftp://*|http://*)
|
||||
mkdir -p "${cachedir}"
|
||||
|
||||
for relative_file in ${fetch_files}; do
|
||||
local local_file="${cachedir}/${relative_file##*/}"
|
||||
if [ -f "${local_file}" ]; then
|
||||
shtk_cli_warning "Reusing existing ${local_file}"
|
||||
else
|
||||
local url="${releasedir}/${relative_file}"
|
||||
shtk_cli_info "Downloading ${url} into ${cachedir}"
|
||||
rm -f "${local_file}"
|
||||
local rflag=
|
||||
[ ! -f "${local_file}.tmp" ] || rflag=-R
|
||||
ftp ${rflag} -o"${local_file}.tmp" "${url}" \
|
||||
|| shtk_cli_error "Failed to fetch ${url}"
|
||||
mv "${local_file}.tmp" "${local_file}"
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
ssh://*)
|
||||
mkdir -p "${cachedir}"
|
||||
|
||||
local relative_srcs=""
|
||||
for relative_file in ${fetch_files}; do
|
||||
local local_file="${cachedir}/${relative_file##*/}"
|
||||
if [ -f "${local_file}" ]; then
|
||||
shtk_cli_warning "Reusing existing ${local_file}"
|
||||
else
|
||||
if [ -z "${relative_srcs}" ]; then
|
||||
relative_srcs="${relative_file}"
|
||||
else
|
||||
relative_srcs="${relative_srcs},${relative_file}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ -n "${relative_srcs}" ]; then
|
||||
local host="$(echo ${releasedir} | cut -d / -f 3)"
|
||||
local dir="$(echo ${releasedir} | cut -d / -f 4-)"
|
||||
scp "${host}:/${dir}/{${relative_srcs}}" "${cachedir}/"
|
||||
fi
|
||||
;;
|
||||
|
||||
/*)
|
||||
mkdir -p "${cachedir}"
|
||||
|
||||
for relative_file in ${fetch_files}; do
|
||||
local src="${releasedir}/${relative_file}"
|
||||
shtk_cli_info "Linking local ${src} into ${cachedir}"
|
||||
[ -f "${src}" ] || shtk_cli_error "Cannot open ${src}"
|
||||
ln -s -f "${src}" "${cachedir}/${relative_file##*/}" \
|
||||
|| shtk_cli_error "Failed to link ${src} into ${cachedir}"
|
||||
done
|
||||
;;
|
||||
|
||||
*)
|
||||
shtk_cli_error "Don't know how to fetch from ${releasedir}; must" \
|
||||
"be an absolute path or an FTP/HTTP site"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
# Installs a new kernel from a set.
|
||||
#
|
||||
# \param kernel_name Name of the kernel set to use; optional.
|
||||
sysupgrade_kernel() {
|
||||
[ ${#} -lt 2 ] \
|
||||
|| shtk_cli_usage_error "kernel takes zero or one arguments"
|
||||
|
||||
local kernel_name
|
||||
if [ -n "${1}" ]; then
|
||||
kernel_name="${1}"
|
||||
elif shtk_config_has KERNEL; then
|
||||
kernel_name="$(shtk_config_get KERNEL)"
|
||||
else
|
||||
shtk_cli_info "Skipping kernel installation (KERNEL not set)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
require_cached_file "netbsd-${kernel_name}.gz"
|
||||
|
||||
local destdir="$(shtk_config_get_default DESTDIR "")"
|
||||
shtk_cli_info "Upgrading kernel using ${kernel_name} in ${destdir}/"
|
||||
|
||||
if gunzip -c "$(get_cached_file "netbsd-${kernel_name}.gz")" \
|
||||
>"${destdir}/nnetbsd"
|
||||
then
|
||||
if [ -f "${destdir}/netbsd" ]; then
|
||||
shtk_cli_info "Backing up 'netbsd' kernel as 'onetbsd'"
|
||||
ln -f "${destdir}/netbsd" "${destdir}/onetbsd"
|
||||
fi
|
||||
|
||||
mv "${destdir}/nnetbsd" "${destdir}/netbsd"
|
||||
else
|
||||
rm -f "${destdir}/nnetbsd"
|
||||
shtk_cli_error "Failed to uncompress new kernel"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Installs new kernel modules.
|
||||
sysupgrade_modules() {
|
||||
[ ${#} -eq 0 ] \
|
||||
|| shtk_cli_usage_error "modules does not take any arguments"
|
||||
|
||||
if ! shtk_list_contains modules $(shtk_config_get SETS); then
|
||||
shtk_cli_info "Skipping modules installation (modules not in SETS)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
shtk_cli_info "Upgrading kernel modules"
|
||||
|
||||
extract_set modules
|
||||
}
|
||||
|
||||
|
||||
# Installs new sets.
|
||||
#
|
||||
# \param ... Names of the sets to extract, to override SETS.
|
||||
sysupgrade_sets() {
|
||||
local sets=
|
||||
for set_name in "${@:-$(shtk_config_get SETS)}"; do
|
||||
case "${set_name}" in
|
||||
*etc) ;; # Handled by etcupdate.
|
||||
kern-*)
|
||||
shtk_cli_error "SETS should not contain any kernel sets;" \
|
||||
"found ${set_name}"
|
||||
;;
|
||||
modules) ;; # Handled by modules.
|
||||
*) sets="${sets} ${set_name}" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
for set_name in ${sets}; do
|
||||
require_cached_file "${set_name}.tgz"
|
||||
done
|
||||
|
||||
shtk_cli_info "Upgrading base system"
|
||||
for set_name in ${sets}; do
|
||||
extract_set "${set_name}"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Runs etcupdate to install new configuration files.
|
||||
sysupgrade_etcupdate() {
|
||||
[ ${#} -eq 0 ] || shtk_cli_usage_error "etcupdate does not take any" \
|
||||
"arguments"
|
||||
|
||||
if shtk_config_has DESTDIR; then
|
||||
shtk_cli_info "Skipping etcupdate (DESTDIR upgrades not supported)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
local sets="$(shtk_list_filter '*etc' $(shtk_config_get SETS))"
|
||||
if [ -z "${sets}" ]; then
|
||||
shtk_cli_info "Skipping etcupdate (no etc sets in SETS)"
|
||||
return 0
|
||||
fi
|
||||
if ! shtk_list_contains etc ${sets}; then
|
||||
shtk_cli_info "Skipping etcupdate (required etc not in SETS)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
local sflags=
|
||||
for set_name in ${sets}; do
|
||||
require_cached_file "${set_name}.tgz"
|
||||
sflags="${sflags} -s$(get_cached_file "${set_name}.tgz")"
|
||||
done
|
||||
|
||||
shtk_cli_info "Upgrading /etc interactively"
|
||||
etcupdate -a -l ${sflags}
|
||||
}
|
||||
|
||||
|
||||
# Runs postinstall to validate the updated system.
|
||||
#
|
||||
# \param ... Arguments to pass to postinstall(8).
|
||||
sysupgrade_postinstall() {
|
||||
local sets=
|
||||
local sets="$(shtk_list_filter '*etc' $(shtk_config_get SETS))"
|
||||
if [ -z "${sets}" ]; then
|
||||
shtk_cli_info "Skipping postinstall (no etc sets in SETS)"
|
||||
return 0
|
||||
fi
|
||||
if ! shtk_list_contains etc ${sets}; then
|
||||
shtk_cli_info "Skipping postinstall (required etc not in SETS)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
local sflags=
|
||||
for set_name in ${sets}; do
|
||||
require_cached_file "${set_name}.tgz"
|
||||
sflags="${sflags} -s$(get_cached_file "${set_name}.tgz")"
|
||||
done
|
||||
|
||||
shtk_cli_info "Performing postinstall checks"
|
||||
local destdir="$(shtk_config_get_default DESTDIR "")"
|
||||
if shtk_config_has POSTINSTALL_AUTOFIX; then
|
||||
postinstall "-d${destdir}/" ${sflags} fix \
|
||||
$(shtk_config_get POSTINSTALL_AUTOFIX)
|
||||
fi
|
||||
postinstall "-d${destdir}/" ${sflags} "${@:-check}" \
|
||||
|| shtk_cli_error "Some postinstall(8) checks have failed"
|
||||
}
|
||||
|
||||
|
||||
# Cleans up the cache directory.
|
||||
sysupgrade_clean() {
|
||||
[ ${#} -eq 0 ] || shtk_cli_usage_error "clean does not take any arguments"
|
||||
|
||||
shtk_cli_info "Cleaning downloaded files"
|
||||
rm -f "$(shtk_config_get CACHEDIR)"/*.*gz*
|
||||
}
|
||||
|
||||
|
||||
# Automated upgrade procedure.
|
||||
#
|
||||
# This is just a convenience mechanism to execute all the different steps of the
|
||||
# upgrade.
|
||||
#
|
||||
# \param releasedir Optional override of the release directory to use.
|
||||
sysupgrade_auto() {
|
||||
[ ${#} -lt 2 ] \
|
||||
|| shtk_cli_usage_error "auto takes zero or one arguments"
|
||||
|
||||
[ -z "${1}" ] || shtk_config_set "RELEASEDIR" "${1}"
|
||||
|
||||
local stages=
|
||||
stages="fetch modules kernel sets"
|
||||
shtk_config_get_bool "ETCUPDATE" && stages="${stages} etcupdate"
|
||||
stages="${stages} postinstall"
|
||||
shtk_config_get_bool "AUTOCLEAN" && stages="${stages} clean"
|
||||
|
||||
shtk_cli_info "Starting auto-update with stages: ${stages}"
|
||||
for stage in ${stages}; do
|
||||
sysupgrade_${stage}
|
||||
done
|
||||
|
||||
shtk_config_get_bool "AUTOCLEAN" || shtk_cli_info "Distribution sets not" \
|
||||
"deleted; further $(shtk_cli_progname) commands will reuse them"
|
||||
}
|
||||
|
||||
|
||||
# Entry point to the program.
|
||||
#
|
||||
# \param ... Command-line arguments to be processed.
|
||||
#
|
||||
# \return An exit code to be returned to the user.
|
||||
sysupgrade_main() {
|
||||
local config_file="${SYSUPGRADE_ETCDIR}/sysupgrade.conf"
|
||||
|
||||
shtk_config_init ${SYSUPGRADE_CONFIG_VARS}
|
||||
|
||||
while getopts ':c:d:o:' arg "${@}"; do
|
||||
case "${arg}" in
|
||||
c) # Path to the configuration file.
|
||||
config_file="${OPTARG}"
|
||||
;;
|
||||
|
||||
d) # Path to the destdir.
|
||||
shtk_config_set DESTDIR "${OPTARG}"
|
||||
;;
|
||||
|
||||
o) # Override for a particular configuration variable.
|
||||
shtk_config_override "${OPTARG}"
|
||||
;;
|
||||
|
||||
\?)
|
||||
shtk_cli_usage_error "Unknown option -${OPTARG}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((${OPTIND} - 1))
|
||||
|
||||
[ ${#} -ge 1 ] || shtk_cli_usage_error "No command specified"
|
||||
|
||||
local exit_code=0
|
||||
|
||||
local command="${1}"; shift
|
||||
case "${command}" in
|
||||
auto|clean|etcupdate|fetch|kernel|modules|sets|postinstall)
|
||||
sysupgrade_set_defaults
|
||||
shtk_config_load "${config_file}"
|
||||
sysupgrade_auto_config
|
||||
"sysupgrade_$(echo "${command}" | tr - _)" "${@}" \
|
||||
|| exit_code="${?}"
|
||||
;;
|
||||
|
||||
config)
|
||||
sysupgrade_set_defaults
|
||||
shtk_config_load "${config_file}"
|
||||
"sysupgrade_$(echo "${command}" | tr - _)" "${@}" \
|
||||
|| exit_code="${?}"
|
||||
;;
|
||||
|
||||
*)
|
||||
shtk_cli_usage_error "Unknown command ${command}"
|
||||
;;
|
||||
esac
|
||||
|
||||
return "${exit_code}"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user