Compare commits

...

2 commits

Author SHA1 Message Date
Geoffrey Frogeye 9a9ee8858d Machines: Lists 2016-12-10 20:04:26 +01:00
Geoffrey Frogeye 338005bca1 Debloc: Multiple mirrors and cyclic deps 2016-12-10 20:04:02 +01:00
2 changed files with 26 additions and 6 deletions

View file

@ -16,8 +16,8 @@ DEBLOC_ROOT=$HOME/.debloc/$ARCH
DEBLOC_LD=$DEBLOC_ROOT/ld DEBLOC_LD=$DEBLOC_ROOT/ld
if [ -z $DEBIAN_MIRROR ]; then if [ -z $DEBIAN_MIRROR ]; then
DEBIAN_MIRROR=$(cat /etc/apt/sources.list | grep '^deb ' | grep main | grep -v security | grep -v updates | grep -v backports) DEBIAN_MIRROR="$(cat /etc/apt/sources.list | grep '^deb ' | grep main | grep -v backports)"
DEBIAN_MIRROR=$(echo $DEBIAN_MIRROR | head -1 | cut -d ' ' -f 2 | sed 's/\/$//') DEBIAN_MIRROR="$(echo -e "$DEBIAN_MIRROR" | cut -d ' ' -f 2 | sed 's/\/$//')"
fi fi
mkdir -p $DEBLOC_DB &> /dev/null mkdir -p $DEBLOC_DB &> /dev/null
@ -167,12 +167,22 @@ function _debloc-installDeb { # path
function _debloc-install { # package function _debloc-install { # package
pkg=$1 pkg=$1
url=${DEBIAN_MIRROR}/$(_debloc-packagePath $pkg)
echo "→ Downloading $url"
DEB_FILE=$(mktemp) &> /dev/null DEB_FILE=$(mktemp) &> /dev/null
wget "$url" --quiet -O $DEB_FILE path=$(_debloc-packagePath $pkg)
if [ $? != 0 ]; then echo -e "${DEBIAN_MIRROR}" | while read mirror; do
if [ -z $mirror ]; then
continue
fi
url=${mirror}/${path}
echo "→ Downloading $url"
wget "$url" --quiet -O $DEB_FILE
if [ $? == 0 ]; then
break
fi
done
if [ ! -s $DEB_FILE ]; then
echo "→ Failed!" echo "→ Failed!"
rm $DEBLOC_DB/$pkg &> /dev/null
return 4 return 4
fi fi
@ -182,6 +192,7 @@ function _debloc-install { # package
if [ "$theo" != "$real" ]; then if [ "$theo" != "$real" ]; then
rm -f $DEB_FILE &> /dev/null rm -f $DEB_FILE &> /dev/null
echo "→ Failed!" echo "→ Failed!"
rm $DEBLOC_DB/$pkg &> /dev/null
return 5 return 5
fi fi
@ -203,6 +214,7 @@ function _debloc-packageDeps { # package
function _debloc-installDeps { # package function _debloc-installDeps { # package
pkg=$1 pkg=$1
echo "Installing $pkg" echo "Installing $pkg"
touch $DEBLOC_DB/$pkg # To prevent cyclic deps
_debloc-packageDeps $pkg | while read dep; do _debloc-packageDeps $pkg | while read dep; do
dep=$(_debloc-filterVirtual $dep) dep=$(_debloc-filterVirtual $dep)
_debloc-locallyInstalled $dep _debloc-locallyInstalled $dep

View file

@ -174,6 +174,14 @@ function machines-sign {
done done
} }
function machines-list {
_machines-apiSigned machine
}
function machines-listNetwork {
_machines-apiSigned network
}
function _machines-postFile { # filename function _machines-postFile { # filename
cat $1 | while read line; do cat $1 | while read line; do
parameter=$(echo $line | cut -d '=' -f 1) parameter=$(echo $line | cut -d '=' -f 1)