Commit 2a5649c6 authored by sebt3's avatar sebt3

Added dependency support

parent 209a806b
### Usage
```
dbp_get.sh {install|list|update}
./dbp-get.sh {install|list|update|list|list_installed|list_upgrade|upgrade|remove}
install <pck> : Install given package
remove <pck> : Remove given package
update : Update known package lists
list : List all availables packages
list_installed: List all installed packages
list_upgrade : List all upgradables packages
upgrade : Upgrade known package
```
......@@ -24,20 +24,11 @@ getRepoInfo() {
getTarget() {
gawk -F= '$1=="target"{print $2}' "$DBP_HOME/config"
}
getPackagePath() {
gawk -F= -v pck=$1 'BEGIN{p=0}$0=="["pck"]"{p=1}/^$/{p=0}p==1&&/Download=/{print $2;exit}' "$DBP_HOME/repos/$2/$3/Packages"
getPackageInfo() {
gawk -F= -v pck=$2 'BEGIN{p=0}$0=="["pck"]"{p=1}/^$/{p=0}p==1&&/'"$1"'=/{print $2;exit}' "$DBP_HOME/repos/$3/$4/Packages"
}
getPackageMD5() {
gawk -F= -v pck=$1 'BEGIN{p=0}$0=="["pck"]"{p=1}/^$/{p=0}p==1&&/MD5sum=/{print $2;exit}' "$DBP_HOME/repos/$2/$3/Packages"
}
getPackageName() {
gawk -F= -v pck=$1 'BEGIN{p=0}$0=="["pck"]"{p=1}/^$/{p=0}p==1&&/Name=/{print $2;exit}' "$DBP_HOME/repos/$2/$3/Packages"
}
getPackageNames() {
gawk -F= 'BEGIN{p=""}/^\[/{p=$1;gsub("^.","",p);gsub(".$","",p)}/^Name=/{print p"\t"$2}' "$DBP_HOME/repos/$1/$2/Packages"
}
getPackageMD5s() {
gawk -F= 'BEGIN{p=""}/^\[/{p=$1;gsub("^.","",p);gsub(".$","",p)}/^MD5sum=/{print p"\t"$2}' "$DBP_HOME/repos/$1/$2/Packages"
getPackagesInfo() {
gawk -F= 'BEGIN{p=""}/^\[/{p=$1;gsub("^.","",p);gsub(".$","",p)}/^'"$1"'=/{print p"\t"$2}' "$DBP_HOME/repos/$2/$3/Packages"
}
getFileMD5() {
md5sum <"$1"|awk '{print $1}'
......@@ -75,7 +66,7 @@ list() {
precheck
getRepoInfo|while read id url comps;do
for c in $comps;do
getPackageNames "$id" "$c"|while read id desc;do
getPackagesInfo "Name" "$id" "$c"|while read id desc;do
printf "%s\033[30G%s\n" "$id" "$desc"
done
done
......@@ -87,9 +78,15 @@ install() {
precheck
getRepoInfo|{ while read id url comps;do
for c in $comps;do
path=$(getPackagePath "$pck" "$id" "$c")
path=$(getPackageInfo "Download" "$pck" "$id" "$c")
if [[ "$path" != "" ]];then
md=$(getPackageMD5 "$1" "$id" "$c")
deps=$(getPackageInfo "Dependency\[dbp\]" "$1" "$id" "$c")
if [[ "$deps" != "" ]];then
echo $deps|sed 's/;/\n/'|while read l;do
install "$l"
done
fi
md=$(getPackageInfo "MD5sum" "$1" "$id" "$c")
fname="${pck}.dbp"
echo -n "Downloading $fname..."
wget -o /dev/null -O "$(getTarget)${fname}_new" "$(echo $url|awk -F/ '{print $1"//"$3}')$path"
......@@ -110,27 +107,45 @@ install() {
}
}
install_all() {
while [ $# -gt 0 ];do
install $1
shift
done
}
list_installed() {
precheck
getRepoInfo|while read id url comps;do
for c in $comps;do
getPackageMD5s "$id" "$c"|while read pck md;do
getPackagesInfo "MD5sum" "$id" "$c"|while read pck md;do
if [ -e "$(getTarget)/${pck}.dbp" ];then
printf "%s\033[30G%s\n" "$pck" "$(getPackageName "$pck" "$id" "$c")"
printf "%s\033[30G%s\n" "$pck" "$(getPackageInfo "Name" "$pck" "$id" "$c")"
fi
done
done
done
}
remove() {
while [ $# -gt 0 ];do
pck=$1
if [ -e "$(getTarget)/${pck}.dbp" ];then
echo "Uninstalling $pck"
rm -f "$(getTarget)/${pck}.dbp"
fi
shift
done
}
list_upgrade() {
precheck
getRepoInfo|while read id url comps;do
for c in $comps;do
getPackageMD5s "$id" "$c"|while read pck md;do
getPackagesInfo "MD5sum" "$id" "$c"|while read pck md;do
if [ -e "$(getTarget)/${pck}.dbp" ];then
if [[ $(getFileMD5 "$(getTarget)/${pck}.dbp") != "$md" ]];then
printf "%s\033[30G%s\n" "$pck" "$(getPackageName "$pck" "$id" "$c")"
printf "%s\033[30G%s\n" "$pck" "$(getPackageInfo "Name" "$pck" "$id" "$c")"
fi
fi
done
......@@ -142,7 +157,7 @@ upgrade() {
precheck
getRepoInfo|while read id url comps;do
for c in $comps;do
getPackageMD5s "$id" "$c"|while read pck md;do
getPackagesInfo "MD5sum" "$id" "$c"|while read pck md;do
if [ -e "$(getTarget)/${pck}.dbp" ];then
if [[ $(getFileMD5 "$(getTarget)/${pck}.dbp") != "$md" ]];then
install "$pck"
......@@ -155,8 +170,9 @@ upgrade() {
showHelp() {
cat <<ENDHELP
$1 {install|list|update}
$1 {install|list|update|list|list_installed|list_upgrade|upgrade|remove}
install <pck> : Install given package
remove <pck> : Remove given package
update : Update known package lists
list : List all availables packages
list_installed: List all installed packages
......@@ -172,7 +188,8 @@ main() {
list_upgrade) list_upgrade;;
list_installed) list_installed;;
upgrade) upgrade;;
install) install "$2";;
install) shift;install_all "$@";;
remove) shift;remove "$@";;
help|*) showHelp "$0";;
esac
}
......
dbp-getsh (0.1.0) unstable; urgency=medium
dbp-getsh (0.1.1) unstable; urgency=medium
* Initial Release.
* Added dependency support
-- Sébastien Huss <sebastien.huss@gmail.com> Tue, 19 Sep 2017 20:52:06 +0200
-- Sébastien Huss <sebastien.huss@gmail.com> Sat, 28 Oct 2017 22:05:25 +0200
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment