Debian 8 base system (amd64)

by sanvila
4 deployments · 4 still active · last rev. 1 year ago

This script tries to emulate a Debian install in which you only install the "base system". This may be useful if you really want to start from scratch.

Compatible with: Debian 8
						#!/bin/sh
# Script to install packages in the "base system", and only those.
# Originally written by Santiago Vila <sanvila@debian.org>. 2015-06-15.
# This script is in the public domain.
#
# The list of packages in the base system was created by doing this:
#
# Install Debian 8 for amd64 on a qemu virtual machine, using debian-installer.
#
# Only the base system was installed:
#
# [*] Install the base system
# [ ] Configure the package manager
# [ ] Select and install software
# [*] Install the GRUB boot loader on a hard disk
#
# Then install the "openssh-server" package without its Recommends.
#
# That's all.
#
# It would be possible to purge other packages which obviously should
# not be in the base system like gcc-4.8-base but we have to draw the
# line somewhere.
#
#####################################################################
#
# Support functions
#

lines_in_2_not_in_1() {
  awk '{ if (FILENAME == ARGV[1]) { a[$0] = 1 } else if (! ($0 in a)) { print $0 } }' $1 $2
}

installed_packages() {
  cd /var/lib/dpkg/info
  ls *.list | sed -e 's/\.list//' | sed -e 's/:.*//' | LC_ALL=C sort
}

install_wanted_packages() {
  apt-get -y -o APT::Install-Recommends="0" install `cat /root/packages.txt`
}

remove_unwanted_packages() {
  list=`tempfile`
  installed_packages > ${list}
  purge=`lines_in_2_not_in_1 /root/packages.txt ${list}`
  rm -f ${list}
  if [ "${purge}" != "" ]; then
    dpkg --purge ${purge}
  fi
}

#
# First the script parses itself to create /root/packages.txt
#
splitscript=`tempfile`
tail -n 14 $0 > ${splitscript}
awk -f ${splitscript} $0
rm -f ${splitscript}

#
# Then it does what it's supposed to do
#
(
apt-get update
echo debconf debconf/frontend select Noninteractive | debconf-set-selections
install_wanted_packages
remove_unwanted_packages
apt-get clean
) | tee /root/StackScript.log
exit 0

# List of wanted packages
START
FILE: 644 /root/packages.txt
acl
acpi
acpi-support-base
acpid
adduser
apt
apt-utils
base-files
base-passwd
bash
bsdmainutils
bsdutils
busybox
console-setup
console-setup-linux
coreutils
cpio
cron
dash
debconf
debconf-i18n
debian-archive-keyring
debianutils
diffutils
dmidecode
dmsetup
dpkg
e2fslibs
e2fsprogs
eject
findutils
gcc-4.8-base
gcc-4.9-base
gettext-base
gnupg
gpgv
grep
groff-base
grub-common
grub-pc
grub-pc-bin
grub2-common
gzip
hostname
ifupdown
init
init-system-helpers
initramfs-tools
initscripts
insserv
iproute2
iptables
iputils-ping
isc-dhcp-client
isc-dhcp-common
kbd
keyboard-configuration
klibc-utils
kmod
less
libacl1
libapt-inst1.5
libapt-pkg4.12
libasprintf0c2
libattr1
libaudit-common
libaudit1
libblkid1
libboost-iostreams1.55.0
libbsd0
libbz2-1.0
libc-bin
libc6
libcap2
libcap2-bin
libcomerr2
libcryptsetup4
libdb5.3
libdebconfclient0
libdevmapper1.02.1
libdns-export100
libedit2
libestr0
libffi6
libfreetype6
libfuse2
libgcc1
libgcrypt20
libgdbm3
libgmp10
libgnutls-deb0-28
libgnutls-openssl27
libgpg-error0
libgssapi-krb5-2
libhogweed2
libicu52
libidn11
libirs-export91
libisc-export95
libisccfg-export90
libjson-c2
libk5crypto3
libkeyutils1
libklibc
libkmod2
libkrb5-3
libkrb5support0
liblocale-gettext-perl
liblogging-stdlog0
liblognorm1
liblzma5
libmnl0
libmount1
libncurses5
libncursesw5
libnetfilter-acct1
libnettle4
libnewt0.52
libnfnetlink0
libp11-kit0
libpam-modules
libpam-modules-bin
libpam-runtime
libpam0g
libpci3
libpcre3
libpipeline1
libpng12-0
libpopt0
libprocps3
libpsl0
libreadline6
libselinux1
libsemanage-common
libsemanage1
libsepol1
libsigc++-2.0-0c2a
libslang2
libsmartcols1
libss2
libssl1.0.0
libstdc++6
libsystemd0
libtasn1-6
libtext-charwidth-perl
libtext-iconv-perl
libtext-wrapi18n-perl
libtinfo5
libudev1
libusb-0.1-4
libusb-1.0-0
libustr-1.0-1
libuuid-perl
libuuid1
libwrap0
libxtables10
linux-base
linux-image-3.16.0-4-amd64
linux-image-amd64
locales
login
logrotate
lsb-base
man-db
manpages
mawk
mount
multiarch-support
nano
ncurses-base
ncurses-bin
net-tools
netbase
netcat-traditional
nfacct
openssh-client
openssh-server
openssh-sftp-server
os-prober
passwd
pciutils
perl-base
procps
readline-common
rsyslog
sed
sensible-utils
startpar
systemd
systemd-sysv
sysv-rc
sysvinit-utils
tar
tasksel
tasksel-data
traceroute
tzdata
ucf
udev
usbutils
util-linux
vim-common
vim-tiny
wget
whiptail
xkb-data
zlib1g
STOP
#!/usr/bin/awk -f
/^STOP/ { status = 2 }
status == 1 {
  if ($0 ~ /^FILE:/) {
    mode = $2
    file = $3
    system("touch " file)
    system("chmod " mode " " file)
  }
  else {
    print $0 > file
  }
}
/^START/ { status = 1 }