Score:1

How to do apt-get dist-upgrade with noninteractive?

in flag

I am on Ubuntu 20.04 and using this command:

DEBIAN_FRONTEND=noninteractive UCF_FORCE_CONFFOLD=1 apt-get -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold -y --allow-downgrades --allow-remove-essential --allow-change-held-package dist-upgrade

However I get 2 dialog prompts during this process:

kdump-tools

grub-efi

I tried searching for an answer for hours, I found pages like this but unfortunately the solutions do not prevent these dialogs: https://serverfault.com/questions/48724/100-non-interactive-debian-dist-upgrade

How would I automate selecting the first item in the case of grub-efi and selecting "yes" in the case of kdump-tools?

user535733 avatar
cn flag
`--allow-downgrades` and `--allow-remove-essential` are dangerous. You're telling apt that it's okay to destroy your system if the package logic leads it that way. Human supervision of the proposed changes is strongly recommended when using those flags.
Hackeron avatar
in flag
Yes, I know, I was just illustrating the fact that I even tried these flags too, but ideally with a solution to the unattended problem I will then remove these flags.
Score:1
in flag

The command that sets the debconf parameters looks like this:

echo "grub-pc grub-pc/install_devices multiselect /dev/sda1" | sudo debconf-set-selections

However to make things a bit cleaner, I ended up with this Ruby code:

debconf_rules = {
  'grub-pc' => [
    'install_devices multiselect /dev/sda1',
    'postrm_purge_boot_grub boolean false'
  ],
  'grub-efi' => 'install_devices multiselect /dev/sda1',
  'kdump-tools' => 'use_kdump boolean true',
  'postgresql-15' => 'postrm_purge_data boolean true'
}

# e.g. echo "grub-pc grub-pc/install_devices multiselect /dev/sda1" | sudo debconf-set-selections
debconf_rules.each do |package, rules|
  rules = [rules] unless rules.is_a?(Array)
  rules.each do |rule|
    puts "Setting DPKG Rule: #{package} #{package}/#{rule}"
    `echo "#{package} #{package}/#{rule}" | sudo debconf-set-selections`
  end
end
Score:0
hu flag
debconf-set-selections <<< "grub-efi grub-efi/install_devices multiselect /dev/sda1"
debconf-set-selections <<< "kdump-tools kdump-tools/install_kdump boolean true"
terdon avatar
cn flag
Can you please edit your answer and explain how this helps? The OP wants to run a `dist-upgrade`, but you don't seem to be saying anything about that.
Hackeron avatar
in flag
Unfortunately it still pops the dialog up, curiously, if I run sudo debconf-show kdump-tools before manually selecting it shows: " kdump-tools/use_kdump: true" - however, after manually selecting it shows: "* kdump-tools/use_kdump: true" (the asterisk is added), any ideas?
Hackeron avatar
in flag
I will accept this solution but also post my answer of what I ended up with, which is similar to this answer.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.