netkit-jh / netkit-jh-build

Build scripts for the kernel, filesystem and assisting scripts/programs for Netkit-JH.
https://netkit-jh.github.io/
GNU General Public License v3.0
22 stars 12 forks source link

Add package installer script (vpackage) #89

Closed AdamBromiley closed 3 years ago

AdamBromiley commented 3 years ago

This PR adds a vcommand called vpackage.

The script mounts the Netkit filesystem image to /mnt/netkit-fs-mount-point (default), chroots into the mount point, and then performs a package management command on the filesystem before unmounting it.

Supported subcommands that are passed directly into apt-get are:

  update              synchronise package index files with their respective
                        sources
  upgrade             install latest package versions
  dist-upgrade        upgrade and potentially remove unnecessary packages
  install PACKAGE...  install or upgrade packages and their dependencies
  remove PACKAGE...   remove packages, leaving their configuration files
  purge PACKAGE...    remove packages and their configuration files
  clean               clear out the apt cache
  autoremove          (alias auto-remove) remove dependencies that are no
                        longer needed

and list is a subcommand that triggers dpkg --list.

Some Apt subcommands were not implemented for reasons relating to lack of usefulness in a mounted filesystem or the fact they added unnecessary complexity to the script.

Some Apt options are provided in the vpackage command line, and additional ones may be specified with the --pass passthrough option.

The pull request also adds the VPACKAGE_MOUNT_POINT variable to netkit.conf to specify the default mount point for the filesystem. The config version was also bumped straight from 4 to 6 to fix an earlier issue where the version was not increased to 5 after an update.

TODO: currently it is assumed that the host system has a valid /etc/resolv.conf file specifying a nameserver. This is bind mounted into the filesystem mountpoint at $MOUNT_DIRECTORY/etc/resolv.conf. In the event that the user does not have such a file, there should be a --nameserver=ADDR option to specify nameserver. The original plan was generating a temporary file containing nameserver ADDR and bind mounting that in - this did not work for an unknown reason.