1

I understand that when running the code sudo apt-get install <packagename> it will only give me this:

Do you want to continue? [Y/n]

If that package will install additional packages. But how do I force apt to give me that confirmation dialog every time that I install a package no matter whether or not it will install additional packages as well?


OS Information:

Description:    Ubuntu 14.10
Release:    14.10

Package Information:

apt:
  Installed: 1.0.9.2ubuntu2
  Candidate: 1.0.9.2ubuntu2
  Version table:
 *** 1.0.9.2ubuntu2 0
        500 http://gb.archive.ubuntu.com/ubuntu/ utopic/main amd64 Packages
        100 /var/lib/dpkg/status
1

1 Answer 1

2

A simple solution would be to make a script that checks first and then launches. For example:

#!/usr/bin/env bash

## Do a test run of the apt-get command, printing the relevant details
sudo apt-get -s install "$@" | 
  perl -ne '$a=1 if /Reading state information/; if($a==1 && /:$/ || /^\s/){print}'

read -p "Do you want to continue? [YN] " response

[[ $response =~ ^[Yy] ]] && sudo apt-get install "$@"

If you save that script somewhere in your path, for example as ~/bin/apt-nanny and make it executable (chmod +x ~/bin/apt-nanny), you can use it to install packages (using nedit as an example):

$ apt-nanny nedit
The following packages were automatically installed and are no longer required:
  liblightdm-gobject-1-0 lightdm-gtk-greeter
The following extra packages will be installed:
  libmotif-common libmrm4 libuil4 libxm4
The following NEW packages will be installed:
  libmotif-common libmrm4 libuil4 libxm4 nedit
Do you want to continue? [YN] 

If you enter y or Y, the script will continue and install the packages.


CAVEATS:

  • The script will show you the same information twice in cases where you would have been asked for confirmation anyway.
  • I haven't tested this extensively, there may be cases whjere more/less information than you need will be shown.
  • It's ugly and runs apt-get twice.

You must log in to answer this question.