Maintain the NetBSD Base System Using pkg * Tools

Yuuki Enomoto∗ Ken’ichi Fukamachi†

Abstract This paper describes the ”basepkg.sh” for base system packaging to NetBSD base system more granular. Today, fine granular systems are expected to provide more rapid secu- rity update and more flexible customization in creating a very small base system for sensor network. In ”NetBSD”, base system packaging mechanism called ”syspkg” has been developed, but now, its development is stagnant. In addition, it is troubled to deal with ”syspkg” consisting of a lot of Makefiles and shell scripts. Thus we developed a simpler than ”syspkg” framework. This script uses src/distrib/sets/lists files and pkg create command to generate a fine granular base package. We verified our system can provide minimum functionality that our package can replace a part of NetBSD base system. It provides the first step for more granular NetBSD base system.

1 Introduction Many systems have its own (s) to manage soft- ”Unix” such as distribution and ware. The scope managed by the *BSD is used mainly as servers. It is package manager depends the system. very important to keep operating sys- Some developers consider that the tems up to date for security. If a soft- whole system consists of packages, an- ware is found to be vulnerable, other consider that the operating sys- administrators must update the soft- tem consists of the base and optional ware as soon as possible. packages. This updating process should be For example, Linux pack- rapid. So, it must be useful to replace a ages the whole system to update vulnerable with the latest bi- and upgrade it easily. FreeBSD nary by using some rapid mechanism 11.0 introduced a framework called e.g. package managers. PkgBase[FreeBSD 2017]. to divide the ∗Chitose Institute of Science and Technology, 758-90, Bibi, Chitose, Hokkaido, 066-8655, mailto: [email protected] https://e-yuuki.org/ †Chitose Institute of Science and Technology, 758-90, Bibi, Chitose, Hokkaido, 066-8655, mailto:[email protected] http://www.nsrg.fml.org/

1 base system into 757 packages where managers (e.g. ””) compile the pkg(8) can manage the FreeBSD base and it into the sys- system. tem. On the other hand, NetBSD had developed ”syspkg” under the same concept described above, but its de- 2.2 FreeBSD velopment is stagnant[NetBSD 2017]. Currently updating a base software ”FreeBSD” has a package system on NetBSD needs building from the called ”ports” to handle optional source code (or replacing the binary if 3rd party packages[FreeBSD 2017]. the major upgrade is available). It is ”ports” consists of a lot of Makefiles no quick response. So, NetBSD base to describe configurations. ”pkg” com- system packaging is required. mand manages actual installation/de- install action et.al. 2 Comparison of By default, ”ports” do not in- stall the binary package directly, but Package Manage- ”ports” can get and compile the source ment Systems code, and install it into the system us- ing the ”pkg” command. ”Package” is a collection of software, Also, ”ports” can fetch and install configuration files and documents. binary packages provided by FreeBSD. This collection is usually packed into a Instead of using ”ports”, FreeBSD single archive file in the ..gz, users can use ”pkg” command to ma- .zip, et.al. ”Package Manager” is a nipulate packages. software that manages package instal- lation, deinstallation and updating. Almost all Unix clone systems con- sist of a base mandatory system, aux- 2.3 NetBSD iliary systems (e.g. , docu- ments, X11 Window) and optional 3rd NetBSD has a portable package sys- party packages. The package manager tem called ””[NetBSD 2017] de- can modify the system by adding or rived from the FreeBSD ”ports” sys- deleting optional binary packages. tem. ”pkgsrc” is mainly developed for NetBSD but also can be avail- 2.1 able on a lot of platforms: NetBSD, FreeBSD, OpenBSD, DragonFlyBSD, ”Debian” Linux and the derived dis- Solaris, Linux, Darwin and other com- tributions use ””, ”-get” and mercial UNIX systems. Some systems ”apt” commands for package manage- such as DragonFlyBSD use ”pkgsrc” ments. as the package management system by ”CentOS” and the derived distribu- default. tions use ”rpm” and ”” commands ”pkgsrc” is similar to FreeBSD as package management systems. ”ports” but different to use another There are a few Linux distributions utilities called ”pkg *” to install or re- (e.g. ”Gentoo”) where the package move compiled software.

2 2.3.1 NetBSD pkg * Utility system[Debian 2017]. Software and functions in the base system can be In NetBSD, the pkg * utility consists easily added and deleted by handling of the following commands. them as a set of packages. • pkg add In the case of BSD Unix(s), FreeBSD 11.0 introduced a mecha- • pkg admin nism called PkgBase. FreeBSD divides • pkg create the base system into 757 packages for pkg(8) to be able to manage the base • pkg delete system. • pkg info Today NetBSD does not support base system packaging. NetBSD costs ”pkg create” creates a binary pack- us a little bit of time to update a base age and saves it in ”tgz” format. software. We need to build from the ”pkg add” installs and upgrades source code and install it. Or we need package(s) created using pkg create. to fetch and extract the binary distri- ”pkg delete” removes the speci- bution to overwrite the binary if the fied package(s) from the system. latest major distribution is available. ”pkg info” displays the package infor- For example, consider that you mation. ”pkg admin” executes man- want to install or remove only ”groff” agement tasks for the package system. on your system. We have roughly granular tar-balls 2.4 OpenBSD on NetBSD where the base system is OpenBSD package system is similar to not packaged. We download text.tgz NetBSD one. But the package utility from the ftp site and unpack it in the is written in not . Commands root directory. So software other than such as pkg add and pkg delete are the groff will be installed together. same Perl script, changes the be- Instead of using text.tgz, we havior by the called argument. can install groff from ”pkgsrc” OpenBSD users can write - (pkgsrc/textproc/groff). But bitrary package management scripts in this case, after further up- by using these Perl modules in dates, two ”groff” will be in- /usr/libdata/perl5/OpenBSD/. stalled such as in /usr/bin/groff and /usr/pkg/bin/groff. It may confuses users. Such a problem can be solved 3 Base System Pack- by packaging the base system with fine aging granularity. NetBSD had developed ”syspkg” 3.1 Base System Packaging under the same ideas described above, but its development is stagnant. Theo- There are Linux distributions manag- retically ”syspkg” can manage the base ing the base system as a collection system, but it is incomplete and not of packages. Debian Linux is a typ- used well. We can run build.sh with ical one. Debian’s ”Essential” pack- the option -syspkgs to create a com- age provides the minimum functional- piled base package, but the compiled ity required to generate a small base package cannot be installed.

3 3.2 Benefits of Base Sys- The style of ”syspkg” frame- tem Packaging work is traditional. It mainly consists of a lot of Makefiles A system packaging a base system with under usr/src/distrib/sets/ and fine granularity must has advantages to usr/src/distrib/syspkg/. It looks be- enable rapid update and flexible cus- yond our control to reconstruct the tomization of base system. current ”syspkg”. We determined that Typical examples needed for rapid it would be easier to develop another security updates in base system script that creates base packages. are some critical libraries such as Instead of traditional Makefile ”OpenSSL” and fundamental daemons style, our script is a wrapper to use such as ”OpenSSH” and ”Postfix”. pkg tools based on information in From the other point of view usr/src/distrib/sets/lists/. Currently on flexibility, it looks that demand pkg tools is used only for ”pkgsrc”, to create a small base system eas- but these tools are used for all soft- ily increases since cheap tiny devices ware in the base system if we can for sensor network are wished. For prepare proper configuration files for example, [Omega2 2016] is a pkg * tools. $5 micro computer ready for Linux and FreeBSD. Also, at CES 4.2 basepkg.sh in 2017 released a credit card size computer[Intel 2017]. But $5 must be ”basepkg.sh” creates a binary pack- too expensive to use billions of de- age based on information under vices over the world. Devices with ”usr/src/distrib/sets/lists/”. The more small storage and memory are script runs in two steps. (1) preferrable, so easily customized small prepare configuration files based on operating systems must be required. ”usr/src/distrib/sets/lists/”. (2) call pkg * tools to create packages actually.

4 Yet Another NetBSD 4.2.1 Preparation of Configura- Base System Pack- tion Files aging Files under ”usr/src/distrib/sets/lists/” contains program and configuration Instead of ”syspkg”, We have devel- paths with classified information. Our oped a ”basepkg.sh”[Enomoto 2016]. script resolves the package name based It is a just shell script simpler than on ”usr/src/distrib/sets/lists/”. ”syspkg” framework. In addition, a configuration file is necessary to create a compiled pack- age. basepkg.sh uses the following set- 4.1 problems on ”syspkg” ting files, which is same as ”pkgsrc” framework ones.

NetBSD source tree contains incom- • +BUILD INFO plete ”syspkg” framework, but its de- Information on the environment velopment is stagnant. in which the package was created

4 • +COMMENT need to find the criterion of the grad- Comment of the package uality and classification. It is also re- quired when we add a new software. • +CONTENTS Secondly, packaging should be Information on the path of the enhanced to run a hook since file to be stored in the package installation/deinstallation of shared • +DESC package needs the corre- Description of the package sponding restarting. We can use PRE-INSTALL and POST- INSTALL scripts of pkg add com- 4.2.2 Package Creation mand, but we should prepare the ”basepkg.sh” calls pkg create com- scripts, which are not covered by mand to create the corresponding com- usr/src/distrib/sets/lists/. We need piled packages in using configuration to arrange another configurations for files created above. such scripts. The created compiled package can Lastly, we need to fix the mas- be installed using the pkg add com- ter for package creation pro- mand. We can use the pkg delete com- cess. There are some empty pack- mand to remove it from the system. ages since there are not corresponding pkg info command shows information binaries in +CONTENTS. For exam- on the binary package. However, at ple, ”comp-obsolete” package contains this moment, useful information is not /usr/bin/atf-compile command, but displayed since our package does not there is no /usr/bin/atf-compile in the contain the corresponding +DESC file. binary set of NetBSD-7.0.2/amd64. We confirmed that we can in- stall compiled packages basepkg.sh cre- ates on NetBSD-7.0.2/amd64 by us- 6 Conclusion ing pkgsrc/pkgtools/pkg install ver- sion 20160410. We have developed a script ”basepkg.sh” for base system pack- aging to make NetBSD base system 5 Future Work more granular. It provides the first step for more granular NetBSD base As a result of development, it has system. turned out that difficulty of base sys- Fine granular systems become tem packaging comes from package more important for rapid update and classification rather than package cre- flexible customization of system in the ation process. future and sensor networks. Firstly, we need to investigate that We believe that our system helps one the number of packages are proper or small step for it. not. Currently ”basepkg.sh” generates 879 binary packages as classified by usr/src/distrib/sets/lists. The number Acknowledgments is almost same as one of FreeBSD base packages. But it is not clear that the I would like to thanks Ken’ichi Fuka- graduality is proper for operation. We machi, NetBSD developers and Japan

5 NetBSD Users Group. [NetBSD 2017] http://wiki.netbsd.org/projects/ References project/syspkgs/ [Omega2 2016] [FreeBSD 2017] https://www.kickstarter.com/ https://www.freebsd.org/ports/ projects/onion/ [NetBSD 2017] omega2-5-iot-computer- http://www.netbsd.org/docs/ with-wi-fi-powered-by-linux/ software/packages.html description [Debian 2017] [Intel 2017] https://www.debian.org/doc/ http://www.intel.com/content/www/us/en/ manuals/ compute-card/intel-compute- debian-reference/ch02.html card.html [FreeBSD 2017] [Enomoto 2016] https://wiki.freebsd.org/PkgBase/ https://github.com/user340/basepkg

6