dot

packages and services management
Log | Files | Refs | README

commit 2119b1446f3184b18fd4c3dc88b77775349d14ee
parent 7e9f4ca58a103b523265dc2af5f1137c9f9f69cc
Author: Josuah Demangeon <mail@josuah.net>
Date:   Mon, 27 Aug 2018 21:24:37 +0200

pack: resolve symlinks

Diffstat:
Mbin/pack-add | 4++++
Mbin/pack-build | 2++
Mbin/pack-cvs | 7++++---
Mbin/pack-git | 3++-
Mbin/pack-tar | 13+++++++++----
Dpack/pack | 2--
6 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/bin/pack-add b/bin/pack-add @@ -1,9 +1,13 @@ #!/bin/sh -e # build a program into /opt/<package>/<version> and symlink it into /local +set -- "$(readlink -f "/etc/pack/$1" | sed -r 's,.*/([^/]+/[^/]+)$,\1,')" test -f "/etc/pack/$1/dep" && xargs -n 1 pack-add </etc/pack/$1/dep test -d "/opt/$1" || pack-build "$1" || { rm -rf "/opt/$1"; exit 1; } printf '\033[1m[ installing %s ]\033[m\n' "$1" cd "/opt/$1" +ln -sf "/opt/$1" "/opt/cur" +set -- "$(dirname "$1")/cur" +mv -f "/opt/cur" "/opt/$1" find -L * -type d -exec sh -c 'mkdir -p "/local/$0"' {} \; find -L * -type f -exec sh -c 'ln -sf "/opt/$1/$0" "/local/$0"' {} "$1" \; diff --git a/bin/pack-build b/bin/pack-build @@ -4,7 +4,9 @@ export PACK=/etc/pack/$1 export PREFIX=/opt/$1 +set -- "$(readlink -f "/etc/pack/$1" | sed -r 's,.*/([^/]+/[^/]+)$,\1,')" test -d "/src/$1" || pack-get "$1" + printf '\033[1m[ building %s ]\033[m\n' "$1" cd "/src/$1" mkdir -p "$PREFIX" diff --git a/bin/pack-cvs b/bin/pack-cvs @@ -1,8 +1,9 @@ #!/bin/sh -e # download a cvs repository into /src/<package>/cvs -test -d "/src/$1" && exit 0 +set -- "$(readlink -f "/etc/pack/$1" | sed -r 's,.*/([^/]+/[^/]+)$,\1,')" +test -d "/src/$1" && exec echo "$1" already checked out +read -r url path </etc/pack/$1/cvs mkdir -p "/src/$1" cd "/src/$1" -read -r url path </etc/pack/$1/cvs -exec cvs -qd "$url" checkout -P "$path" +cvs -qd "$url" checkout -P "$path" || { rm -rf "$path"; exit 1; } diff --git a/bin/pack-git b/bin/pack-git @@ -1,6 +1,7 @@ #!/bin/sh -e # download a git repository into /src/<package>/git +set -- "$(readlink -f "/etc/pack/$1" | sed -r 's,.*/([^/]+/[^/]+)$,\1,')" test -d "/src/$1" && exit 0 -IFS="" read -r url </etc/pack/$1/git +IFS= read -r url </etc/pack/$1/git exec git clone "$url" "/src/$1" diff --git a/bin/pack-tar b/bin/pack-tar @@ -1,14 +1,19 @@ #!/bin/sh -e # download a tar source package into a /opt/<pakage>/<version> -test -d "/src/$1" && exit 0 -mkdir -p "/src/$1" +set -- "$(readlink -f "/etc/pack/$1" | sed -r 's,.*/([^/]+/[^/]+)$,\1,')" +test ! -d "/src/$1" || exec echo "$1" already downloaded IFS='' read -r url </etc/pack/$1/tar + +mkdir -p "$(dirname "/tar/$1")" 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" || { rm -rf "/src/$1"; exit 1; } +esac >/tar/$1.tar || { rm -f "/tar/$1.tar"; exit 1; } + +mkdir -p "/src/$1" +tar -xf "/tar/$1.tar" -C "/src/$1" || { rm -rf "/src/$1"; exit 1; } mv "/src/$1"/*/* "/src/$1" -rmdir "/src/$1"/* 2>/dev/null || true +! rmdir "/src/$1"/* 2>/dev/null diff --git a/pack/pack b/pack/pack @@ -1 +0,0 @@ -/root/conf/pack- \ No newline at end of file