NetBSD Problem Report #53697

From www@NetBSD.org  Sat Nov  3 14:10:23 2018
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id CC1987A158
	for <gnats-bugs@gnats.NetBSD.org>; Sat,  3 Nov 2018 14:10:23 +0000 (UTC)
Message-Id: <20181103141022.DB29C7A1E9@mollari.NetBSD.org>
Date: Sat,  3 Nov 2018 14:10:22 +0000 (UTC)
From: ci4ic4@gmail.com
Reply-To: ci4ic4@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Introduction of 'tar.xz' extension for system sets requires modification to sysupgrade
X-Send-Pr-Version: www-1.0

>Number:         53697
>Category:       pkg
>Synopsis:       Introduction of 'tar.xz' extension for system sets requires modification to sysupgrade
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    jmmv
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Nov 03 14:15:00 +0000 2018
>Last-Modified:  Sun Nov 04 09:44:44 +0000 2018
>Originator:     Chavdar Ivanov
>Release:        Current pkgsrc as of 2018/11/03
>Organization:
CI4 Consulting Ltd
>Environment:
NetBSD tarkus 8.99.25 NetBSD 8.99.25 (GENERIC) #0: Sat Nov  3 03:33:22 GMT 2018  sysbuild@ymir:/home/sysbuild/sysbuild/amd64/obj/home/sysbuild/src/sys/arch/amd64/compile/GENERIC amd64

>Description:
Until recently the system sets of a NetBSD distribution were in '.tgz' format. This was hardcoded in the sysutils/sysupgrade package. Now NetBSD-current uses '.tar.xz' extension with obviously different compression. The sysupgrade utility fails.i

The attached patch to sysupgrade,sh introduces support for '.tar.xz' while maintaining the ability to use '.tgz' as well. 
>How-To-Repeat:
Try to use sysupgrade with recent -current distribution using '.tar.xz' sets. 
>Fix:
--- sysupgrade.sh.orig	2018-11-03 13:02:13.466845937 +0000
+++ sysupgrade.sh	2018-11-03 13:01:17.707244783 +0000
@@ -39,7 +39,7 @@
 #
 # Please remember to update sysbuild(1) if you change this list.
 SYSUPGRADE_CONFIG_VARS="AUTOCLEAN CACHEDIR DESTDIR ETCUPDATE KERNEL
-                        POSTINSTALL_AUTOFIX RELEASEDIR SETS"
+                        POSTINSTALL_AUTOFIX RELEASEDIR SETS EXT"


 # Directory in which to keep downloaded release files.
@@ -163,18 +163,19 @@
 # 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.
+# \param set_name Name of the set to extract, without the .tgz  or .tar.xz extension.
 extract_set() {
+    local extension="$(shtk_config_get EXT)"
     local set_name="${1}"; shift

-    require_cached_file "${set_name}.tgz"
+    require_cached_file "${set_name}${extension}"

     local destdir="$(shtk_config_get_default DESTDIR "")"
-    local set_tgz="$(get_cached_file "${set_name}.tgz")"
+    local set_ext="$(get_cached_file "${set_name}${extension}")"

     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 -
+    progress -zf "${set_ext}" tar -xp -C "${destdir}/" -f -
 }


@@ -188,10 +189,13 @@
     [ -z "${1}" ] || shtk_config_set "RELEASEDIR" "${1}"

     local releasedir="$(shtk_config_get RELEASEDIR)"
+    shtk_config_set EXT ".tgz"
+    [[ -f ${releasedir}/base${EXT} || shtk_config_set EXT '.tar.xz'
+    local extension="$(shtk_config_get EXT)"
     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"
+        fetch_files="${fetch_files} binary/sets/${set_name}${extension}"
     done
     if shtk_config_has KERNEL; then
         local kernel_name="$(shtk_config_get KERNEL)"
@@ -321,6 +325,7 @@
 # \param ... Names of the sets to extract, to override SETS.
 sysupgrade_sets() {
     local sets=
+    local extension="$(shtk_config_get EXT)"
     for set_name in "${@:-$(shtk_config_get SETS)}"; do
         case "${set_name}" in
             *etc) ;;  # Handled by etcupdate.
@@ -334,7 +339,7 @@
     done

     for set_name in ${sets}; do
-        require_cached_file "${set_name}.tgz"
+        require_cached_file "${set_name}${extension}"
     done

     shtk_cli_info "Upgrading base system"
@@ -346,6 +351,7 @@

 # Runs etcupdate to install new configuration files.
 sysupgrade_etcupdate() {
+    local extension="$(shtk_config_get EXT)"
     [ ${#} -eq 0 ] || shtk_cli_usage_error "etcupdate does not take any" \
         "arguments"

@@ -366,8 +372,8 @@

     local sflags=
     for set_name in ${sets}; do
-        require_cached_file "${set_name}.tgz"
-        sflags="${sflags} -s$(get_cached_file "${set_name}.tgz")"
+        require_cached_file "${set_name}${extension}"
+        sflags="${sflags} -s$(get_cached_file "${set_name}${extension}")"
     done

     shtk_cli_info "Upgrading /etc interactively"
@@ -379,6 +385,7 @@
 #
 # \param ... Arguments to pass to postinstall(8).
 sysupgrade_postinstall() {
+    local extension="$(shtk_config_get EXT)"
     local sets=
     local sets="$(shtk_list_filter '*etc' $(shtk_config_get SETS))"
     if [ -z "${sets}" ]; then
@@ -392,8 +399,8 @@

     local sflags=
     for set_name in ${sets}; do
-        require_cached_file "${set_name}.tgz"
-        sflags="${sflags} -s$(get_cached_file "${set_name}.tgz")"
+        require_cached_file "${set_name}${extension}"
+        sflags="${sflags} -s$(get_cached_file "${set_name}${extension}")"
     done

     shtk_cli_info "Performing postinstall checks"

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->jmmv
Responsible-Changed-By: hauke@NetBSD.org
Responsible-Changed-When: Sun, 04 Nov 2018 09:44:44 +0000
Responsible-Changed-Why:
Over to maintainer.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.