From eada9a0b9c1ec9672f38a118581c4aa78dbb4617 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Sat, 10 Sep 2022 00:05:02 +0200 Subject: [PATCH] feat: run all handlers in a tempdir --- handlers/apt/install_deb | 6 +++--- handlers/arch/install_makepkg | 1 - handlers/make/install | 3 +-- instalee | 7 ++++++- packages/krew/linux | 1 - packages/logcli/script | 1 - packages/stderred/zsh | 5 +++-- packages/xkblayout-state/script | 3 +-- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/handlers/apt/install_deb b/handlers/apt/install_deb index 96c3f3e..910a0b8 100755 --- a/handlers/apt/install_deb +++ b/handlers/apt/install_deb @@ -1,10 +1,10 @@ #!/bin/sh # Install a package from a local or downloaded .deb-file and remove it -loc="/tmp/install.deb" +loc="$(basename "$arg")" case "$1" in - (http*) sudo wget -O "$loc" "$arg";; + (http*) wget -O "$loc" "$arg";; (*) loc="$arg";; esac sudo dpkg -i "$loc" sudo apt -f install -sudo rm -f "$loc" +sudo rm -v "$loc" diff --git a/handlers/arch/install_makepkg b/handlers/arch/install_makepkg index fed264b..67bb612 100755 --- a/handlers/arch/install_makepkg +++ b/handlers/arch/install_makepkg @@ -3,7 +3,6 @@ case "$1" in (*://*) url=$1;; (*) url=https://aur.archlinux.org/$1.git;; esac -cd "$(mktemp -d)" git clone "$url" cd $(basename "${1%.git}") makepkg -si diff --git a/handlers/make/install b/handlers/make/install index dc56ff5..3b00753 100755 --- a/handlers/make/install +++ b/handlers/make/install @@ -1,7 +1,6 @@ #!/bin/sh -e case $1 in -(*://*) cd "$(mktemp -d)" - git clone "$1" +(*://*) git clone "$1" cd "$(basename "${1%.git}")";; (*) cd "$1";; esac diff --git a/instalee b/instalee index 34066d5..620a4c7 100755 --- a/instalee +++ b/instalee @@ -47,12 +47,14 @@ installpkg() { set -e local name="$(basename $pkg)" local base="${name%_*}" + echo "Dependencies" for dependency in $(cat "${pkgdir}depends" "${pkgdir}${base}_depends" 2>/dev/null) - do runinstalee $dependency + do runinstalee $dependency | sed 's/^/ /' done local ext="${name#$base}" local handler="$homedir/handlers/$base" + cd $(mktemp -d --tmpdir=$execdir $pkg.XXXX) if test -d "$handler" then # This declaration needs to be ahead, otherwise it overrides failing exit codes @@ -118,6 +120,9 @@ case "$1" in ;; esac +execdir=/tmp/instalee.%(date +%s) +mkdir -p $execdir +cd $execdir runinstalee() { groupfile="$homedir/groups/$1" if test -f "$groupfile" diff --git a/packages/krew/linux b/packages/krew/linux index 3bdb0e0..fb6b1df 100755 --- a/packages/krew/linux +++ b/packages/krew/linux @@ -1,5 +1,4 @@ #!/bin/sh -ex -cd "$(mktemp -d)" OS="$(uname | tr '[:upper:]' '[:lower:]')" ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" KREW="krew-${OS}_${ARCH}" diff --git a/packages/logcli/script b/packages/logcli/script index 8535864..4666b08 100755 --- a/packages/logcli/script +++ b/packages/logcli/script @@ -1,5 +1,4 @@ #!/bin/sh -e -cd "$(mktemp -d)" git clone https://github.com/grafana/loki.git cd loki make logcli >&2 diff --git a/packages/stderred/zsh b/packages/stderred/zsh index 164bea5..f26a837 100644 --- a/packages/stderred/zsh +++ b/packages/stderred/zsh @@ -1,6 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh cd /opt git clone git://github.com/sickill/stderred.git cd stderred make -case "$LD_PRELOAD" in *libstderred.so*) ;; *) echo 'export LD_PRELOAD="/opt/stderred/build/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}"'>>$HOME/.zprofile;; esac +case "$LD_PRELOAD" in (*libstderred.so*) ;; + (*) echo 'export LD_PRELOAD="/opt/stderred/build/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}"'>>$HOME/.zprofile;; esac diff --git a/packages/xkblayout-state/script b/packages/xkblayout-state/script index abf7a89..f5cf6e4 100755 --- a/packages/xkblayout-state/script +++ b/packages/xkblayout-state/script @@ -1,5 +1,4 @@ -#!/usr/bin/env sh -cd "$(mktemp -d)" +#!/bin/sh -e git clone https://github.com/nonpop/xkblayout-state cd xkblayout-state make