diff options
author | jmmv <jmmv@pkgsrc.org> | 2012-08-25 01:57:27 +0000 |
---|---|---|
committer | jmmv <jmmv@pkgsrc.org> | 2012-08-25 01:57:27 +0000 |
commit | 5a083621481b80112a25b3f50fc8b1d207775bae (patch) | |
tree | c64f5b8ea8d6cb4fc445ee134876dad382d56a4d /sysutils | |
parent | 3d9b555af9c31ac4892ca503e3ae243778477120 (diff) | |
download | pkgsrc-5a083621481b80112a25b3f50fc8b1d207775bae.tar.gz |
Update to 1.2:
- Use netbsd-*.gz files to install the kernel rather than kern-*.tgz sets.
This lets sysupgrade work in conjunction with the "releasekernel" target
of build.sh, as this generates the former instead of the latter.
- Preserve timestamps of the kernel when backing it up as onetbsd.
- Fix some tests to not rely on the current state of the system (the cache
directory and the autodetection of KERNEL).
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/sysupgrade/Makefile | 4 | ||||
-rw-r--r-- | sysutils/sysupgrade/files/sysupgrade.8 | 12 | ||||
-rw-r--r-- | sysutils/sysupgrade/files/sysupgrade.conf.5 | 10 | ||||
-rw-r--r-- | sysutils/sysupgrade/files/sysupgrade.sh | 106 | ||||
-rw-r--r-- | sysutils/sysupgrade/files/sysupgrade_test.sh | 178 |
5 files changed, 197 insertions, 113 deletions
diff --git a/sysutils/sysupgrade/Makefile b/sysutils/sysupgrade/Makefile index 177c4c536e3..49223289a07 100644 --- a/sysutils/sysupgrade/Makefile +++ b/sysutils/sysupgrade/Makefile @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.2 2012/08/15 21:21:15 jmmv Exp $ +# $NetBSD: Makefile,v 1.3 2012/08/25 01:57:27 jmmv Exp $ -DISTNAME= sysupgrade-1.1 +DISTNAME= sysupgrade-1.2 CATEGORIES= sysutils MASTER_SITES= # empty DISTFILES= # empty diff --git a/sysutils/sysupgrade/files/sysupgrade.8 b/sysutils/sysupgrade/files/sysupgrade.8 index e90ea72ff4b..8077fe0a4a0 100644 --- a/sysutils/sysupgrade/files/sysupgrade.8 +++ b/sysutils/sysupgrade/files/sysupgrade.8 @@ -25,7 +25,7 @@ .\" 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 August 6, 2012 +.Dd August 24, 2012 .Dt SYSUPGRADE 8 .Os .Sh NAME @@ -266,8 +266,8 @@ if present, or otherwise from the .Va KERNEL variable. The kernel is expected to be found in a -.Sq kern-<NAME> -distribution set in the release directory. +.Sq netbsd-<NAME>.gz +file in the release directory. .Pp The previous kernel is backed up as .Pa <destdir>/onetbsd. @@ -286,10 +286,12 @@ In other words, this command installs sets like or .Sq tests but explicitly skips sets of the forms -.Sq *etc , -.Sq kern-* +.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 diff --git a/sysutils/sysupgrade/files/sysupgrade.conf.5 b/sysutils/sysupgrade/files/sysupgrade.conf.5 index 1df328fc95d..4cc03bdeb7a 100644 --- a/sysutils/sysupgrade/files/sysupgrade.conf.5 +++ b/sysutils/sysupgrade/files/sysupgrade.conf.5 @@ -25,7 +25,7 @@ .\" 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 August 6, 2012 +.Dd August 24, 2012 .Dt SYSUPGRADE.CONF 5 .Os .Sh NAME @@ -97,8 +97,8 @@ Default: yes. .It Va KERNEL Name of the kernel to install. There must be a -.Sq kern-<KERNEL> -distribution set in the release directory matching this name. +.Sq netbsd-<KERNEL>.gz +file in the release directory matching this name. .Pp If this is set to the magic value .Sq AUTO , @@ -138,9 +138,9 @@ If this is set to the magic value the list of sets is determined from the files in .Pa <DESTDIR>/etc/mtree . .Pp -This list should not include any +This list cannot include any .Sq kern-* -sets as this is automatically handled by the +sets; the kernel to be installed is determined by the .Va KERNEL variable. .Pp diff --git a/sysutils/sysupgrade/files/sysupgrade.sh b/sysutils/sysupgrade/files/sysupgrade.sh index 7631391c0cb..27eefe1d3bb 100644 --- a/sysutils/sysupgrade/files/sysupgrade.sh +++ b/sysutils/sysupgrade/files/sysupgrade.sh @@ -78,8 +78,9 @@ 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_name="$(config -x "${kernel}" | head -n 1 \ + 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}" @@ -133,26 +134,26 @@ sysupgrade_config() { } -# Gets the path to a set, and ensures it exists. +# Gets the path to a file in the cache. # -# \post The path to the tgz of the set is printed on stdout. +# \post The path to the file in the cache is printed on stdout. # -# \param set_name The name of the set to query. -get_set() { - local set_name="${1}"; shift +# \param file The name of the file to query. +get_cached_file() { + local file="${1}"; shift - echo "$(shtk_config_get CACHEDIR)/${set_name}.tgz" + echo "$(shtk_config_get CACHEDIR)/${file}" } -# Ensures that a given set exists. +# Ensures that a given distribution file exists in the cache. # -# \param set_name The name of the set to query. -require_set() { - local set_name="${1}"; shift +# \param file The name of the file to query. +require_cached_file() { + local file="${1}"; shift - local set_tgz="$(get_set "${set_name}")" - [ -f "${set_tgz}" ] || shtk_cli_error "Cannot find ${set_name}; did you run" \ + local path="$(get_cached_file "${file}")" + [ -f "${path}" ] || shtk_cli_error "Cannot find ${file}; did you run" \ "'$(shtk_cli_progname) fetch' first?" } @@ -166,10 +167,10 @@ require_set() { extract_set() { local set_name="${1}"; shift - require_set "${set_name}" + require_cached_file "${set_name}.tgz" local destdir="$(shtk_config_get_default DESTDIR "")" - local set_tgz="$(get_set "${set_name}")" + 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}" @@ -188,26 +189,30 @@ sysupgrade_fetch() { local releasedir="$(shtk_config_get RELEASEDIR)" local cachedir="$(shtk_config_get CACHEDIR)" - local fetch_sets="$(shtk_config_get SETS)" + 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 - fetch_sets="${fetch_sets} kern-$(shtk_config_get KERNEL)" + 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 set_name in ${fetch_sets}; do - local file="${cachedir}/${set_name}.tgz" - if [ -f "${file}" ]; then - shtk_cli_warning "Reusing existing ${file}" + 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}/binary/sets/${set_name}.tgz" + local url="${releasedir}/${relative_file}" shtk_cli_info "Downloading ${url} into ${cachedir}" - rm -f "${file}" - ftp -R -o"${file}.tmp" "${url}" \ + rm -f "${local_file}" + ftp -R -o"${local_file}.tmp" "${url}" \ || shtk_cli_error "Failed to fetch ${url}" - mv "${file}.tmp" "${file}" + mv "${local_file}.tmp" "${local_file}" fi done ;; @@ -215,11 +220,11 @@ sysupgrade_fetch() { /*) mkdir -p "${cachedir}" - for set_name in ${fetch_sets}; do - local src="${releasedir}/binary/sets/${set_name}.tgz" + 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}/${set_name}.tgz" \ + ln -s -f "${src}" "${cachedir}/${relative_file##*/}" \ || shtk_cli_error "Failed to link ${src} into ${cachedir}" done ;; @@ -249,16 +254,24 @@ sysupgrade_kernel() { return 0 fi - require_set "kern-${kernel_name}" + 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 [ -f "${destdir}/netbsd" ]; then - shtk_cli_info "Backing up 'netbsd' kernel as 'onetbsd'" - cp "${destdir}/netbsd" "${destdir}/onetbsd" + 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 - extract_set "kern-${kernel_name}" } @@ -282,22 +295,24 @@ sysupgrade_modules() { # # \param ... Names of the sets to extract, to override SETS. sysupgrade_sets() { - shtk_cli_info "Upgrading base system" - local sets= for set_name in "${@:-$(shtk_config_get SETS)}"; do case "${set_name}" in *etc) ;; # Handled by etcupdate. - kern-*) ;; # Handled by kernel. + 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_set "${set_name}" + require_cached_file "${set_name}.tgz" done + shtk_cli_info "Upgrading base system" for set_name in ${sets}; do extract_set "${set_name}" done @@ -306,7 +321,8 @@ sysupgrade_sets() { # Runs etcupdate to install new configuration files. sysupgrade_etcupdate() { - [ ${#} -eq 0 ] || shtk_cli_usage_error "etcupdate does not take any arguments" + [ ${#} -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)" @@ -325,8 +341,8 @@ sysupgrade_etcupdate() { local sflags= for set_name in ${sets}; do - require_set "${set_name}" - sflags="${sflags} -s$(get_set "${set_name}")" + require_cached_file "${set_name}.tgz" + sflags="${sflags} -s$(get_cached_file "${set_name}.tgz")" done shtk_cli_info "Upgrading /etc interactively" @@ -351,8 +367,8 @@ sysupgrade_postinstall() { local sflags= for set_name in ${sets}; do - require_set "${set_name}" - sflags="${sflags} -s$(get_set "${set_name}")" + require_cached_file "${set_name}.tgz" + sflags="${sflags} -s$(get_cached_file "${set_name}.tgz")" done shtk_cli_info "Performing postinstall checks" @@ -371,7 +387,7 @@ 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)"/*.tgz* + rm -f "$(shtk_config_get CACHEDIR)"/*.*gz* } @@ -398,8 +414,8 @@ sysupgrade_auto() { sysupgrade_${stage} done - shtk_config_get_bool "AUTOCLEAN" || shtk_cli_info "Distribution sets not deleted;" \ - "further $(shtk_cli_progname) commands will reuse them" + shtk_config_get_bool "AUTOCLEAN" || shtk_cli_info "Distribution sets not" \ + "deleted; further $(shtk_cli_progname) commands will reuse them" } diff --git a/sysutils/sysupgrade/files/sysupgrade_test.sh b/sysutils/sysupgrade/files/sysupgrade_test.sh index af13dfdf154..df6f263d508 100644 --- a/sysutils/sysupgrade/files/sysupgrade_test.sh +++ b/sysutils/sysupgrade/files/sysupgrade_test.sh @@ -63,34 +63,37 @@ EOF } -# Generates a NetBSD release dir with fake tarballs. +# Generates a NetBSD release dir with fake sets and kernels. # -# Each of the generated sets contains a single file named '<set>.cookie'. -# Additionally, if the set starts with kern-, a 'netbsd' file will also be -# inside it. +# Each generated set contains a single file named '<set>.cookie'. The kernels +# contain just an hardcoded string within them that can later be validated to +# ensure the right set was unpacked. # # \param releasedir Path to the release directory. -# \param ... Names of the sets to create under releasedir/binary/sets/. +# \param ... Names of the sets to create under releasedir/binary/sets/ and the +# kernels to create under releasedir/binary/kernel/. No extensions should +# be given. create_mock_release() { local releasedir="${1}"; shift + mkdir -p "${releasedir}/binary/kernel" mkdir -p "${releasedir}/binary/sets" for set_name in "${@}"; do - local files= - - echo "File from ${set_name}" >"${set_name}.cookie" - files="${files} ${set_name}.cookie" - case "${set_name}" in - kern-*) - echo "File from ${set_name}" >netbsd - files="${files} netbsd" + netbsd-*) + echo "File from ${set_name}" \ + >"${releasedir}/binary/kernel/${set_name}" + gzip "${releasedir}/binary/kernel/${set_name}" ;; - esac - tar czf "${releasedir}/binary/sets/${set_name}.tgz" ${files} - rm ${files} + *) + echo "File from ${set_name}" >"${set_name}.cookie" + tar czf "${releasedir}/binary/sets/${set_name}.tgz" \ + "${set_name}.cookie" + rm "${set_name}.cookie" + ;; + esac done } @@ -153,9 +156,9 @@ EOF mkdir root cat >root/netbsd <<EOF -### START CONFIG FILE "ABCDE" +### START CONFIG FILE "foo/bar/ABCDE" these are some contents -### END CONFIG FILE "ABCDE" +### END CONFIG FILE "foo/bar/ABCDE" EOF atf_check -o match:"KERNEL = ABCDE" \ sysupgrade -c /dev/null \ @@ -277,7 +280,7 @@ EOF SYSUPGRADE_CACHEDIR="$(pwd)/a/b/c"; export SYSUPGRADE_CACHEDIR atf_check -o ignore -e ignore sysupgrade -c /dev/null \ -o RELEASEDIR="ftp://example.net/pub/NetBSD/X.Y/a-machine" \ - -o SETS="a foo" fetch + -o KERNEL=GENERIC -o SETS="a foo" fetch cat >expout <<EOF Command: ftp @@ -295,8 +298,8 @@ Arg: ftp://example.net/pub/NetBSD/X.Y/a-machine/binary/sets/foo.tgz Command: ftp Directory: $(pwd) Arg: -R -Arg: -o$(pwd)/a/b/c/kern-GENERIC.tgz.tmp -Arg: ftp://example.net/pub/NetBSD/X.Y/a-machine/binary/sets/kern-GENERIC.tgz +Arg: -o$(pwd)/a/b/c/netbsd-GENERIC.gz.tmp +Arg: ftp://example.net/pub/NetBSD/X.Y/a-machine/binary/kernel/netbsd-GENERIC.gz EOF atf_check -o file:expout cat commands.log @@ -308,7 +311,7 @@ fetch__http_head() { atf_set "require.progs" "/usr/libexec/httpd" } fetch__http_body() { - create_mock_release www/a-machine base comp etc kern-GENERIC tests text + create_mock_release www/a-machine base comp etc netbsd-GENERIC tests text /usr/libexec/httpd -b -s -d -I 30401 -P "$(pwd)/httpd.pid" "$(pwd)/www" \ || atf_fail "Failed to start test HTTP server" @@ -316,13 +319,13 @@ fetch__http_body() { SYSUPGRADE_CACHEDIR="$(pwd)/cache"; export SYSUPGRADE_CACHEDIR atf_check -o ignore -e ignore sysupgrade -c /dev/null \ -o RELEASEDIR="http://localhost:30401/a-machine" \ - -o SETS="base etc text" fetch + -o KERNEL=GENERIC -o SETS="base etc text" fetch - for set_name in base etc kern-GENERIC text; do - [ -e "cache/${set_name}.tgz" ] || atf_fail "${set_name} not fetched" + for set_name in base.tgz etc.tgz netbsd-GENERIC.gz text.tgz; do + [ -e "cache/${set_name}" ] || atf_fail "${set_name} not fetched" done - for set_name in comp tests; do - [ ! -e "cache/${set_name}.tgz" ] || atf_fail "${set_name} fetched" + for set_name in comp.tgz tests.tgz; do + [ ! -e "cache/${set_name}" ] || atf_fail "${set_name} fetched" done kill -9 "$(cat httpd.pid)" @@ -338,24 +341,25 @@ fetch__http_cleanup() { atf_test_case fetch__local fetch__local_body() { - create_mock_release release base comp etc kern-GENERIC tests text + create_mock_release release base comp etc netbsd-GENERIC tests text SYSUPGRADE_CACHEDIR="$(pwd)/cache"; export SYSUPGRADE_CACHEDIR atf_check -o ignore -e ignore sysupgrade -c /dev/null \ - -o RELEASEDIR="$(pwd)/release" -o SETS="base etc text" fetch + -o KERNEL=GENERIC -o RELEASEDIR="$(pwd)/release" \ + -o SETS="base etc text" fetch - for set_name in base etc kern-GENERIC text; do - [ -e "cache/${set_name}.tgz" ] || atf_fail "${set_name} not fetched" + for set_name in base.tgz etc.tgz netbsd-GENERIC.gz text.tgz; do + [ -e "cache/${set_name}" ] || atf_fail "${set_name} not fetched" done - for set_name in comp tests; do - [ ! -e "cache/${set_name}.tgz" ] || atf_fail "${set_name} fetched" + for set_name in comp.tgz tests.tgz; do + [ ! -e "cache/${set_name}" ] || atf_fail "${set_name} fetched" done } atf_test_case fetch__no_kernel fetch__no_kernel_body() { - create_mock_release release base comp kern-GENERIC + create_mock_release release base comp netbsd-GENERIC SYSUPGRADE_CACHEDIR="$(pwd)/cache"; export SYSUPGRADE_CACHEDIR atf_check -o ignore -e ignore sysupgrade -c /dev/null \ @@ -364,7 +368,7 @@ fetch__no_kernel_body() { for set_name in base comp; do [ -e "cache/${set_name}.tgz" ] || atf_fail "${set_name} not fetched" done - [ ! -e "cache/kern-GENERIC.tgz" ] || atf_fail "kern-GENERIC fetched" + [ ! -e "cache/netbsd-GENERIC.gz" ] || atf_fail "netbsd-GENERIC fetched" } @@ -418,8 +422,9 @@ kernel__from_config_body() { mkdir root echo "my old kernel" >root/netbsd - create_mock_release release kern-FOOBAR - SYSUPGRADE_CACHEDIR="$(pwd)/release/binary/sets"; export SYSUPGRADE_CACHEDIR + create_mock_release release netbsd-FOOBAR + SYSUPGRADE_CACHEDIR="$(pwd)/release/binary/kernel" + export SYSUPGRADE_CACHEDIR atf_check -s exit:0 \ -e match:"Upgrading kernel using FOOBAR in $(pwd)/root/" \ @@ -427,7 +432,7 @@ kernel__from_config_body() { sysupgrade -c /dev/null \ -o DESTDIR="$(pwd)/root" -o KERNEL=FOOBAR kernel - atf_check -o match:"File from kern-FOOBAR" cat root/netbsd + atf_check -o match:"File from netbsd-FOOBAR" cat root/netbsd atf_check -o match:"my old kernel" cat root/onetbsd } @@ -437,8 +442,9 @@ kernel__from_arg_body() { mkdir root echo "my old kernel" >root/netbsd - create_mock_release release kern-FOOBAR kern-OTHER - SYSUPGRADE_CACHEDIR="$(pwd)/release/binary/sets"; export SYSUPGRADE_CACHEDIR + create_mock_release release netbsd-FOOBAR netbsd-OTHER + SYSUPGRADE_CACHEDIR="$(pwd)/release/binary/kernel" + export SYSUPGRADE_CACHEDIR atf_check -s exit:0 \ -e match:"Upgrading kernel using OTHER in $(pwd)/root/" \ @@ -446,7 +452,28 @@ kernel__from_arg_body() { sysupgrade -c /dev/null \ -o DESTDIR="$(pwd)/root" -o KERNEL=FOOBAR kernel OTHER - atf_check -o match:"File from kern-OTHER" cat root/netbsd + atf_check -o match:"File from netbsd-OTHER" cat root/netbsd + atf_check -o match:"my old kernel" cat root/onetbsd +} + + +atf_test_case kernel__override_backup +kernel__override_backup_body() { + mkdir root + echo "my old kernel" >root/netbsd + echo "my older kernel" >root/onetbsd + + create_mock_release release netbsd-FOOBAR + SYSUPGRADE_CACHEDIR="$(pwd)/release/binary/kernel" + export SYSUPGRADE_CACHEDIR + + atf_check -s exit:0 \ + -e match:"Upgrading kernel using FOOBAR in $(pwd)/root/" \ + -e match:"Backing up" \ + sysupgrade -c /dev/null \ + -o DESTDIR="$(pwd)/root" -o KERNEL=FOOBAR kernel + + atf_check -o match:"File from netbsd-FOOBAR" cat root/netbsd atf_check -o match:"my old kernel" cat root/onetbsd } @@ -455,14 +482,15 @@ atf_test_case kernel__no_backup kernel__no_backup_body() { mkdir root - create_mock_release release kern-FOOBAR - SYSUPGRADE_CACHEDIR="$(pwd)/release/binary/sets"; export SYSUPGRADE_CACHEDIR + create_mock_release release netbsd-FOOBAR + SYSUPGRADE_CACHEDIR="$(pwd)/release/binary/kernel" + export SYSUPGRADE_CACHEDIR atf_check -s exit:0 -e not-match:"Backing up" sysupgrade -c /dev/null \ -o DESTDIR="$(pwd)/root" -o KERNEL=FOOBAR kernel - atf_check -o match:"File from kern-FOOBAR" cat root/netbsd - [ ! -f root/onetbsd ] || "onetbsd backup created, but not expected" + atf_check -o match:"File from netbsd-FOOBAR" cat root/netbsd + [ ! -f root/onetbsd ] || atf_fail "onetbsd backup created, but not expected" } @@ -474,7 +502,7 @@ kernel__missing_set_body() { SYSUPGRADE_CACHEDIR="$(pwd)"; export SYSUPGRADE_CACHEDIR cat >experr <<EOF -sysupgrade: E: Cannot find kern-GENERIC; did you run 'sysupgrade fetch' first? +sysupgrade: E: Cannot find netbsd-GENERIC.gz; did you run 'sysupgrade fetch' first? EOF atf_check -s exit:1 -e file:experr sysupgrade -c /dev/null \ -o DESTDIR="$(pwd)/root" -o KERNEL=GENERIC kernel @@ -483,6 +511,25 @@ EOF } +atf_test_case kernel__bad_file +kernel__bad_file_body() { + mkdir root + echo "my old kernel" >root/netbsd + + echo "invalid gzip file" >netbsd-FOOBAR.gz + SYSUPGRADE_CACHEDIR="$(pwd)"; export SYSUPGRADE_CACHEDIR + + atf_check -s exit:1 \ + -e match:"Upgrading kernel using FOOBAR in $(pwd)/root/" \ + -e match:"Failed to uncompress new kernel" \ + sysupgrade -c /dev/null \ + -o DESTDIR="$(pwd)/root" -o KERNEL=FOOBAR kernel + + atf_check -o match:"my old kernel" cat root/netbsd + [ ! -f root/onetbsd ] || atf_fail "onetbsd backup created, but not expected" +} + + atf_test_case kernel__too_many_args kernel__too_many_args_body() { cat >experr <<EOF @@ -533,7 +580,7 @@ sets__from_config_body() { SYSUPGRADE_CACHEDIR="$(pwd)/release/binary/sets"; export SYSUPGRADE_CACHEDIR expected_sets="base comp" - unexpected_sets="etc kern-GENERIC modules xetc" + unexpected_sets="etc modules xetc" atf_check -s exit:0 -e ignore sysupgrade -c /dev/null \ -o DESTDIR="$(pwd)/root" \ @@ -558,7 +605,7 @@ sets__from_args_body() { SYSUPGRADE_CACHEDIR="$(pwd)/release/binary/sets"; export SYSUPGRADE_CACHEDIR expected_sets="base comp" - unexpected_sets="etc kern-GENERIC modules xetc" + unexpected_sets="etc modules xetc" atf_check -s exit:0 -e ignore sysupgrade -c /dev/null \ -o DESTDIR="$(pwd)/root" -o SETS="foo bar baz" \ @@ -576,6 +623,16 @@ sets__from_args_body() { } +atf_test_case sets__invalid_kern +sets__invalid_kern_body() { + cat >experr <<EOF +sysupgrade: E: SETS should not contain any kernel sets; found kern-FOO +EOF + atf_check -s exit:1 -e file:experr sysupgrade -c /dev/null \ + -o DESTDIR="$(pwd)/root" -o SETS="foo kern-FOO baz" sets +} + + atf_test_case etcupdate__skip__none etcupdate__skip__none_body() { cat >experr <<EOF @@ -633,8 +690,10 @@ EOF atf_test_case etcupdate__missing_etc etcupdate__missing_etc_body() { + SYSUPGRADE_CACHEDIR="$(pwd)"; export SYSUPGRADE_CACHEDIR + cat >experr <<EOF -sysupgrade: E: Cannot find etc; did you run 'sysupgrade fetch' first? +sysupgrade: E: Cannot find etc.tgz; did you run 'sysupgrade fetch' first? EOF atf_check -s exit:1 -e file:experr sysupgrade -c /dev/null \ -o RELEASEDIR="$(pwd)/missing" -o SETS="etc" etcupdate @@ -756,8 +815,10 @@ EOF atf_test_case postinstall__missing_etc postinstall__missing_etc_body() { + SYSUPGRADE_CACHEDIR="$(pwd)"; export SYSUPGRADE_CACHEDIR + cat >experr <<EOF -sysupgrade: E: Cannot find etc; did you run 'sysupgrade fetch' first? +sysupgrade: E: Cannot find etc.tgz; did you run 'sysupgrade fetch' first? EOF atf_check -s exit:1 -e file:experr sysupgrade -c /dev/null \ -o RELEASEDIR="$(pwd)/missing" -o SETS="etc" postinstall @@ -799,17 +860,19 @@ clean__nothing_body() { } -atf_test_case clean__only_tgzs -clean__only_tgzs_body() { +atf_test_case clean__only_zipped +clean__only_zipped_body() { SYSUPGRADE_CACHEDIR="$(pwd)/cache"; export SYSUPGRADE_CACHEDIR mkdir "${SYSUPGRADE_CACHEDIR}" touch cache/foo.tgz touch cache/foo.tgz.tmp touch cache/bar.gz + touch cache/bar.gz.tmp atf_check -e match:"Cleaning downloaded files" sysupgrade -c /dev/null clean [ ! -f cache/foo.tgz ] || atf_fail "tgz not deleted" [ ! -f cache/foo.tgz.tmp ] || atf_fail "Temporary tgz not deleted" - [ -f cache/bar.gz ] || atf_fail "Non-tgz files deleted" + [ ! -f cache/bar.gz ] || atf_fail "gz not deleted" + [ ! -f cache/bar.gz.tmp ] || atf_fail "Temporary gz not deleted" [ -d cache ] || atf_fail "Cache directory should not have been deleted" } @@ -830,7 +893,7 @@ auto__simple_body() { create_mock_binary etcupdate PATH="$(pwd):${PATH}" - create_mock_release release base comp etc kern-CUSTOM modules + create_mock_release release base comp etc netbsd-CUSTOM modules mkdir root echo "old kernel" >root/netbsd @@ -855,7 +918,7 @@ EOF atf_check -o inline:"File from base\n" cat root/base.cookie atf_check -o inline:"File from comp\n" cat root/comp.cookie atf_check -o inline:"File from modules\n" cat root/modules.cookie - atf_check -o inline:"File from kern-CUSTOM\n" cat root/netbsd + atf_check -o inline:"File from netbsd-CUSTOM\n" cat root/netbsd atf_check -o inline:"old kernel\n" cat root/onetbsd [ ! -f root/etc.cookie ] || atf_fail "etc extracted by mistake" @@ -1014,8 +1077,10 @@ atf_init_test_cases() { atf_add_test_case kernel__skip atf_add_test_case kernel__from_config atf_add_test_case kernel__from_arg + atf_add_test_case kernel__override_backup atf_add_test_case kernel__no_backup atf_add_test_case kernel__missing_set + atf_add_test_case kernel__bad_file atf_add_test_case kernel__too_many_args atf_add_test_case modules__skip @@ -1024,6 +1089,7 @@ atf_init_test_cases() { atf_add_test_case sets__from_config atf_add_test_case sets__from_args + atf_add_test_case sets__invalid_kern atf_add_test_case etcupdate__skip__none atf_add_test_case etcupdate__skip__no_etc @@ -1041,7 +1107,7 @@ atf_init_test_cases() { atf_add_test_case postinstall__explicit_args atf_add_test_case clean__nothing - atf_add_test_case clean__only_tgzs + atf_add_test_case clean__only_zipped atf_add_test_case clean__too_many_args atf_add_test_case auto__simple |