Upgrade NetBSD 7.0 do 10 przy pomocy sysupgrade.

Upgrade NetBSD 7.0 do 10 przy pomocy sysupgrade.
Photo by Oleksandr Chumak / Unsplash

Upgrade przy pomocy sysupgrade powinien przebiegać bezproblemowo, natomiast upgrade systemu z okolic roku 2018 w roku 2024 dostarcza kilku problemów.

Problem 1 - setsy są w tar.xz

sysupgrade zainstalowany z pkgsrc z 2018 nie rozumie i nie rozpakowuje tego archiwum

Problem 2 - tar nie rozumie tar.xz

Tar z base systemy NetBSD 7.0 nie umie rozpakować archiwum tar.xz

# sysupgrade sets
sysupgrade: I: Upgrading base system
sysupgrade: I: Extracting base into /
  0% |                                                                                             tar:                                                                                                     unknown option -- J                 |     0        0.00 KiB/s    --:-- ETA

Problem 3 - pkgsrc-2024q2 wpada w cyrkularną zależność przy próbie instalowania czegokolwiek, a że wszystko zależy od nowego pkg_install i mktools to w zasadzie nie da się nic zainstalować:

# cd /usr/pkgsrc/pkgtools/mktools
# make install
===> Trying to handle out-dated pkg_install...
===> Cleaning for pkg_install-20240307
===> Installing dependencies for pkg_install-20240307
==========================================================================
The supported build options for pkg_install are:

        inet6 openssl

The currently selected options are:

        inet6 openssl

You can select which build options to use by setting PKG_DEFAULT_OPTIONS
or the following variable.  Its current value is shown:

        PKG_OPTIONS.libfetch (not defined)

==========================================================================
==========================================================================
The following variables will affect the build process of this package,
pkg_install-20240307.  Their current value is shown below:

        * SSLBASE = /usr
        * SSLCERTBUNDLE (not defined)
        * SSLCERTS = /etc/openssl/certs
        * SSLDIR = /etc/openssl
        * SSLKEYS = /etc/openssl/private

You may want to abort the process now with CTRL-C and change the value
of variables in the first group before continuing.  Be sure to run
/usr/bin/make clean' after the changes.
==========================================================================
=> Tool dependency mktools-[0-9]*: NOT found
=> Verifying reinstall for ../../pkgtools/mktools
===> Trying to handle out-dated pkg_install...
===> Cleaning for pkg_install-20240307
ERROR: This package has set PKG_FAIL_REASON:
ERROR: Circular dependency detected
*** Error code 1

Stop.
make[3]: stopped in /usr/pkgsrc/pkgtools/pkg_install
*** Error code 1

Stop.
make[2]: stopped in /usr/pkgsrc/pkgtools/mktools
*** Error code 1

Stop.
make[1]: stopped in /usr/pkgsrc/pkgtools/pkg_install
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/pkgtools/mktools
# clear
# cd /usr/pkgsrc/pkgtools/pkg_install
# make install
===> Installing dependencies for pkg_install-20240307
==========================================================================
The supported build options for pkg_install are:

        inet6 openssl

The currently selected options are:

        inet6 openssl

You can select which build options to use by setting PKG_DEFAULT_OPTIONS
or the following variable.  Its current value is shown:

        PKG_OPTIONS.libfetch (not defined)

==========================================================================
==========================================================================
The following variables will affect the build process of this package,
pkg_install-20240307.  Their current value is shown below:

        * SSLBASE = /usr
        * SSLCERTBUNDLE (not defined)
        * SSLCERTS = /etc/openssl/certs
        * SSLDIR = /etc/openssl
        * SSLKEYS = /etc/openssl/private

You may want to abort the process now with CTRL-C and change the value
of variables in the first group before continuing.  Be sure to run
/usr/bin/make clean' after the changes.
==========================================================================
=> Tool dependency mktools-[0-9]*: NOT found
=> Verifying reinstall for ../../pkgtools/mktools
===> Trying to handle out-dated pkg_install...
===> Cleaning for pkg_install-20240307
ERROR: This package has set PKG_FAIL_REASON:
ERROR: Circular dependency detected
*** Error code 1

Stop.
make[2]: stopped in /usr/pkgsrc/pkgtools/pkg_install
*** Error code 1

Stop.
make[1]: stopped in /usr/pkgsrc/pkgtools/mktools
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/pkgtools/pkg_install
# cd /usr/pkgsrc/pkgtools/mktools
# make install
===> Trying to handle out-dated pkg_install...
===> Cleaning for pkg_install-20240307
===> Installing dependencies for pkg_install-20240307
==========================================================================
The supported build options for pkg_install are:

        inet6 openssl

The currently selected options are:

        inet6 openssl

You can select which build options to use by setting PKG_DEFAULT_OPTIONS
or the following variable.  Its current value is shown:

        PKG_OPTIONS.libfetch (not defined)

==========================================================================
==========================================================================
The following variables will affect the build process of this package,
pkg_install-20240307.  Their current value is shown below:

        * SSLBASE = /usr
        * SSLCERTBUNDLE (not defined)
        * SSLCERTS = /etc/openssl/certs
        * SSLDIR = /etc/openssl
        * SSLKEYS = /etc/openssl/private

You may want to abort the process now with CTRL-C and change the value
of variables in the first group before continuing.  Be sure to run
/usr/bin/make clean' after the changes.
==========================================================================
=> Tool dependency mktools-[0-9]*: NOT found
=> Verifying reinstall for ../../pkgtools/mktools
===> Trying to handle out-dated pkg_install...
===> Cleaning for pkg_install-20240307
ERROR: This package has set PKG_FAIL_REASON:
ERROR: Circular dependency detected
*** Error code 1

Stop.
make[3]: stopped in /usr/pkgsrc/pkgtools/pkg_install
*** Error code 1

Stop.
make[2]: stopped in /usr/pkgsrc/pkgtools/mktools
*** Error code 1

Stop.
make[1]: stopped in /usr/pkgsrc/pkgtools/pkg_install
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/pkgtools/mktools

Rozwiązanie jakie wymyśliłem dające 100% sukcesu, jest następujące:

  1. Cofamy się do pkgsrc z okolic świetności systemu NetBSD 7.0 czyli np 2018Q3
cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2018Q3 -P pkgsrc
  1. Instalujemy GNU Tar
cd /usr/pkgsrc/archivers/gtar-base/
make install clean
  1. Pobieramy wszystkie a minimalnie base.tar.xz, comp.tar.xz, misc.tar.xz oraz modules.tar.xz z mirrora NetBSD. Może byc problem z certyfikatami SSL a także może być problem z brakiem narzędzia wget więc proponuję ftp i pobranie plików z lokalizacji:
ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-10.0/amd64/binary/sets/

Poniżej cały proces:

0:00
/0:58
  1. Następnie aktualizujemy tylko kernel oraz moduły przy pomocy gtar rozpakowując je do / i na koniec reboot
# gtar -zxvpf kern-XEN3_DOMU.tar.xz
./netbsd
# mv netbsd /
# gtar -zxvpf modules.tar.xz -C /
reboot
0:00
/1:24
  1. Mając działajacy kernel i moduły, możemy ręcznie rozpakować base system i pakiety pomocnicze.
gtar -zxvpf base.tar.xz -C /
gtar -zxvpf comp.tar.xz  -C /
gtar -zxvpf misc.tar.xz  -C /
0:00
/1:12

To pozwala używać najnowszego pkgsrc (aktualnie 2024Q2), tak aby móc zaktualizować sysupgrade do najnowszej wersji, która umie obsłużyć archiwa tar.xz, a także zapewnia tar w base systemie współpracujacy z tar.xz i sysupgrade. Zatem kasujemy stare drzewo i pobieramy najnowsze:

# rm -rf /usr/pkgsrc
# cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2024Q2 -P pkgsrc
# cd /usr/pkgsrc/sysutils/sysupgrade

Trzeba jeszcze dodać do mk.conf - PKG_DBDIR=/var/db/pkg ponieważ zmieniło się domyślne miejsce instalacji paczek

# make update clean
===> Resuming update for sysupgrade-1.5nb10
=> Bootstrap dependency digest>=20211023: NOT found
=> Verifying update for ../../pkgtools/digest
===> Resuming update for digest-20220214
===> Installing dependencies for digest-20220214
=> Tool dependency mktools-[0-9]*: NOT found
=> Verifying update for ../../pkgtools/mktools
===> Skipping vulnerability checks.
WARNING: No /var/db/pkg/pkg-vulnerabilities file found.
WARNING: To fix run: `/usr/sbin/pkg_admin -K /var/db/pkg fetch-pkg-vulnerabilities'.
===> Installing dependencies for mktools-20220614
=> Tool dependency cwrappers>=20150314: found cwrappers-20170112
===> Skipping vulnerability checks.
WARNING: No /var/db/pkg/pkg-vulnerabilities file found.
WARNING: To fix run: `/usr/sbin/pkg_admin -K /var/db/pkg fetch-pkg-vulnerabilities'.
===> Overriding tools for mktools-20220614
===> Extracting for mktools-20220614
/bin/cp -R /usr/pkgsrc/pkgtools/mktools/files/ /usr/pkgsrc/pkgtools/mktools/work/mktools-20220614/
===> Patching for mktools-20220614
===> Creating toolchain wrappers for mktools-20220614
===> Configuring for mktools-20220614
===> Building for mktools-20220614
rm -f .gdbinit
touch .gdbinit

[...]

===> Installing binary package of sysupgrade-1.5nb10
sysupgrade-1.5nb10: copying /usr/pkg/share/examples/sysupgrade/default.conf to /usr/pkg/etc/sysupgrade.conf
===> Cleaning for sysupgrade-1.5nb10
===> Cleaning for sysupgrade-1.5nb10
  1. Wrzucamy/pobieramy wszystkie pliki do nowego katalogu z cachem od sysupgrade:
cd /root/10/
mv * var/cache/sysupgrade/
  1. Aktualizaujemy userland już przy pomocy sysupgrade:
sysupgrade sets
0:00
/1:30
  1. Następnie sprawdzamy, aktualizujemy i uzupełniamy pliki konfiguracyjne o zmiany miedzy 7.0 a 10.0 uważając aby nie nadpisać naszych ustawień.
sysupgrade etcupdate

Na koniec sprawdzamy czy są jakieś zalecenie do wykonania, które sprawdzenia nie poszły i uruchamiamy je:

sh /usr/sbin/postinstall -s /var/cache/sysupgrade/etc.tar.xz -s /var/cache/sysupgrade/xetc.tar.xz -d / fix opensslcertsrehash rc varshm obsolete

Jeżeli w polu postinstall checks failed: nie ma nic, upgrade wykonał się prawidłowo. Dla pewności można pościć sprawdzanie wszystkiego jeszcze raz przy pomocy:

sysupgrade postinstall
0:00
/1:13
  1. Należy wykonać reboot i system powinien wrócić jako już pełno prawny NetBSD 10.0, gdzie dalej można juz wykonać upgrade paczek z pkgsrc lub pkgin dla wersji 10.