This page contains information about a number of non-trivial bash shell functions I use in my scripts. Providing this info here is both for my own benefit as well as for others'. A listing of the actual code of a function can be called up by clicking the function name in the title. Smaller functions the main functions depend on are usually included in the listing.
The function first compares the version of the package with the current one in the cache. If this is newer, it will download the new version, unpack it and compare the file(s) listed. The fact a file has changed will be reported, and the differences are shown in the log file.
The commands available are: install, reinstall, upgrade, remove, purge, hold, replace-conf and reconfigure. Only reconfigure is limited to one package name as argument. The others can have multiple arguments, separated by commas. An item must not contain whitespace.
The difference between reinstall and install is that the first uses apt-get install with the --reinstall switch. Upgrade is essentially the same as install.
Several qualifiers may be added. If the command starts with k), k8), k9), k10), k_), kee), x), x8), x9), x10), x_) or xee), it will only be executed in the specified environment (k=KDE, x=Xfce). The numbers specify the SolydXK release required and ee means Enthusiast's Edition only and _ main edition only. Following that, a colon at the start of a command makes the function add some dpkg force options, e.g. ignoring dependency problems.
A +[ sequence following the equals sign signals a variable dependent command, i.e. +[Control:names,of,packages]. The packages can be specified directly or in a variable. They will only be handled if the control variable exists (or not, with +[! instead of +[).
If a package name contains the literal [DE], the code (k or x) for the desktop environment will replace it. Similarly, [RELOLD] and [RELNEW] will be replaced with the old and new release numbers (for the main edition, currently 8 and 9 respectively - 9 and 10 for an EE).
If a package must be installed without the additional packages its control file recommends, the three characters !r; must precede its name.
To force replacing a package's configuration files (replace-conf command), add a (semi-colon separated) list of files to be replaced after the package name and a semi-colon.
Package names can have a trailing equals sign plus version number, e.g. for downgrading (with the install command) or forcibly holding a package at that version (this can include up or downgrading). In case of a hold, the required package must be/remain available in one of the repositories used and this must have a higher priority than all others.
If a package name has a trailing colon, the command will only handle the package for the foreign architecture. This option cannot be combined with specifying the version number.
While most commands are processed by apt-get, the reconfigure command is short for dpkg-reconfigure. Reconfiguring a package will only happen if the package in question is actually installed by the way, so listing all kinds of different grub packages, as is done in the example above, should be fine.