Compare commits
No commits in common. "622dec4827cdf40b3728e281d70117261f202b1e" and "c5215c814dda383c15425ca6568fb3f6345c2240" have entirely different histories.
622dec4827
...
c5215c814d
89
brick.sh
89
brick.sh
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
# settings
|
# settings
|
||||||
set -e
|
set -e
|
||||||
start_time=$(date +%s)
|
|
||||||
|
|
||||||
# functions
|
# functions
|
||||||
errcho() {
|
errcho() {
|
||||||
|
@ -61,34 +60,6 @@ user_confirm() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
bricksenv() {
|
|
||||||
echo "export BRICKS_DIR=$BRICKS_DIR"
|
|
||||||
echo "export BRICKS_DB=$BRICKS_DB"
|
|
||||||
echo "export AUTOMATIC=$AUTOMATIC"
|
|
||||||
}
|
|
||||||
|
|
||||||
tmpdir() {
|
|
||||||
if ! [ -f $BRICKS_DIR/.tmp ]; then
|
|
||||||
mkdir -p $BRICKS_DB/.tmp
|
|
||||||
fi
|
|
||||||
echo $BRICKS_DB/.tmp
|
|
||||||
}
|
|
||||||
|
|
||||||
# checking that brick's dependencies are installed
|
|
||||||
BRICK_DEPS=(curl)
|
|
||||||
NO_DEPS=()
|
|
||||||
for dep in ${BRICK_DEPS[@]}; do
|
|
||||||
if ! command -v $dep > /dev/null; then
|
|
||||||
NO_DEPS=(${NO_DEPS[@]} $dep)
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if ! [ "${#NO_DEPS[@]}" == "0" ]; then
|
|
||||||
errcho 'Error!'
|
|
||||||
errcho 'brick itself depends on some stuff, which you dont have installed:'
|
|
||||||
errcho "${NO_DEPS[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# some vars
|
# some vars
|
||||||
BRICKS_DIR=${BRICKS_DIR:-}
|
BRICKS_DIR=${BRICKS_DIR:-}
|
||||||
PKGS=()
|
PKGS=()
|
||||||
|
@ -167,7 +138,7 @@ if [ "${#PKGS[@]}" == "0" ]; then
|
||||||
inf "nothing to do"
|
inf "nothing to do"
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
inf "Packages to install: ${PKGS[@]}"
|
echo "Packages to install: ${PKGS[@]}"
|
||||||
user_confirm
|
user_confirm
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -199,7 +170,6 @@ if [ "${#PACDEPS[@]}" != "0" ]; then
|
||||||
inf "removed $removed installed pacman deps"
|
inf "removed $removed installed pacman deps"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# then there might actually be no work to be done
|
|
||||||
if [ "$TO_INSTALL" != "" ]; then
|
if [ "$TO_INSTALL" != "" ]; then
|
||||||
inf "installing pacman packages:"
|
inf "installing pacman packages:"
|
||||||
inf "$TO_INSTALL"
|
inf "$TO_INSTALL"
|
||||||
|
@ -220,60 +190,17 @@ else
|
||||||
inf "no pacman deps to install"
|
inf "no pacman deps to install"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DOWNLOADED_FILES=()
|
|
||||||
|
|
||||||
i=1
|
i=1
|
||||||
# pacman deps installed, lets install the actual shit
|
# pacman deps installed, lets install the actual shit
|
||||||
for pkg in "${PKGS[@]}"; do
|
for pkg in "${PKGS[@]}"; do
|
||||||
|
|
||||||
exec_brick() {
|
|
||||||
echo -e "$(bricksenv)$1" | bash
|
|
||||||
}
|
|
||||||
|
|
||||||
# first check if there is stuff we need to download for that brick
|
|
||||||
|
|
||||||
SCRIPT="
|
|
||||||
source $(getbrick $pkg)
|
|
||||||
if [ -z ${var+x} ]; then
|
|
||||||
echo \${downloads[@]}
|
|
||||||
fi
|
|
||||||
"
|
|
||||||
|
|
||||||
DOWNLOADS=$(exec_brick "$SCRIPT")
|
|
||||||
DOWNLOADS_MAP=()
|
|
||||||
if ! [ "$DOWNLOADS" == "" ]; then
|
|
||||||
DOWNLOADS=($DOWNLOADS)
|
|
||||||
inf "$(inf "downloading files for $pkg...")"
|
|
||||||
ii=1
|
|
||||||
for download in $DOWNLOADS; do
|
|
||||||
curl -s $download > $(tmpdir)/$pkg-file-$i &
|
|
||||||
DOWNLOADS_MAP=(${DOWNLOADS_MAP[@]} $(tmpdir)/$pkg-file-$i)
|
|
||||||
ii=$(($ii + 1))
|
|
||||||
done
|
|
||||||
wait
|
|
||||||
inf "$(inf "downloaded")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
DOWNLOADED_FILES=(${DOWNLOADED_FILES[@]} ${DOWNLOADS_MAP[@]})
|
|
||||||
|
|
||||||
SCRIPT="
|
|
||||||
source $(getbrick $pkg)\n
|
|
||||||
downloads=(${DOWNLOADS_MAP[@]})\n
|
|
||||||
install
|
|
||||||
"
|
|
||||||
|
|
||||||
inf "installing $pkg [$i/${#PKGS[@]}]"
|
inf "installing $pkg [$i/${#PKGS[@]}]"
|
||||||
exec_brick "$SCRIPT" > $BRICKS_DB/.$pkg-install-log
|
SCRIPT="
|
||||||
|
export BRICKS_DIR=$BRICKS_DIR
|
||||||
|
export BRICKS_DB=$BRICKS_DB
|
||||||
|
source $(getbrick $pkg)\n
|
||||||
|
install"
|
||||||
|
echo -e "$SCRIPT" | bash > $BRICKS_DB/.$pkg-install-log
|
||||||
i=$(($i + 1))
|
i=$(($i + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
if ! [ "${#DOWNLOADED_FILES[@]}" == "0" ]; then
|
inf "done"
|
||||||
inf 'cleaning up downloaded files'
|
|
||||||
for file in $DOWNLOADED_FILES; do
|
|
||||||
rm $file &
|
|
||||||
done
|
|
||||||
wait
|
|
||||||
fi
|
|
||||||
|
|
||||||
inf "done in $(($(date +%s) - $start_time)) seconds"
|
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
# GPL3 only
|
# GPL3 only
|
||||||
# uwu
|
# uwu
|
||||||
|
|
||||||
downloads=(
|
|
||||||
https://example.com/script.sh
|
|
||||||
)
|
|
||||||
|
|
||||||
info() {
|
info() {
|
||||||
echo this brick does this and that
|
echo this brick does this and that
|
||||||
|
@ -26,9 +23,11 @@ pkgs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
install() {
|
install() {
|
||||||
echo this is a dummy package, it is not meant to actually be installed, silly
|
# these 2 lines are to prevent it from being installed
|
||||||
return
|
errcho '`example` brick is not an installable brick, its for packaging reference only'
|
||||||
sh -c "$(cat ${downloads[0]})"
|
exit 1
|
||||||
|
|
||||||
|
sh -c "$(curl https://example.com/script.sh)"
|
||||||
}
|
}
|
||||||
|
|
||||||
uninstall() {
|
uninstall() {
|
||||||
|
|
Loading…
Reference in New Issue