Skip to content

Commit

Permalink
Merge pull request #1799 from MilhouseVH/fix_checkdeps
Browse files Browse the repository at this point in the history
scripts/checkdeps: fix library test
  • Loading branch information
chewitt committed Jul 23, 2017
2 parents 1885156 + 3a4c5eb commit 65e3131
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
47 changes: 31 additions & 16 deletions scripts/checkdeps
Expand Up @@ -20,6 +20,20 @@

. config/options $1

get_yes_no()
{
local ans
read -p "Would you like to install the needed tools ? (y/n) " ans
[ "${ans,,}" == "y" ] && return 0
[ "${ans,,}" == "yes" ] && return 0
return 1
}

test_libjson-perl()
{
perl -MJSON -e 'exit(0);' 2>/dev/null
}

if [ -f /etc/lsb-release ]; then
DISTRO=$(grep DISTRIB_ID /etc/lsb-release | cut -d "=" -f 2 | tr A-Z a-z)
fi
Expand Down Expand Up @@ -62,7 +76,7 @@ case "$DISTRO" in
;;
esac

if ! perl -MJSON -e 'exit(0);' 2>/dev/null; then
if ! test_libjson-perl; then
files="$files perl/JSON.pm"
files_pkg="$files_pkg libjson-perl"
fi
Expand Down Expand Up @@ -95,7 +109,11 @@ done

i=0
while file=`getarg $i $files` && [ -n "$file" ]; do
[ ! -f $file ] && need="$need $file" && need_pkg="$need_pkg `getarg $i $files_pkg`"
installed=N
file_pkg=`getarg $i $files_pkg`
[ "$(type -t "test_$file_pkg")" == "function" ] && test_$file_pkg && installed=Y
[ $installed == N -a -f $file ] && installed=Y
[ $installed == N ] && need="$need $file" && need_pkg="$need_pkg $file_pkg"
i=$(($i+1))
done

Expand All @@ -106,29 +124,23 @@ if [ -n "$need" ]; then

case "$DISTRO" in
ubuntu|debian|\"elementary\")
read -p "would you like to install the needed tools ? (y/n) " ans
[ "$ans" = "y" ] && sudo apt-get install $need_pkg
get_yes_no && sudo apt-get install $need_pkg
;;
fedora|centos|rhel)
if [ `which dnf` ]; then YUM=dnf; else YUM=yum; fi
read -p "would you like to install the needed tools ? (y/n) " ans
[ "$ans" = "y" ] && sudo $YUM install $need_pkg
get_yes_no && sudo $YUM install $need_pkg
;;
gentoo)
read -p "would you like to install the needed tools ? (y/n) " ans
[ "$ans" = "y" ] && sudo emerge --ask --deep $need_pkg
get_yes_no && sudo emerge --ask --deep $need_pkg
;;
mageia)
read -p "would you like to install the needed tools ? (y/n) " ans
[ "$ans" = "y" ] && sudo urpmi $need_pkg
get_yes_no && sudo urpmi $need_pkg
;;
arch)
read -p "would you like to install the needed tools ? (y/n) " ans
[ "$ans" = "y" ] && sudo pacman -Sy $need_pkg
get_yes_no && sudo pacman -Sy $need_pkg
;;
opensuse)
read -p "would you like to install the needed tools ? (y/n) " ans
[ "$ans" = "y" ] && sudo zypper install -y --no-recommends $need_pkg
get_yes_no && sudo zypper install -y --no-recommends $need_pkg
;;
*)
echo "**** unsupported distro $DISTRO ****"
Expand All @@ -137,7 +149,6 @@ if [ -n "$need" ]; then
esac
fi


need=""
need_pkg=""

Expand All @@ -149,7 +160,11 @@ done

i=0
while file=`getarg $i $files` && [ -n "$file" ]; do
[ ! -f $file ] && need="$need $file" && need_pkg="$need_pkg `getarg $i $files_pkg`"
installed=N
file_pkg=`getarg $i $files_pkg`
[ "$(type -t "test_$file_pkg")" == "function" ] && test_$file_pkg && installed=Y
[ $installed == N -a -f $file ] && installed=Y
[ $installed == N ] && need="$need $file" && need_pkg="$need_pkg $file_pkg"
i=$(($i+1))
done

Expand Down
1 change: 1 addition & 0 deletions scripts/create_addon
Expand Up @@ -42,6 +42,7 @@ if [ -n "$PKG_ADDON_PROJECTS" -a ! "$PKG_ADDON_PROJECTS" = "any" ]; then
fi
fi

$SCRIPTS/checkdeps

pack_addon() {
scripts/install_addon $PKG_NAME $PKG_ADDON_ID || exit
Expand Down

0 comments on commit 65e3131

Please sign in to comment.