Page MenuHomeFreeBSD

sysutils/firstboot-pkgs: Bootstrap and update pkg unconditionally
ClosedPublic

Authored by lwhsu on Apr 20 2020, 9:59 PM.

Details

Summary

The background of this patch is available at:
https://lists.freebsd.org/pipermail/freebsd-cloud/2020-April/000234.html

Even a pkg -N success, the following pkg install may still fail because of
the repository version doesn't match between client and server.
Use pkg update as checker and perform a force bootstrap if needed.
The second pkg update is for ensuring pkg install will fetch the latest
packages as pkg bootstrap doesn't include updating the index.

Test Plan

Manually put in a very old image (11.3-R), launch an instance and do pkg install`

Diff Detail

Repository
rP FreeBSD ports repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

linimon retitled this revision from firstboot-pkgs: check if force bootstrap again is necessary to sysutils/firstboot-pkgs: check if force bootstrap again is necessary.Apr 21 2020, 2:57 AM
This revision is now accepted and ready to land.Apr 21 2020, 3:57 PM

I'm not sure I understand the logic behind this.

If I understand correctly, a problem arises when the local copy of the repository catalogue is a very old version. If this is the case, couldn't we also have problems if the local database of *installed* packages is an old version?

If there's a general danger that old versions of pkg might not be able to cope with changes which occurred long after VM images were created, why not make "update the pkg tool" unconditional rather than relying on "pkg update" to fail if and only if pkg should be updated?

I'm not sure I understand the logic behind this.

If I understand correctly, a problem arises when the local copy of the repository catalogue is a very old version. If this is the case, couldn't we also have problems if the local database of *installed* packages is an old version?

your understanding is correct, but it cannot happen because I make sure pkg is backward compatible regarding the local database and always able to upgrade an old version of the database.

If there's a general danger that old versions of pkg might not be able to cope with changes which occurred long after VM images were created, why not make "update the pkg tool" unconditional rather than relying on "pkg update" to fail if and only if pkg should be updated?

I agree that is would be better to make an unconditionnal update, pkg boostrap have been design exactly for that.

In D24517#540205, @bapt wrote:

I'm not sure I understand the logic behind this.

If I understand correctly, a problem arises when the local copy of the repository catalogue is a very old version. If this is the case, couldn't we also have problems if the local database of *installed* packages is an old version?

your understanding is correct, but it cannot happen because I make sure pkg is backward compatible regarding the local database and always able to upgrade an old version of the database.

Ok, so pkg guarantees compatibility with old versions of the installed-packages database but not with old versions of the repository-catalogue database?

If there's a general danger that old versions of pkg might not be able to cope with changes which occurred long after VM images were created, why not make "update the pkg tool" unconditional rather than relying on "pkg update" to fail if and only if pkg should be updated?

I agree that is would be better to make an unconditionnal update, pkg boostrap have been design exactly for that.

Ok, so the "bootstrap if necessary" section should just be an unconditional

env ASSUME_ALWAYS_YES=YES pkg bootstrap -f | cat
env ASSUME_ALWAYS_YES=YES pkg update -f | cat

?

Bootstrap and update pkg unconditionally

I originally wanted to delay this until first pkg update fails to try to
save some instance provision time. But this is safest to bootstrap to ensure
using the latest pkg before doing anything else.

This revision now requires review to proceed.May 20 2020, 10:57 PM
lwhsu retitled this revision from sysutils/firstboot-pkgs: check if force bootstrap again is necessary to sysutils/firstboot-pkgs: Bootstrap and update pkg unconditionally.Jun 3 2020, 3:43 PM

Looks good to me. Please commit.

This revision is now accepted and ready to land.Jun 8 2020, 5:10 PM