dot

packages and services management
Log | Files | Refs | README

commit 6defb0ee789310f15722b2f41eee2a1b903990e4
parent 98c290ff2cb37c1312cae8a01a4bb5ce2804461a
Author: Josuah Demangeon <mail@josuah.net>
Date:   Thu,  9 Aug 2018 01:44:45 +0200

split pack into separate commands

Diffstat:
Mbin/pack | 106+++++++++++++++----------------------------------------------------------------
Abin/pack-add | 16++++++++++++++++
Abin/pack-build | 12++++++++++++
Mbin/pack-chroot | 4++--
Abin/pack-cvs | 8++++++++
Abin/pack-del | 6++++++
Abin/pack-get | 7+++++++
Abin/pack-git | 6++++++
Abin/pack-tar | 17+++++++++++++++++
Abin/pack-up | 6++++++
Apack/ttg/build | 3+++
Apack/ttg/git | 1+
Apack/ttg/version | 1+
13 files changed, 105 insertions(+), 88 deletions(-)

diff --git a/bin/pack b/bin/pack @@ -1,91 +1,25 @@ -#!/bin/sh -e -# source-based package manager that fetches compile and install +pack - Source-based package manager that fetches compile and install -# <version> - numeric version number of a package. "git" or "cvs" -# can be used anywhere to describe a git or cvs source repo. -# -# /etc/pack/<package>/git - file with one line with the url of -# the remote git repository -# -# /etc/pack/<package>/git - file with one line with the url of -# the remote cvs repository followed with the path to -# the source tree -# -# /etc/pack/<package>/tar - file with one line with the url of -# the tar archive, with '%s' in place of the version -# -# /etc/pack/<package>/version - file with one version per line, most -# recent last. -# -# /src/<package>/<version> - source files of <package> at a given -# <version>. -# -# /opt/<package>/<version> - files installed by <package> at a given -# <version>. -# -# /opt/<package> - symlink to the current version +<version> - numeric version number of a package. "git" or "cvs" + can be used anywhere to describe a git or cvs source repo. -export PACK=/etc/pack/$2 +/etc/pack/<package>/git - file with one line with the url of + the remote git repository -test "$1" = -v && - export VERSION=$2 && shift 2 || - export VERSION=$(tail -n 1 "$PACK/version") +/etc/pack/<package>/git - file with one line with the url of + the remote cvs repository followed with the path to + the source tree -export PREFIX=/opt/$2/$VERSION +/etc/pack/<package>/tar - file with one line with the url of + the tar archive, with '%s' in place of the version -case $1 in -(tar) test -d "/src/$2/$VERSION" && exit 0 - mkdir -p "/src/$2/$VERSION" - url=$(awk -v v="$VERSION" 'gsub("%s", v) || 1' "$PACK/tar") - wget -O - "$url" | case $url in - (*.tgz|*.tar.gz) gzip -d - ;; - (*.tbz|*.tar.bz2) bzip2 -d - ;; - (*.txz|*.tar.xz) xz -d - ;; - (*.tlz|*.tar.lz) lzip -d - ;; - esac | tar -xf - -C "/src/$2/$VERSION" || - exec rm -rf "/src/$2/$VERSION" - mv "/src/$2/$VERSION"/*/* "/src/$2/$VERSION" - rmdir "/src/$2/$VERSION"/* 2>/dev/null || true - ;; -(git) test -d "/src/$2/git" && exit 0 - IFS="" read -r url <$PACK/git - git clone "$url" "/src/$2/git" - ;; -(cvs) test -d "/src/$2/cvs" && exit 0 - mkdir -p "/src/$2/cvs" - cd "/src/$2/cvs" - read -r url path <$PACK/cvs - cvs -qd "$url" checkout -P "$path" - ;; -(get) printf '\033[1m[ downloading %s ]\033[m\n' "$2" - test -f "$PACK/tar" && exec "$0" tar "$2" - test -f "$PACK/git" && exec "$0" git "$2" - test -f "$PACK/cvs" && exec "$0" cvs "$2" - ;; -(build) test -d "/src/$2/$VERSION" || "$0" get "$2" - printf '\033[1m[ building %s ]\033[m\n' "$2" - cd "/src/$2/$VERSION" - mkdir -p "$PREFIX" - exec "$PACK/build" - ;; -(add) test -f "$PACK/dep" && xargs -n 1 "$0" add <$PACK/dep - test -d "$PREFIX" || "$0" build "$2" || { rm -rf "$PREFIX"; exit 1; } - printf '\033[1m[ installing %s ]\033[m\n' "$2" - ln -sf "$VERSION" "/opt/$2/$VERSION/cur" - mv -f "/opt/$2/$VERSION/cur" /opt/$2 - cd "/opt/$2/cur" - find -L * -type d -exec sh -c 'mkdir -p "/local/$0"' {} \; - find -L * -type f -exec sh -c 'ln -sf "/opt/$1/cur/$0" "/local/$0"' {} "$2" \; - ;; -(del) printf '\033[1m[ deleting %s ]\033[m\n' "$2" - cd "$PREFIX" - find * -type f -o -type l -exec sh -c 'rm -f "/local/$0"' {} \; - rm -rf "$PREFIX" - ;; -(up) "$0" del "$2" - rm -rf "/src/$2" - "$0" add "$2" - ;; -(*) echo 'usage: pack {tar,git,cvs,get,build,add,up} package' - ;; -esac +/etc/pack/<package>/version - file with one version per line, most + recent last. + +/src/<package>/<version> - source files of <package> at a given + <version>. + +/opt/<package>/<version> - files installed by <package> at a given + <version>. + +/opt/<package> - symlink to the current version diff --git a/bin/pack-add b/bin/pack-add @@ -0,0 +1,16 @@ +#!/bin/sh -e +# build a program into /opt/<package>/<version> and symlink it into /local + +export VERSION=$(tail -n 1 "/etc/pack/$1/version") + +test -f "/etc/pack/$1/dep" && xargs -n 1 pack-add </etc/pack/$1/dep +test -d "/opt/$1/$VERSION" || pack-build "$1" || { + rm -rf "/opt/$1/$VERSION" + exit 1 +} +printf '\033[1m[ installing %s ]\033[m\n' "$1" +ln -sf "$VERSION" "/opt/$1/$VERSION/cur" +mv -f "/opt/$1/$VERSION/cur" "/opt/$1" +cd "/opt/$1/cur" +find -L * -type d -exec sh -c 'mkdir -p "/local/$0"' {} \; +find -L * -type f -exec sh -c 'ln -sf "/opt/$1/cur/$0" "/local/$0"' {} "$1" \; diff --git a/bin/pack-build b/bin/pack-build @@ -0,0 +1,12 @@ +#!/bin/sh -e +# build a source from /src/<package>/<version> into /opt/<package>/<version> + +export VERSION=$(tail -n 1 "/etc/pack/$1/version") +export PACK=/etc/pack/$1 +export PREFIX=/opt/$1/$VERSION + +test -d "/src/$1/$VERSION" || pack-get "$1" +printf '\033[1m[ building %s ]\033[m\n' "$1" +cd "/src/$1/$VERSION" +mkdir -p "$PREFIX" +exec "/etc/pack/$1/build" diff --git a/bin/pack-chroot b/bin/pack-chroot @@ -12,8 +12,8 @@ mkdir -p etc/pack bin dev # # Resources used for bootstraping # -pack add busybox -pack add dash +pack-add busybox +pack-add dash CC="$(readlink -f "$(command -v cc)")" cp "$CC" bin/"$(basename "$CC")" ln -s "$(basename "$CC")" bin/cc diff --git a/bin/pack-cvs b/bin/pack-cvs @@ -0,0 +1,8 @@ +#!/bin/sh -e +# download a cvs repository into /src/<package>/cvs + +test -d "/src/$1/cvs" && exit 0 +mkdir -p "/src/$1/cvs" +cd "/src/$1/cvs" +read -r url path </etc/pack/$1/cvs +cvs -qd "$url" checkout -P "$path" diff --git a/bin/pack-del b/bin/pack-del @@ -0,0 +1,6 @@ +#!/bin/sh -e + +printf '\033[1m[ deleting %s ]\033[m\n' "$1" +cd /opt/$1/cur +find * -type f -o -type l -exec sh -c 'rm -f "/local/$0"' {} \; +rm -rf /opt/$1 diff --git a/bin/pack-get b/bin/pack-get @@ -0,0 +1,7 @@ +#!/bin/sh -e +# get a package's source from either tar, git, cvs + +printf '\033[1m[ downloading %s ]\033[m\n' "$1" +test -f "/etc/pack/$1/tar" && exec pack-tar "$1" +test -f "/etc/pack/$1/git" && exec pack-git "$1" +test -f "/etc/pack/$1/cvs" && exec pack-cvs "$1" diff --git a/bin/pack-git b/bin/pack-git @@ -0,0 +1,6 @@ +#!/bin/sh -e +# download a git repository into /src/<package>/git + +test -d "/src/$1/git" && exit 0 +IFS="" read -r url </etc/pack/$1/git +git clone "$url" "/src/$1/git" diff --git a/bin/pack-tar b/bin/pack-tar @@ -0,0 +1,17 @@ +#!/bin/sh -e +# download a tar source package into a /opt/<pakage>/<version> + +export VERSION=$(tail -n 1 "/etc/pack/$1/version") + +test -d "/src/$1/$VERSION" && exit 0 +mkdir -p "/src/$1/$VERSION" +url=$(awk -v v="$VERSION" 'gsub("%s", v) || 1' "/etc/pack/$1/tar") +wget -O - "$url" | case $url in +(*.tgz|*.tar.gz) gzip -d - ;; +(*.tbz|*.tar.bz2) bzip2 -d - ;; +(*.txz|*.tar.xz) xz -d - ;; +(*.tlz|*.tar.lz) lzip -d - ;; +esac | tar -xf - -C "/src/$1/$VERSION" || + exec rm -rf "/src/$1/$VERSION" +mv "/src/$1/$VERSION"/*/* "/src/$1/$VERSION" +rmdir "/src/$1/$VERSION"/* 2>/dev/null || true diff --git a/bin/pack-up b/bin/pack-up @@ -0,0 +1,6 @@ +#!/bin/sh -e +# delete and install a package again + +pack-del "$1" +rm -rf "/src/$1" +pack-add "$1" diff --git a/pack/ttg/build b/pack/ttg/build @@ -0,0 +1,3 @@ +#!/bin/sh -ex + +make diff --git a/pack/ttg/git b/pack/ttg/git @@ -0,0 +1 @@ +git://josuah.net/ttg diff --git a/pack/ttg/version b/pack/ttg/version @@ -0,0 +1 @@ +git