### Install Example Files Source: https://docs.freebsd.org/en/books/porters-handbook/book This target installs example files into the ${EXAMPLESDIR} directory after the main installation. It copies the example files from the source directory to the staging area. ```makefile post-install-EXAMPLES-on: ${MKDIR} ${STAGEDIR}${EXAMPLESDIR} cd ${WRKSRC}/ex && ${COPYTREE_SHARE} . ${STAGEDIR}${EXAMPLESDIR} ``` -------------------------------- ### Enable and Start a FreeBSD Service Source: https://docs.freebsd.org/en/articles/rc-scripting Use these commands to enable a service to start on boot and to manually start it. This example creates a service instance named 'dummy_foo'. ```shell # ln -s dummy /usr/local/etc/rc.d/dummy_foo # sysrc dummy_foo_enable=YES # service dummy_foo start ``` -------------------------------- ### Install a Program As Superuser Source: https://docs.freebsd.org/en/books/handbook/book This example demonstrates the sequence of commands to install a program, requiring superuser privileges for the 'make install' step. Use 'su -' to become the superuser and 'exit' to return to the user account. ```shell % configure % make % su - Password: ``` -------------------------------- ### Options Variables Order Example Source: https://docs.freebsd.org/en/books/porters-handbook/order Defines options, their descriptions, and associated configuration directives. Includes custom post-install targets for installing documentation and examples. ```makefile OPTIONS_DEFINE= DOCS EXAMPLES FOO BAR OPTIONS_DEFAULT= FOO OPTIONS_RADIO= SSL OPTIONS_RADIO_SSL= OPENSSL GNUTLS OPTIONS_SUB= yes BAR_DESC= Enable bar support FOO_DESC= Enable foo support BAR_CONFIGURE_WITH= bar=${LOCALBASE} FOO_CONFIGURE_ENABLE= foo GNUTLS_CONFIGURE_ON= --with-ssl=gnutls OPENSSL_CONFIGURE_ON= --with-ssl=openssl post-install-DOCS-on: ${MKDIR} ${STAGEDIR}${DOCSDIR} cd ${WRKSRC}/doc && ${COPYTREE_SHARE} . ${STAGEDIR}${DOCSDIR} post-install-EXAMPLES-on: ${MKDIR} ${STAGEDIR}${EXAMPLESDIR} cd ${WRKSRC}/ex && ${COPYTREE_SHARE} . ${STAGEDIR}${EXAMPLESDIR} ``` -------------------------------- ### Start FreeBSD Guest Installation Source: https://docs.freebsd.org/en/books/handbook/virtualization Launch the FreeBSD guest in installation mode using vmrun.sh. This command specifies CPU count, memory, tap device, disk image, and the installation ISO. ```shell # sh /usr/share/examples/bhyve/vmrun.sh -c 1 -m 1024M -t tap0 -d guest.img \ -i -I FreeBSD-14.0-RELEASE-amd64-bootonly.iso guestname ``` -------------------------------- ### Example Package List Files Source: https://docs.freebsd.org/en/books/porters-handbook/plist These are the files installed by the port, illustrating the paths that need to be managed in the package list. ```text /usr/local/bin/machine-build /usr/local/lib/perl5/site_perl/man/man1/machine-build.1.gz /usr/local/lib/perl5/site_perl/man/man3/Machine::Build.3.gz /usr/local/lib/perl5/site_perl/Machine/Build.pm /usr/local/lib/perl5/site_perl/mach/5.20/Machine/Build/Build.so ``` -------------------------------- ### Install X.org Server Meta-Package Source: https://docs.freebsd.org/en/books/handbook/book Install the X.org server meta-package for a quick setup with fewer customization options. Users must be added to the 'video' group. ```shell pkg install xorg ``` -------------------------------- ### Simple USE_GITHUB Example Source: https://docs.freebsd.org/en/books/porters-handbook/makefiles This example shows a basic setup for `USE_GITHUB` when fetching a specific version of a package from GitHub. It automatically sets `MASTER_SITES` to `GH` and `WRKSRC`. ```makefile PORTNAME= pkg DISTVERSION= 1.2.7 USE_GITHUB= yes GH_ACCOUNT= freebsd ``` -------------------------------- ### Start X Window System Source: https://docs.freebsd.org/en/books/handbook/virtualization Execute this command in the console after installing the X Window system to launch the graphical desktop environment. ```shell % startx ``` -------------------------------- ### Install X.org Server Source: https://docs.freebsd.org/en/books/handbook/x11 Installs the complete X Window System meta-package. This includes a traditional window manager and desktop suite. Use this for a quick setup with fewer customization options. ```bash # pkg install xorg ``` -------------------------------- ### Installing GNU Info Files Source: https://docs.freebsd.org/en/books/porters-handbook/book This example shows how to declare GNU info files to be installed by a package. The `INFO` variable lists the relative paths to the info files within the `PREFIX/INFO_PATH` directory. ```makefile INFO= gcc34/cpp gcc34/cppinternals gcc34/g77 ... ``` -------------------------------- ### Launch Linux Guest VM for Installation Source: https://docs.freebsd.org/en/books/handbook/virtualization Start the bhyve virtual machine with specified configurations. This includes setting up host bridges, LPC, virtio devices for network and disk, a CD-ROM for installation, and serial console. '-c 4' specifies 4 CPU cores and '-m 1024M' allocates 1GB of RAM. ```bash # bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,tap0 \ -s 3:0,virtio-blk,./linux.img -s 4:0,ahci-cd,./somelinux.iso \ -l com1,stdio -c 4 -m 1024M linuxguest ``` -------------------------------- ### Install Configuration File with Custom Group and Permissions Source: https://docs.freebsd.org/en/books/porters-handbook/book This example demonstrates using `@sample` with only group and mode specified, omitting the owner. This is a concise way to adjust permissions when the owner does not need to be changed from the default. ```plist @sample(,games,660) etc/config.sample ``` -------------------------------- ### Implementation of @sample Keyword Source: https://docs.freebsd.org/en/books/porters-handbook/plist This example shows a real-world implementation of the '@sample' keyword. It handles file copying for samples, conditional installation, and cleanup during deinstallation. It utilizes 'file' action and 'arguments: true'. ```plist actions: [file(1)] arguments: true post-install: <` to retrieve detailed information about a specific installed package, including its version, installation date, origin, and dependencies. ```bash # pkg info pkg ``` -------------------------------- ### Build Website with make Source: https://docs.freebsd.org/en/books/fdp-primer/book Navigate to the website directory and run 'make' to build the website. ```shell % cd ~/doc/website % make __Copied! ``` -------------------------------- ### Start Alpine Source: https://docs.freebsd.org/en/books/handbook/mail Installs and starts the Alpine mail client. The first run prompts to send an anonymous email for usage statistics. ```shell % alpine ``` -------------------------------- ### Install and Run wlsunset Source: https://docs.freebsd.org/en/books/accessibility/colors Installs the wlsunset utility and provides an example of how to run it with latitude and longitude arguments for Wayland gamma adjustments. ```bash # pkg install wlsunset ``` ```bash % wlsunset -l 14.34 -L 40.55 & ``` -------------------------------- ### Use %%EXAMPLESDIR%% for Sample Configuration Files Source: https://docs.freebsd.org/en/books/porters-handbook/plist If sample configuration files are located in a directory other than the standard location, use the %%EXAMPLESDIR%% macro to specify the path to the sample file. ```makefile @sample %%EXAMPLESDIR%%/orbit.conf etc/orbit.conf ``` -------------------------------- ### Install Configuration File with Custom Ownership and Permissions Source: https://docs.freebsd.org/en/books/porters-handbook/book This example shows how to use the `@sample` keyword with arguments to specify the owner, group, and mode for a configuration file. This is useful for setting specific security or operational parameters for configuration files. ```plist @sample(games,games,640) etc/config.sample ``` -------------------------------- ### Configure XFCE Start with startx Source: https://docs.freebsd.org/en/books/handbook/desktop Set up the ~/.xinitrc file to launch XFCE when using the startx command. ```bash % echo '. /usr/local/etc/xdg/xfce4/xinitrc' > ~/.xinitrc ``` -------------------------------- ### UCL pkg-message: Simple Install Message Source: https://docs.freebsd.org/en/books/porters-handbook/pkg-files Use this format for a basic message displayed only during package installation. Ensure the file starts with '[' and ends with ']'. ```UCL [ { type: install message: "Simple message" } ] ``` -------------------------------- ### Build Installed Documentation Source: https://docs.freebsd.org/en/books/handbook//cutting-edge Navigate to the documentation source directory and execute 'make' to perform a full update of the installed documentation. ```bash # cd /usr/doc # make ``` -------------------------------- ### MS-DOS Command Example Source: https://docs.freebsd.org/en/books/handbook/preface Examples starting with C:\> indicate MS-DOS commands. These can typically be executed from a Command Prompt in modern Windows environments. ```shell C:\> tools\fdimage floppies\kern.flp A: ``` -------------------------------- ### Example /etc/fstab Configuration Source: https://docs.freebsd.org/en/articles/remote-install This is an example of the /etc/fstab file content, which defines how file systems are mounted at boot. Ensure device names and mount points are correct for your system. ```shell # Device Mountpoint FStype Options Dump Pass# /dev/mirror/swap none swap sw 0 0 /dev/mirror/root / ufs rw 1 1 /dev/mirror/usr /usr ufs rw 2 2 /dev/mirror/var /var ufs rw 2 2 /dev/cd0 /cdrom cd9660 ro,noauto 0 0 ``` -------------------------------- ### Install Wayland and seatd packages Source: https://docs.freebsd.org/en/books/handbook/wayland Installs the Wayland protocol and the seatd daemon, which provides non-root access to devices, simplifying compositor setup. ```shell # pkg install wayland seatd ``` -------------------------------- ### Example Desktop Entry Creation Source: https://docs.freebsd.org/en/books/porters-handbook/special An example demonstrating the creation of a desktop entry for a game, including its name, comment, icon path, command-line arguments, categories, and startup notification setting. ```makefile DESKTOP_ENTRIES= "ToME" "Roguelike game based on JRR Tolkien's work" \ "${DATADIR}/xtra/graf/tome-128.png" \ "tome -v -g" "Application;Game;RolePlaying;" \ false ``` -------------------------------- ### Start FreeBSD Guest from Disk Source: https://docs.freebsd.org/en/books/handbook/virtualization Start the FreeBSD guest from its virtual disk after installation. This command configures 4 virtual CPUs and 1024MB of memory. ```shell # sh /usr/share/examples/bhyve/vmrun.sh -c 4 -m 1024M -t tap0 -d guest.img guestname ``` -------------------------------- ### Start Plasma via ~/.xinitrc Source: https://docs.freebsd.org/en/books/handbook/desktop Configure ~/.xinitrc to start Plasma in an Xorg session by manually invoking startx. ```shell % echo "exec dbus-launch --exit-with-x11 ck-launch-session startplasma-x11" > ~/.xinitrc ``` -------------------------------- ### Start Linux VM Installation with grub2-bhyve Source: https://docs.freebsd.org/en/books/handbook/virtualization Initiate the Linux guest startup process using grub-bhyve. This command loads the GRUB bootloader, mapping devices and specifying memory for the VM. The '-r cd0' option indicates booting from the CD-ROM. ```bash # grub-bhyve -m device.map -r cd0 -M 1024M linuxguest ``` -------------------------------- ### Example pkg-plist File Content Source: https://docs.freebsd.org/en/books/porters-handbook/quick-porting This file lists all files installed by a port, with paths relative to the installation prefix. It's used to generate the package. ```text bin/oneko man/man1/oneko.1.gz lib/X11/app-defaults/Oneko lib/X11/oneko/cat1.xpm lib/X11/oneko/cat2.xpm lib/X11/oneko/mouse.xpm ``` -------------------------------- ### Start racoon daemon Source: https://docs.freebsd.org/en/articles/vpn-ipsec Command to start the racoon IPsec daemon in the foreground, specifying the configuration file and log file. This is useful for debugging during setup. ```shell # /usr/local/sbin/racoon -F -f /usr/local/etc/racoon/racoon.conf -l /var/log/racoon.log ``` -------------------------------- ### Start First VM (left) Source: https://docs.freebsd.org/en/books/handbook/book Script to launch the first QEMU virtual machine named 'left' using raw disk format. Ensure the ISO and VM image paths are correct. ```shell /usr/local/bin/qemu-system-x86_64 -monitor none \ -cpu qemu64 \ -vga std \ -m 4096 \ -smp 4 \ -cdrom ../ISO/fbsd.iso \ -boot order=cd,menu=on \ -blockdev driver=file,aio=threads,node-name=imgleft,filename=../VM/left.img \ -blockdev driver=raw,node-name=drive0,file=imgleft \ -device virtio-blk-pci,drive=drive0,bootindex=1 \ -netdev tap,id=nd0,ifname=tap0,script=no,downscript=no,br=bridge0 \ -device e1000,netdev=nd0,mac=02:20:6c:65:66:74 \ -name "left" ``` -------------------------------- ### Install Linux Userland with Package Manager Source: https://docs.freebsd.org/en/books/handbook/linuxemu When installing Linux software from the Ports tree using pkg(8), the required Linux userland is automatically set up. This example shows installing Sublime Text 4. ```shell pkg install sublime-text ``` -------------------------------- ### Install MATE Desktop Meta Package Source: https://docs.freebsd.org/en/books/handbook/desktop Install the MATE Desktop Environment along with a selection of common applications. ```bash # pkg install mate ``` -------------------------------- ### Install a Port with Clean Source: https://docs.freebsd.org/en/books/handbook/ports Compile and install a port, then clean up build artifacts. This is an alternative to running `make clean` separately. ```shell # make install clean ``` -------------------------------- ### Start Sway Compositor Source: https://docs.freebsd.org/en/books/handbook/wayland Launches the Sway compositor using a specified configuration file. Useful for testing changes before full migration. ```bash % sway -c ~/.config/sway/config ``` -------------------------------- ### Get ISA Resource Start and Count Source: https://docs.freebsd.org/en/books/arch-handbook/isa Convenience functions to retrieve only the start address or the count of a resource. Returns 0 on error, which can be ambiguous if 0 is a valid value. ```c u_long bus_get_resource_start(device_t dev, int type, int rid) ``` ```c u_long bus_get_resource_count(device_t dev, int type, int rid) ``` -------------------------------- ### Install and Configure Avahi for Zero-configuration Networking Source: https://docs.freebsd.org/en/books/handbook/book Install the Avahi application and nss_mdns for zeroconf support, update nsswitch.conf to include mdns, and enable and start the dbus and avahi-daemon services. ```bash # pkg install avahi-app nss_mdns # grep -q '^hosts:.*' /etc/nsswitch.conf || sed -i "" 's/^hosts: .*/& mdns/' /etc/nsswitch.conf # service dbus enable # service avahi-daemon enable # service dbus start # service avahi-daemon start ``` -------------------------------- ### Describing OPTIONS Source: https://docs.freebsd.org/en/books/porters-handbook/makefiles This example provides descriptions for build options. It's recommended to describe what functionality each option changes from the user's perspective. ```makefile OPT1_DESC= Describe OPT1 OPT2_DESC= Describe OPT2 OPT3_DESC= Describe OPT3 OPT4_DESC= Describe OPT4 OPT5_DESC= Describe OPT5 OPT6_DESC= Describe OPT6 ``` -------------------------------- ### FreeBSD Superuser Command Example Source: https://docs.freebsd.org/en/books/handbook/preface Examples starting with # indicate commands that must be run as the superuser in FreeBSD. You can log in as root or use su(1) to gain superuser privileges. ```shell # dd if=kern.flp of=/dev/fd0 ``` -------------------------------- ### Get Resource Range Source: https://docs.freebsd.org/en/books/arch-handbook/book Retrieves the start and end addresses of an allocated resource range. ```c u_long rman_get_start(r) u_long rman_get_end(r) ```