Skip to content

Instantly share code, notes, and snippets.

@vtorri
Last active October 13, 2022 04:02
Show Gist options
  • Save vtorri/d1d78062795832403e334a132bad702f to your computer and use it in GitHub Desktop.
Save vtorri/d1d78062795832403e334a132bad702f to your computer and use it in GitHub Desktop.
OpenIndiana: create a package with oi-userland

Creating Samurai package for OpenIndiana

Samurai is a C99 implementation of ninja, with no dependency. This document tries to explain, step by step, how to create an OpenIndiana package for Samurai.

This document is based on this OpenIndiana documentation, and my own experimentation, with the help of developpers on IRC (channel #openindianaon libera.chat).

OpenIndiana provides a git repository, named oi-userland, on github to make such creation easier.

Before creating the package, user rbac role should be set, as well as common build tools:

sudo usermod -P'Software Installation' vtorri
sudo pkg install build-essential

Step 1: fork the oi-userland github repository

Once forked, clone your oi-userland repository, then enter in your oi-userland directory, and :

git remote add upstream https://github.com/OpenIndiana/oi-userland.git
git fetch upstream
git merge upstream/oi/hipster
git push

Step 2: Create the needed files

2 files are needed: a Makefile and the license file. They must be placed in a samurai subdirectory correctly located. ninja is in components/developer. So place the files in the same location. After Step 1.:

  1. enter the directory components/developer,
  2. create there the subdirectory samurai,
  3. enter this subdirectory.

We first create the Makefile, based on the ninja one. It needs some informations about the package, and the source code as tarball. Here it is:

#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"). You may
# only use this file in accordance with the terms of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2022 Vincent Torri
#
BUILD_BITS=64
BUILD_STYLE=justmake

include ../../../make-rules/shared-macros.mk

COMPONENT_NAME=           samurai
COMPONENT_VERSION=        1.2
COMPONENT_SUMMARY=        samurai is a ninja-compatible build tool written in C99
COMPONENT_PROJECT_URL=    https://git.sr.ht/~mcf/samurai
COMPONENT_SRC=            $(COMPONENT_NAME)-$(COMPONENT_VERSION)
COMPONENT_ARCHIVE=        $(COMPONENT_SRC).tar.gz
COMPONENT_ARCHIVE_URL=    https://git.sr.ht/~mcf/samurai/archive/$(COMPONENT_VERSION).tar.gz
COMPONENT_ARCHIVE_HASH=
COMPONENT_FMRI=           developer/build/samurai
COMPONENT_CLASSIFICATION= Development/Distribution Tools
COMPONENT_LICENSE=        Apache 2.0

include $(WS_MAKE_RULES)/common.mk

COMPONENT_BUILD_ENV += CC=$(CC)
COMPONENT_BUILD_ARGS += CC=$(CC)
COMPONENT_INSTALL_ARGS += PREFIX=/usr DESTDIR=$(PROTO_DIR)

The beginning of the Makefile is some informations about the package (name, version, description, home page, source archive). I have left the sha256 key (COMPONENT_ARCHIVE_HASH) empty. It will be filled in the next section.

The second needed file is the license, named generally $(COMPONENT_NAME).license ($(COMPONENT_NAME) value is in the Makefilefile above), that is, samurai.license. So just copy the LICENSE file of samurai in the directory and rename it accordingly.

Step 3: create the package

  1. Download the package

in the samurai directory, just type

gmake download

As the sha256 keyvalue is empty, the Makefile displays its value. Now fill the COMPONENT_ARCHIVE_HASH variable with this value (it begins with sha256:). For the version 1.2 of samurai, the variable must be filled as is:

COMPONENT_ARCHIVE_HASH=sha256:37a2d9f35f338c53387eba210bab7e5d8abe033492664984704ad84f91b71bac
  1. Apply patches.

This step is ignored for samurai, as there is no patch.

  1. Build the package

Type:

gmake build
  1. Install the package

Type:

gmake install
  1. Generate the IPS manifest

Simply type:

gmake sample-manifest

This creates a subdirectory manifests/ with in it the file sample-manifest.p5m. Copy this file in the samurai directory and rename it to $(COMPONANT_NAME).p5m, that is, samurai.p5m:

cp manifests/sample-manifest.p5m samurai.p5m

Edit it to set you name (around line 13, after the copyright comment). Once it is done, run the following command to automatically add to Makefile a list of run-time dependencies:

gmake REQUIRED_PACKAGES
  1. Setup

Run the setup target in git root repostory, then return to the samurai directory:

cd ../../..
gmake setup
cd components/developer/samurai
  1. Publish the package

Publish the package:

sudo gmake publish
@Toasterson
Copy link

After that the only thing missing is gmake publish and to make a PR and implement the feedback :) Will be happy to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment