Core OS Index

1.3. Ports

This instructions are done inside chroot.

1.3.1. Build as user

For more information read Fakeroot Ports. Add a user that will be used by ports tools, this example pkgmk;

        # useradd -U -M -d /usr/ports -s /bin/false pkgmk
        

You can add your self to group pkgmk. Check if members of this group are under tpe protection.

        # usermod -a -G pkgmk c9admin
        
        # chmod -R 774 /usr/ports
        # chmod 775    /usr/ports
        

1.3.2. Ports Layout

This configuration will build and save files inside home directory of the user pkgmk. Work directory will be mounted on ram to speed up the build process and added to fstab. Let's start by creating layout directories

        # sudo -u pkgmk mkdir /usr/ports/distfiles
        # sudo -u pkgmk mkdir /usr/ports/packages
        # sudo -u pkgmk mkdir /usr/ports/work
        # sudo -u pkgmk mkdir /usr/ports/pkgbuild
        

Configure to compile in ram average of 3GB is recommended for core while firefox need at least 30G. Discover id of pkgmk user;

        # id pkgmk
        uid=102(pkgmk) gid=102(pkgmk) groups=102(pkgmk)
        

Edit fstab, change uid to id of pkgmk, this example 102;

        pkgmk /usr/ports/work tmpfs size=30G,uid=102,defaults,mode=0750 0 0
        

1.3.3. Configure pkgmk

Read 4.5. Adjust/Configure the Package Build Process to take advantage of your specific hardware. Packages build with native flag will not run on different hardware. This is the best choice if you want gcc to find the best settings based on your hardware.

Edit /etc/pkgmk.conf, remove pipe from compiler flags and let the system get from nproc how many cpu's it can use for compiling;

        #
        # /etc/pkgmk.conf: pkgmk(8) configuration
        #

        export CFLAGS="-O2 -march=x86-64"
        export CXXFLAGS="${CFLAGS}"

        # export MAKEFLAGS="-j$(nproc)"

        case ${PKGMK_ARCH} in
                "64"|"")
                        ;;
                "32")
                        export CFLAGS="${CFLAGS} -m32"
                        export CXXFLAGS="${CXXFLAGS} -m32"
                        export LDFLAGS="${LDFLAGS} -m32"
                        export PKG_CONFIG_LIBDIR="/usr/lib32/pkgconfig"
                        ;;
                *)
                        echo "Unknown architecture selected! Exiting."
                        exit 1
                        ;;
        esac

        # PKGMK_SOURCE_MIRRORS=()
        # PKGMK_SOURCE_DIR="$PWD"
        # PKGMK_PACKAGE_DIR="$PWD"
        # PKGMK_WORK_DIR="$PWD/work"
        # PKGMK_DOWNLOAD="no"
        # PKGMK_IGNORE_SIGNATURE="no"
        # PKGMK_IGNORE_MD5SUM="no"
        # PKGMK_IGNORE_FOOTPRINT="no"
        # PKGMK_IGNORE_NEW="no"
        # PKGMK_NO_STRIP="no"
        # PKGMK_DOWNLOAD_PROG="wget"
        # PKGMK_WGET_OPTS=""
        # PKGMK_CURL_OPTS=""
        # PKGMK_COMPRESSION_MODE="gz"

        # End of file
        

If you want native build change the above example to;

        export CFLAGS="-O2 -march=native -mtune=native"
        

Check toolchain for more options on how packages are build.

1.3.4. Configure prt-get

Edit /etc/prt-get.conf;

        ###
        ### prt-get conf
        ###

        # note: the order matters: the package found first is used
        prtdir /usr/ports/core

        # ports described on this documentation
        prtdir /usr/ports/c9-ports

        # 6c37 team provides a collection with freetype-iu, fontconfig-iu
        # and cairo-iu ports.
        prtdir /usr/ports/6c37
        prtdir /usr/ports/6c37-dropin

        prtdir /usr/ports/opt
        prtdir /usr/ports/xorg

        # the following line enables the multilib compat-32 collection
        #prtdir /usr/ports/compat-32

        # the following line enables the user maintained contrib collection
        prtdir /usr/ports/contrib

        ### use mypackage form local directory
        # prtdir /home/packages/build:mypackage

        ### log options:
        writelog enabled         # (enabled|disabled)
        logmode  overwrite       # (append|overwrite)
        rmlog_on_success yes     # (no|yes)
        logfile  /usr/ports/pkgbuild/%n-%v-%r.log
                                   # path, %p=path to port dir, %n=port name
                                   #       %v=version, %r=release

        ### use alternate cache file (default: /var/lib/pkg/prt-get.cache
        # cachefile /mnt/nfs/cache

        ### print README information:
        readme verbose           # (verbose|compact|disabled)

        ### prefer higher versions in sysup / diff
        preferhigher yes      # (yes|no)

        ### use regexp search
        # useregex no        # (yes|no)

        ### run pre- and post-installs scripts; yes is equivalent to the
        ### --install-scripts option
        runscripts yes            # (no|yes)


        ### EXPERT SECTION ###

        ### alternative commands
        makecommand      sudo -H -u pkgmk -g pkgmk fakeroot pkgmk
        addcommand       sudo pkgadd
        removecommand    sudo pkgrm
        runscriptcommand sudo sh
        
Core OS Index

This is part of the c9-doc Manual. Copyright (C) 2016 c9 team. See the file Gnu Free Documentation License for copying conditions.