[OmniOS-discuss] pkg(5) in alternate roots

Jim Klimov jim at cos.ru
Thu Jul 2 09:33:31 UTC 2015


От: Dan McDonald <danmcd at omniti.com>
Дата: Wednesday, July 1, 2015 19:43
> 
> > On Jul 1, 2015, at 9:20 AM, Jim Klimov <jim at cos.ru> wrote:
> > 
> > The corresponding part of the script (and exact command-lines 
> involved) are here:
> > 
> > 
> > ...
> > 
> >         { echo "===== 
> Updating PKG software itself"
> >           
> ### This clause should fail if no 'pkg' updates were available, 
> or if a
> >           
> ### chrooted upgrade attempt with the new 'pkg' failed - both 
> ways fall
> >           
> ### through to altroot upgrade attempt
> >           if 
> /usr/bin/pkg -R "$BENEW_MNT" update --no-refresh --accept --deny-
> new-be --no-backup-be pkg; then \
> >             echo "===== Updating the image with new PKG software via chroot"
> >             chroot "$BENEW_MNT" /usr/bin/pkg -R / image-update --no-refresh --accept --deny-new-be --no-backup-be
> >           
> else false; fi; } || \
> >         { echo "===== 
> Updating the image with old PKG software via altroot"
> >           
> /usr/bin/pkg -R "$BENEW_MNT" image-update --no-refresh --accept -
> -deny-new-be --no-backup-be; } || \
> >         { echo "===== 
> Updating the image with old PKG software via altroot and allowed 
> refresh">           /usr/bin/pkg -R "$BENEW_MNT" image-update --accept --deny-new-be --no-backup-be; }
> 
> Can you run these, one at a time, by hand, so we all can see the 
> exact output per command that's run?  It'll help at least 
> me get a better bead on what's wrong.
> 
> Thanks,
> Dan


Most of the output was in the screenshot just above that, and I guess I found a workaround 
that should suffice (will test more today), but for the sake of completeness, here goes:


The old BE was OmniOS bloody updated a month ago (20150602Z070407), new one with an updated pkg program was made yesterday, starting as the old one's clone (export BENEW=omnios-20150701Z065339-test) and the relevant tree was mounted into "/a" with my splitroot scripts from github:



###############################


:; ./beadm-mount.sh
omnios-20150701Z065339-test does not exist or appear to be a valid BE.
Please check that the name of the BE provided is correct.
=== Will clone omnios-20150602Z070407 into omnios-20150701Z065339-test, ok? Using these settings:
BENEW=omnios-20150701Z065339-test
BENEW_DS=rpool/ROOT/omnios-20150701Z065339-test
BENEW_MNT=/a
BENEW_MPT=/a
BEOLD=omnios-20150602Z070407
BEOLD_DS=rpool/ROOT/omnios-20150602Z070407
BEOLD_MNT=/
BEOLD_MPT=/
EXCLUDE_ATTRS='org.opensolaris.libbe:uuid|canmount|mountpoint'
RPOOL=rpool
RPOOLALT=
RPOOL_ROOT=rpool/ROOT
RPOOL_SHARED=rpool/SHARED
    (Press ENTER or CTRL+C)


Created successfully
=== Created omnios-20150701Z065339-test based on omnios-20150602Z070407
=== Trying to replicate ZFS attributes from original to new BE...
===== ''
org.opensolaris.libbe:policy=static
org.openindiana.caiman:install=ready
===== '/opt'
compression=gzip-9
===== '/opt/local'
compression=gzip-9
===== '/usr'
compression=gzip-9
===== '/usr/local'
compression=gzip-9
===== '/var'
compression=gzip-9
===== '/var/db'
===== '/var/db/pkgin'
===== '/var/pkg'
compression=gzip-9
===== '/var/pkg/publisher'
=== Replicated custom ZFS attributes
Mounted successfully on: '/a'
=== Mounted omnios-20150701Z065339-test at /a
rpool/ROOT/omnios-20150701Z065339-test   153387008      721348   124154515     1%    /a
rpool/ROOT/omnios-20150701Z065339-test/usr   153387008      758981   124154515     1%    /a/usr
rpool/ROOT/omnios-20150701Z065339-test/usr/local   153387008          28   124154515     1%    /a/usr/local
rpool/ROOT/omnios-20150701Z065339-test/opt   153387008     1207927   124154515     1%    /a/opt
rpool/ROOT/omnios-20150701Z065339-test/opt/local   153387008      811058   124154515     1%    /a/opt/local
rpool/ROOT/omnios-20150701Z065339-test/var   153387008       18600   124154515     1%    /a/var
rpool/ROOT/omnios-20150701Z065339-test/var/db   153387008          33   124154515     1%    /a/var/db
rpool/ROOT/omnios-20150701Z065339-test/var/db/pkgin   153387008      665190   124154515     1%    /a/var/db/pkgin
rpool/ROOT/omnios-20150701Z065339-test/var/pkg   153387008       38370   124154515     1%    /a/var/pkg
rpool/ROOT/omnios-20150701Z065339-test/var/pkg/publisher   153387008        9364   124154515     1%    /a/var/pkg/publisher
=== BE clone completed!


=== To upgrade from upstream do:
pkg -R "/a" image-update --deny-new-be --no-backup-be && touch "/a/reconfigure" && bootadm update-archive -R "/a" && beadm umount "omnios-20150701Z065339-test"


TS="`date -u "+%Y%m%dZ%H%M%S"`"
zfs snapshot -r "rpool/SHARED at postupgrade-$TS"
zfs snapshot -r "rpool/ROOT/omnios-20150701Z065339-test at postupgrade-$TS"


beadm activate "omnios-20150701Z065339-test"
===


INFO: Unmounting any previous traces (if any - may fail), just in case
=== Unmounting BE omnios-20150701Z065339-test under '/a'...
===== beadm-unmounting omnios-20150701Z065339-test (/a)...
Unmounted successfully
Mounted successfully on: '/a'
BE                          Active Mountpoint Space Policy Created
omnios-20150701Z065339-test -      /a         15.0K static 2015-07-01 17:09
===== lofs-mount '/tmp' at '/a/tmp'
===== lofs-mount '/proc' at '/a/proc'
===== lofs-mount '/dev' at '/a/dev'
===== lofs-mount '/devices' at '/a/devices'
===== lofs-mount '/var/adm' at '/a/var/adm'
===== lofs-mount '/var/cores' at '/a/var/cores'
===== lofs-mount '/var/crash' at '/a/var/crash'
===== lofs-mount '/var/log' at '/a/var/log'
===== lofs-mount '/var/mail' at '/a/var/mail'
===== lofs-mount '/var/spool/clientmqueue' at '/a/var/spool/clientmqueue'
===== lofs-mount '/var/spool/mqueue' at '/a/var/spool/mqueue'
===== lofs-mount '/var/tmp' at '/a/var/tmp'


BE                          Active Mountpoint Space Policy Created
omnios-20150701Z065339-test -      /a         15.0K static 2015-07-01 17:09
rpool/ROOT/omnios-20150701Z065339-test   153387008      721348   124154491     1%    /a
rpool/ROOT/omnios-20150701Z065339-test/usr   153387008      758981   124154491     1%    /a/usr
rpool/ROOT/omnios-20150701Z065339-test/usr/local   153387008          28   124154491     1%    /a/usr/local
rpool/ROOT/omnios-20150701Z065339-test/opt   153387008     1207927   124154491     1%    /a/opt
rpool/ROOT/omnios-20150701Z065339-test/opt/local   153387008      811058   124154491     1%    /a/opt/local
rpool/ROOT/omnios-20150701Z065339-test/var   153387008       18600   124154491     1%    /a/var
rpool/ROOT/omnios-20150701Z065339-test/var/db   153387008          33   124154491     1%    /a/var/db
rpool/ROOT/omnios-20150701Z065339-test/var/db/pkgin   153387008      665190   124154491     1%    /a/var/db/pkgin
rpool/ROOT/omnios-20150701Z065339-test/var/pkg   153387008       38370   124154491     1%    /a/var/pkg
rpool/ROOT/omnios-20150701Z065339-test/var/pkg/publisher   153387008        9364   124154491     1%    /a/var/pkg/publisher
/tmp                    14744832          16    14744816     1%    /a/tmp
/proc                          0           0           0     0%    /a/proc
/dev                           0           0           0     0%    /a/dev
/devices                       0           0           0     0%    /a/devices
/var/adm               124172025        3071   124168954     1%    /a/var/adm
/var/cores               5241366          19     5241347     1%    /a/var/cores
/var/crash               5242880          19     5242861     1%    /a/var/crash
/var/log               124173841         337   124173504     1%    /a/var/log
/var/mail              124173921         114   124173807     1%    /a/var/mail
/var/spool/clientmqueue     2096461          26     2096435     1%    /a/var/spool/clientmqueue
/var/spool/mqueue        2096392          30     2096362     1%    /a/var/spool/mqueue
/var/tmp               124515436      360944   124154491     1%    /a/var/tmp


=== SUCCESS, (un)mounting operations completed for BE 'omnios-20150701Z065339-test' at '/a'


###############################




So, the tree above is mounted. Updating pkg under /a altroot itself (note the script does this via "pkg -R /a update pkg", but in the example below I do it via chroot to verify it generally works for this):



###############################

:;  chroot /a /usr/bin/pkg -R /  update pkg
WARNING: The boot environment being modified is not the active one.  Changes
made will not be reflected on the next boot.


            Packages to update:   1
       Create boot environment:  No
Create backup boot environment: Yes


DOWNLOAD                                PKGS         FILES    XFER (MB)   SPEED
Completed                                1/1         16/16      0.3/0.3  183k/s


PHASE                                          ITEMS
Removing old actions                             1/1
Updating modified actions                      18/18
Updating package state database                 Done
Updating package cache                           1/1
Updating image state                            Done
Creating fast lookup database                   Done
Reading search index                            Done
Updating search index                            1/1
###############################


Now, trying to update packages inside that altroot in different ways...


What the script tries in the chroot:

###############################

:; chroot /a /usr/bin/pkg -R / image-update --no-refresh --accept --deny-new-be --no-backup-be
Creating Plan (Package planning:  425/427): /
pkg update: The proposed operation cannot be performed on a live image.
###############################


Trying to cheat with a non-verbatim "/" altroot string in the chroot:

###############################

:; chroot /a /usr/bin/pkg -R /// image-update --no-refresh --accept --deny-new-be --no-backup-be
pkg update: The proposed operation cannot be performed on a live image.
###############################


Trying the two other ways the script attempts (original BE's old pkg over a new BE's packages)

###############################

:; /usr/bin/pkg -R /a image-update --no-refresh --accept --deny-new-be --no-backup-be

Checking that pkg(5) is up to date -



WARNING: pkg(5) appears to be out of date, and should be updated before
running update.  Please update pkg(5) by executing 'pkg install
pkg:/package/pkg' as a privileged user and then retry the update.
###############################


###############################

:; /usr/bin/pkg -R /a image-update --accept --deny-new-be --no-backup-be
WARNING: pkg(5) appears to be out of date, and should be updated before
running update.  Please update pkg(5) by executing 'pkg install
pkg:/package/pkg' as a privileged user and then retry the update.
###############################




Finally, reading through the sources at /usr/bin/pkg and /usr/lib/python2.*/vendor-packages/pkg/ I tracked the error message to decision points to is_liveroot() to obscure envvars and/or configuration settings that cause some boolean regarding required new BE's to be true or false regardless of package-reboot settings.


Here is a piece which made me think it is intended for debug and so might not be a piece of committed API (would love to be wrong on this point): https://java.net/projects/ips/sources/pkg-gate/content/src/tests/api/t_bootenv.py#62


So, using PKG_LIVE_ROOT envvar, but no -R for altroot - no banana:

###############################

:; PKG_LIVE_ROOT=/ chroot /a /usr/bin/pkg image-update --no-refresh --accept --deny-new-be --no-backup-be
pkg update: The proposed operation cannot be performed on a live image.
###############################



Using both PKG_LIVE_ROOT envvar and -R for altroot - this is what ultimately succeeded, though only with a non-verbatim-"/" root directory string in this envvar:

###############################
:; PKG_LIVE_ROOT=/ chroot /a /usr/bin/pkg -R / image-update --no-refresh --accept --deny-new-be --no-backup-be
pkg update: The proposed operation cannot be performed on a live image.


:; PKG_LIVE_ROOT=/// chroot /a /usr/bin/pkg -R ///  image-update --no-refresh --accept --deny-new-be --no-backup-be

 Packages to remove:   1
Packages to install:   2
 Packages to update: 424
 Services to change:   1


DOWNLOAD                                PKGS         FILES    XFER (MB)   SPEED
SUNWcs                                 1/427      476/7699    6.4/418.8  1.1M/s^C





:; PKG_LIVE_ROOT=/// chroot /a /usr/bin/pkg -R / image-update --no-refresh --accept --deny-new-be --no-backup-be
 Packages to remove:   1
Packages to install:   2
 Packages to update: 424
 Services to change:   1


DOWNLOAD                                PKGS         FILES    XFER (MB)   SPEED
SUNWcs                                 1/427       96/7699    1.2/418.8  516k/s^C
###############################


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://omniosce.org/ml-archive/attachments/20150702/1dabe9c7/attachment-0001.html>


More information about the OmniOS-discuss mailing list