I'm setting up an automated "no questions asked" preseed system and using Dustin Kirkland's server preseed as an example.

He uses the following line to install three packages as part of the automated install:

d-i pkgsel/include string byobu vim openssh-server

I am looking for the inverse of this, basically be able to remove packages as part of the automated install.

I am thinking I need to to use d-i preseed/late_command string apt-remove packagename to clean up stuff I don't want when the install is done, but I am not sure

  • Definitely how I would go about it. Not big on preseed though. I use pseudopackages and start from a base install that doesn't have anything I don't want. – RobotHumans Jul 28 '11 at 12:04
  • No one from the desktop team or server team looked at this question? – Manish Sinha Oct 3 '11 at 19:24
  • I've tried this approach to remove packages but it is not working for me :(. gist.github.com/lmayorga1980/6d698a5d5425c676ecdd – Maverick Sep 8 '14 at 14:27

There isn't an option to purge o delete a package in the preseed configuration script but you can use this command....

d-i preseed/late_command

This command is run just before the install finishes, but when there is
still a usable /target directory. You can chroot to /target and use it
directly, or use the apt-install and in-target commands to easily install
packages and run commands in the target system.
"in-target" means: chroot /target
d-i preseed/late_command string [in-target] foo

example :

d-i preseed/late_command string \
            in-target apt-get remove packagename

you can also run a script :

d-i preseed/late_command string \
        in-target wget http://........./postinst.sh -O /root/postinst.sh; \
        in-target /bin/bash /root/postinst.sh

or install a group of DEB files :

d-i preseed/late_command               string \
    for deb in /hd-media/*.deb; do cp $deb /target/tmp; \
    chroot /target dpkg -i /tmp/$(basename $deb); done

The example pressed is just an example; it does not contain all possible d-i combinations, but just those more common.

Personally, I have never tried to remove packages from an install, so I am not sure there is a specific d-i command for it; it sounds like your d-i preseed late_command should work. A quick search on the d-i docs did not produce anything... But, of course, Colin would know ;-)

Alternatively, you could start from a basic server, and then add whatever you want:

tasksel tasksel/first   multiselect     Basic Ubuntu server
d-i preseed/late_command string apt-install whatever else

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.