-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src/apply.bash: Update pacman database before installing packages #204
src/apply.bash: Update pacman database before installing packages #204
Conversation
Hi, unfortunately I don't think this is desired in all circumstances. I think it might also be potentially dangerous, as a database sync must always be followed by a full system upgrade - otherwise, installing a package would result in a partial upgrade. Could we detect that the databases are missing? In which case, we could do a |
e0c4a51
to
b01b05c
Compare
Good catch. I didn't think about partial upgrades. Allow me to throw some code at you and please let me know if this is the right direction. |
src/apply.bash
Outdated
@@ -212,6 +212,16 @@ function AconfApply() { | |||
|
|||
LogLeave # Installing priority files | |||
|
|||
if ! sudo "$PACMAN" --database --check --check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that the check (--database --check --check
) and the cure (--sync --refresh --upgrades
) are checking for / curing the same thing. For example, on my system, this check complains about some missing dependencies, which doesn't seem to be related to the matter at hand, and I don't think would require --refresh
to fix.
Perhaps a single --check
would do the job? But, if it would be good if we had some way that we could be certain that the check will be positive only in the situations where the fix will do what is needed.
test/t/mocks/pacman
Outdated
done | ||
if $opt_db_sync_check | ||
then | ||
exit_code=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is very helpful. The database files missing is an extraordinary circumstance, which I think should have one test dedicated to it, rather than a situation encountered in every test.
In this case, an integration test (which deletes the database files) would probably be the most helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any tips on how to create such an integration test? I've been staring at the tests for a while but it's not exactly clear to me how to achieve the removal of a pacman db in the test container.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps take t-2_apply-1_packages-1_new.sh
as a base and add TestIntegrationOnly
at the top + command sudo rm -rf /var/lib/pacman/sync
at the end of the TestPhase_Setup
section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does seem to work, thanks!
src/apply.bash
Outdated
@@ -212,6 +212,16 @@ function AconfApply() { | |||
|
|||
LogLeave # Installing priority files | |||
|
|||
if ! sudo "$PACMAN" --database --check --check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check takes a couple seconds for me, even with one --check
. It does seem to be more involved than what we need, which is to check that the database files are present. If there's no better way to check for that situation, then probably it should be in a LogEnter
/ LogLeave
block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've poked around and I could grep for something like "database file for 'community' does not exist" since it's printed even when just invoking pacman with no args. What do you think?
[testme@64d38ef3aa04 aconfmgr]$ pacman
warning: database file for 'community' does not exist (use '-Sy' to download)
warning: database file for 'multilib' does not exist (use '-Sy' to download)
error: no operation specified (use -h for help)
[testme@64d38ef3aa04 aconfmgr]$ echo $?
1
[testme@64d38ef3aa04 aconfmgr]$ sudo pacman --database
warning: database file for 'community' does not exist (use '-Sy' to download)
warning: database file for 'multilib' does not exist (use '-Sy' to download)
[testme@64d38ef3aa04 aconfmgr]$ echo $?
0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no cleaner solution then I guess that would work. Just have to make sure to run it with LC_ALL=C
.
src/apply.bash
Outdated
@@ -212,6 +212,16 @@ function AconfApply() { | |||
|
|||
LogLeave # Installing priority files | |||
|
|||
if ! sudo "$PACMAN" --database --check --check | |||
then | |||
function Details() { Log "The pacman database is out of sync with the configuration, update?" ; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function Details() { Log "The pacman database is out of sync with the configuration, update?" ; } | |
function Details() { Log "The pacman local package database is internally inconsistent. Perform a full refresh and system upgrade now?\n" ; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/apply.bash
Outdated
function Details() { Log "The pacman database is out of sync with the configuration, update?" ; } | ||
Confirm Details | ||
|
||
LogEnter 'Updating pacman database...\n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LogEnter 'Updating pacman database...\n' | |
LogEnter 'Performing a full refresh and system upgrade...\n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/apply.bash
Outdated
Confirm Details | ||
|
||
LogEnter 'Updating pacman database...\n' | ||
sudo "$PACMAN" --sync --refresh --upgrades |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be --sysupgrade
not --upgrades
(see CI failure).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed - done
b01b05c
to
0ac1229
Compare
0ac1229
to
2287353
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise!
src/apply.bash
Outdated
function Details() { Log "The pacman local package database is internally inconsistent. Perform a full refresh and system upgrade now?\n" ; } | ||
Confirm Details |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is going to be a little less confusing, as the user doesn't know what they're agreeing to unless they ask for details:
function Details() { Log "The pacman local package database is internally inconsistent. Perform a full refresh and system upgrade now?\n" ; } | |
Confirm Details | |
Log 'The pacman local package database is internally inconsistent. Perform a full refresh and system upgrade now?\n' | |
Confirm '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I've added "resolves #33" into the commit message too.
On a fresh install it might happen that after priority files, including the pacman config, are installed the pacman database is not up to date. : Applying configuration... :: Installing priority files... ::: Installing /etc/pacman.conf... :::: Done. ::: Done. :: Configuring packages... ::: Unpinning 4 unknown packages. warning: database file for 'community' does not exist (use '-Sy' to download) warning: database file for 'multilib' does not exist (use '-Sy' to download) This can later result in issues with finding the correct package during the "Apply packages" step. error: target not found: lib32-vulkan-intel error: target not found: lib32-vulkan-mesa-layers error: target not found: steam error: target not found: wine To avoid this issue ask the user if he wishes to do as pacman suggests and update the database before "Apply packages". To avoid an inconsistent state upgrade packages for which database entries were updated, in other words perform a system upgrade. Resolves CyberShadow#33
2287353
to
5cb934c
Compare
Cool! Thanks for your patience! |
On a fresh install it might happen that after priority files including the pacman config are installed, the pacman database is not up to date.
: Applying configuration...
:: Installing priority files...
::: Installing /etc/pacman.conf...
:::: Done.
::: Done.
:: Configuring packages...
::: Unpinning 4 unknown packages.
warning: database file for 'community' does not exist (use '-Sy' to download)
warning: database file for 'multilib' does not exist (use '-Sy' to download)
This can later result in issues with finding the correct package during the "Apply packages" step.
error: target not found: lib32-vulkan-intel
error: target not found: lib32-vulkan-mesa-layers
error: target not found: steam
error: target not found: wine
To avoid this issue do as pacman suggests and update the database before "Apply packages"
Please let me know if I missed something.