archlinux support
This commit is contained in:
+2
-1
@@ -44,6 +44,7 @@ if [[ $CURDIR != '/opt/miaou-bash' ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
apt-get install -y "${REQUIRED_PKGS[@]}"
|
source "$CURDIR/lib/functions.sh"
|
||||||
|
"$CURDIR/tools/idem_apt_install" "${REQUIRED_PKGS[@]}"
|
||||||
./init.sh
|
./init.sh
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -18,6 +18,18 @@ function isArray {
|
|||||||
[[ "$(declare -p "$1" 2>/dev/null)" =~ "declare -a" ]] || return 1
|
[[ "$(declare -p "$1" 2>/dev/null)" =~ "declare -a" ]] || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isDebian {
|
||||||
|
grep ^ID=debian /etc/os-release
|
||||||
|
}
|
||||||
|
|
||||||
|
function isArch {
|
||||||
|
grep ^ID=arch /etc/os-release
|
||||||
|
}
|
||||||
|
|
||||||
|
function os-release {
|
||||||
|
grep ^ID= /etc/os-release | cut -d '=' -f2
|
||||||
|
}
|
||||||
|
|
||||||
function askConfirmation {
|
function askConfirmation {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
y | Y | yes | YES)
|
y | Y | yes | YES)
|
||||||
|
|||||||
+38
-12
@@ -1,25 +1,51 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
source "$MIAOU_BASH_DIR"/lib/functions.sh
|
||||||
|
|
||||||
function usage {
|
function usage {
|
||||||
local BASECMD
|
local BASECMD
|
||||||
BASECMD=$(basename "$0")
|
BASECMD=$(basename "$0")
|
||||||
echo "usage: $BASECMD <packages...>"
|
echo "usage: $BASECMD <packages...>"
|
||||||
echo 'idempotent debian package installation : update if necessary, install only if not yet done'
|
case $(os-release) in
|
||||||
|
debian)
|
||||||
|
echo 'idempotent debian package installation : update if necessary, install only if not yet done'
|
||||||
|
;;
|
||||||
|
arch)
|
||||||
|
echo 'idempotent archlinux package installation : update if necessary, install only if not yet done'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "$(id -u)" -ne 0 ] && echo 'root privilege required' && exit 2
|
[ "$(id -u)" -ne 0 ] && echo 'root privilege required' && exit 2
|
||||||
[[ $# -lt 1 ]] && usage
|
[[ $# -lt 1 ]] && usage
|
||||||
|
|
||||||
if [ "$(date --date='-12 hours' +%s)" -gt "$(date -d "$(stat -c %y /var/lib/apt/lists/partial)" +%s)" ]; then
|
case $(os-release) in
|
||||||
echo "updating repositoring..."
|
debian)
|
||||||
apt-get update
|
if [ "$(date --date='-12 hours' +%s)" -gt "$(date -d "$(stat -c %y /var/lib/apt/lists/partial)" +%s)" ]; then
|
||||||
fi
|
echo "updating repositoring..."
|
||||||
|
apt-get update
|
||||||
for i in "$@"; do
|
|
||||||
if ! dpkg -l "$i" 2>/dev/null | grep -q ^ii; then
|
|
||||||
sudo apt-get install -y "$i"
|
|
||||||
elif [ -n "${VERBOSE+x}" ] && $VERBOSE; then
|
|
||||||
echo "apt package <$i> already installed!"
|
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
for i in "$@"; do
|
||||||
|
if ! dpkg -l "$i" 2>/dev/null | grep -q ^ii; then
|
||||||
|
sudo apt-get install -y "$i"
|
||||||
|
elif [ -n "${VERBOSE+x}" ] && $VERBOSE; then
|
||||||
|
echo "apt package <$i> already installed!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
arch)
|
||||||
|
for i in "$@"; do
|
||||||
|
if ! pacman -Ql "$i" 2>/dev/null | grep -q ^ii; then
|
||||||
|
sudo pacman -S "$i"
|
||||||
|
elif [ -n "${VERBOSE+x}" ] && $VERBOSE; then
|
||||||
|
echo "pacman package <$i> already installed!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "unknown os release <$(os-release)>!" && exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|||||||
+2
-1
@@ -42,7 +42,8 @@ function get_artcode {
|
|||||||
|
|
||||||
if [ -z "$(command -v git)" ]; then
|
if [ -z "$(command -v git)" ]; then
|
||||||
echo "INSTALLING PACKAGE <GIT> required"
|
echo "INSTALLING PACKAGE <GIT> required"
|
||||||
sudo apt install -y git
|
source "$MIAOU_BASH_DIR/lib/functions.sh"
|
||||||
|
"$CURDIR/tools/idem_apt_install" git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $REPO_TYPE in
|
case $REPO_TYPE in
|
||||||
|
|||||||
Reference in New Issue
Block a user