mypkg

command module
v0.0.0-...-2149106 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2025 License: MIT Imports: 1 Imported by: 0

README

mypkg

mypkg is a simple tool that helps managing application build, installation and removal lifecycle.

mypkg is one of my first GoLang project that I didn't imagine I would need to use today! Started it as a discovery project to learn GoLang several years ago when I needed to compile applications in a restricted environment while wanting to keep track every file installed by the simple make install of tarballs.

Build/Install

git clone https://github.com/iisteev/mypkg.git
cd mypkg && make build

Compiled binary would be in dist directory

Or you can directly install it with:

# Assuming that you're at the root of this project
make install

Config

Bellow is a simple configuration file to be configured in ~/.mypkg.yaml file

Gnu/Linux

myuser should be replaced by your username

prefix: /home/myuser/.opt/usr
installDir: /home/myuser/mypkg/install
buildDir: /home/myuser/mypkg/build
installDBDir: /home/myuser/mypkg/packages
environment:
   - export PATH=${PATH}
   - export CONF_OPTS="--prefix=${PREFIX} --infodir=${PREFIX}/share/info/${PKG_NAME}"
   - export NBJOBS=$(getconf _NPROCESSORS_ONLN)
   - export CFLAGS="-I${PREFIX}/include"
   - export CXXFLAGS="-I${PREFIX}/include"
   - export LDFLAGS="-L${PREFIX}/lib"
   - export PKG_CONFIG_PATH=${PREFIX}/lib/pkg-config
   - export LIBTOOL=llibtool
   - export LIBTOOLIZE=llibtoolize
   - export DYLD_LIBRARY_PATH=${PREFIX}/lib
   - export PKG_CONFIG=${PREFIX}/bin/pkg-config
   - export INSTALL_BIN_DIR=${INSTALL_DIR}/${PREFIX}/bin
dbDir: /home/myuser/.opt/mypkg/packages

MacOS

myuser should be replaced by your username

prefix: /home/myuser/.opt/usr
installDir: /home/myuser/mypkg/install
buildDir: /home/myuser/mypkg/build
installDBDir: /home/myuser/mypkg/packages
environment:
   - export PATH=${PATH}
   - export CONF_OPTS="--prefix=${PREFIX} --infodir=${PREFIX}/share/info/${PKG_NAME}"
   - export NBJOBS=$(getconf _NPROCESSORS_ONLN)
   - export CFLAGS="-I${PREFIX}/include"
   - export CXXFLAGS="-I${PREFIX}/include"
   - export LDFLAGS="-framework CoreFoundation -framework Carbon -L${PREFIX}/lib"
   - export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
   - export LIBTOOL=llibtool
   - export LIBTOOLIZE=llibtoolize
   - export DYLD_LIBRARY_PATH=${PREFIX}/lib
   - export PKG_CONFIG=${PREFIX}/bin/pkg-config
dbDir: /home/myuser/.opt/mypkg/packages

How it works?

mypkg uses a package/tarball/whatever you would call it, as a reference to see how to handle an app.

Basically it tells from when to download the source, how to build it, how to install it and then create an archived file that contains built app with few metadata useful to install it later.

The package file format was inspired from solus/ypkg

Here is an example:

# Name of the app
name     : htop
# Version of the app
version  : 3.0.5
# Release or the build number
release  : 1
# Home page of the app
homePage : https://htop.dev/
# License of the app
licence  : GPL-2.0-or-later
# Source section contains info from where to download it
source   :
  uri: https://github.com/htop-dev/htop/archive/3.0.5.tar.gz
  sha256: 4c2629bd50895bd24082ba2f81f8c972348aa2298cc6edc6a21a7fa18b73990c
# Setup section is run first to setup things before building it
setup    :
  # Note this is for macos, might not work for gnu/linux
  - sed -i .bak.sh s/glibtoolize/llibtoolize/g ./autogen.sh
  - ./autogen.sh
  - $configure
# build section is run after the setup
build    :
  - $make
# Install section handles installing the app in a temporary installation structure in order to prepare it for archive
install  :
  - $make_install

setup, build and install sections accepts any shell command available in your environment. But also, they provide macros (e.g $configure, $make and $make_install) which are predefined commands based on the environment.

macros are available in pkg/mpkg/utils.go file

Another example:

---
# Name of the app
name     : helm
# Version Of the app
version  : 3.17.4
# Release or the build number
release  : 1
# Source section contains info from where to download it
source   :
  uri: https://get.helm.sh/helm-v3.17.4-linux-amd64.tar.gz
  sha256: c91e3d7293849eff3b4dc4ea7994c338bcc92f914864d38b5789bab18a1d775d
# Install section on how to install it
install  :
  - mkdir -p $INSTALL_BIN_DIR
  - install $PKG_BUILD_DIR/helm $INSTALL_BIN_DIR/helm

Documentation

Overview

Copyright © 2022 Isteevan Shetoo <isteevan.shetoo@is-info.fr>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL