#!/bin/bash
# This file is part of vlbuildbot.
#
# vlbuildbot is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License v3 as published by
# the Free Software Foundation.
#
# vlbuildbot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# See http://www.gnu.org/licenses/ for complete licensing terms.
SB=$(basename $1)
SBPATH=$1
APP=$(basename $SB .SlackBuild)
#SBREPO=/var/vabs/
SBREPO=/home/vluser/devel/slackbuilds/var/vabs/
#DEPS=$(grep ^MAKEDEPENDS $1|cut -d'"' -f2) || exit 1
function read_sb_deps {
sb=$1
deps=$(grep ^MAKEDEPENDS $sb | cut -d '"' -f2) || return 1
echo $deps
}
function find_deps_of_deps {
# exit if nothing in $DEPS
if [ -z $DEPS ]; then
return 0
fi
echo "DEPS=$DEPS"
for dep in $DEPS; do
if [ -d $SBREPO/$dep ]; then
echo "Found source directory for $dep "
else
echo "Cannot find source directory for $dep "
fi
done
}
function refresh_online_repo_data {
# exit on failure because if we can't run this, then
# we can't solve deps.
slapt-get -u || exit 1
}
function install_dep_from_repos {
dep=$1
retval=""
slapt-get -y -i $dep
retval=$?
# return the returncode of runni
echo $retval
}
function build_dep_from_source {
dep=$1
if [ -d $SBREPO/$dep ]; then
# found the source dir... copy it to the build dir.
cp -ar $SBREPO/$dep /tmp/builds/ || exit 1
cd /tmp/builds/$dep/src || exit 1
echo "Building $dep from source code ... "
./$dep.SlackBuild || exit 1
installpkg /tmp/builds/$dep/$dep*.t?z || exit 1
else
echo "Source directory for $dep not found. Cannot build from source code."
exit 1
fi
}
function process_deps_hive {
# get list of initial dependencies.
initial=$(read_sb_deps $SBPATH)
# loop through these and try to solve them
for dep in $initial;
slaptry=$(install_dep_from_repos $dep)
if [ "$slaptry" != 0 ]; then
}
#val=$(install_dep_from_repos "foo")
#echo $val
#exit $val
#echo "initial deps ... $initial"
#for i in $initial; do
# deps_of_dep=$(read_sb_deps $SBREPO/$i/src/$i.SlackBuild)
# if [ "x$deps_of_dep" != "x" ]; then
# echo "Deps for $i .. $deps_of_dep"
# else
# echo "No dep data for $i"
# fi
# #deps_of_deps=$(read_sb_deps $i.SlackBuild)
# #echo $deps_of_dep
#done
#exit 0
#ls -al $SBREPO
#echo $DEPS
if [ "x$DEPS" != "x" ]; then
echo "Refreshing repository data"
slapt-get -u || exit 1
else
echo "No MAKEDEPENDS specifications found on $SB"
exit 0
fi
for i in $(echo $DEPS) ;do
# if ! ls /var/log/packages/$i-* &>/dev/null;then
slapt-get -y -i $i
if [ $? != 0 ];then
if [ -d $SBREPO/$i ]; then
# copy the source dir to the build location
cp -ar $SBREPO/$i /tmp/builds/ || exit 1
cd /tmp/builds/$i/src || exit 1
chmod +x $i.SlackBuild || exit 1
echo "Building $i from source ... "
./$i.SlackBuild || exit 1
installpkg /tmp/builds/$i/$i*t?z || exit 1
else
echo "Package $i is not found on the online repos."
echo "No source found to build $i. Cannot continue"
exit 1
fi
fi
# else
# echo "$i is installed"
# fi
done