Skip to content

Commit

Permalink
add crackle upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuseteam committed Apr 21, 2024
1 parent 992b929 commit 776b837
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ crackle
sudo $BIN
list
clean
update
upgrade
setup
debug
nuke
Expand Down
19 changes: 18 additions & 1 deletion crackle
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@ if [ -z "$operation" -o "$operation" = "help" ]; then
- crackle search $PKG
- crackle show $PKG
- crackle update
- crackle upgrade
- crackle nuke'
exit 0
fi

case $operation in
"install"|"reinstall"|"download"|"crack"|"remove"|"search"|"show"|"remove"|"sudo")[ -z "$PKG" ] && err "missing argument";;
"setup"|"debug"|"clean"|"update"|"nuke"|"list");;
"setup"|"debug"|"clean"|"update"|"upgrade"|"nuke"|"list");;
"click")[ -z "$PKG" ] && err "missing argument";build_click;;
*) err 'available operations (setup|debug|install $PKG|download $PKG|crack $PKG|remove $PKG|clean|search $PKG|show $PKG|update|remove $PKG)';;
esac
Expand Down Expand Up @@ -215,6 +216,22 @@ APT_CACHE="apt-cache -o Dir::Cache=$APTCACHE -o Dir::State=$APTSTATE -o Dir::Etc
exit 0;
}

# Upgrades the installed packages
[ "$operation" = "upgrade" ] && {
wget -q --spider https://ubports.com || err "no internet connection, please run crackle upgrade later to fetch the latest upgrades";
say "calculating upgrade....."
while read pkg
do
PKGS_DIR=$PKG_PATH/$pkg
installed=$(cat $PKGS_DIR/$pkg.version);
candidate=$($APT_CACHE policy $pkg|awk '/Candidate/{print $2}');
[[ ! "$installed" = "$candidate" ]] && upgradable+=($pkg)
done < <(ls $PKG_PATH)
[[ -n "$upgradable" ]] && crackle install $upgradable
[[ -z "$upgradable" ]] && stat "all packages are up to date"
exit 0;
}

# Downloads a package for installation
[ "$operation" = "download" ] && {
$APT_GET "$operation" ${PKG[@]};
Expand Down

0 comments on commit 776b837

Please sign in to comment.