Skip to content

Commit

Permalink
add package removal functionality and a way to list installed package
Browse files Browse the repository at this point in the history
   > also set up tailscale gpg key so it is updatable
   > also fix up mc setup
  • Loading branch information
Fuseteam committed Apr 14, 2024
1 parent 9c9858f commit e8ba0fb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bin
Submodule bin updated from fbaddf to 8bc5d3
37 changes: 31 additions & 6 deletions crackle
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ if [ -z "$operation" -o "$operation" = "help" ]; then
- crackle download $PKG
- crackle crack $PKG
- crackle remove $PKG
- crackle list
- crackle clean
- crackle click $PKG
- crackle search $PKG
Expand All @@ -97,10 +98,10 @@ if [ -z "$operation" -o "$operation" = "help" ]; then
fi

case $operation in
"install"|"reinstall"|"download"|"crack"|"remove"|"search"|"show")[ -z "$PKG" ] && err "missing argument";;
"setup"|"debug"|"clean"|"update"|"nuke");;
"install"|"reinstall"|"download"|"crack"|"remove"|"search"|"show"|"remove")[ -z "$PKG" ] && err "missing argument";;
"setup"|"debug"|"clean"|"update"|"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)';;
*) err 'available operations (setup|debug|install $PKG|download $PKG|crack $PKG|remove $PKG|clean|search $PKG|show $PKG|update|remove $PKG)';;
esac

# Aliases for commands
Expand Down Expand Up @@ -145,6 +146,16 @@ APT_CACHE="apt-cache -o Dir::Cache=$APTCACHE -o Dir::State=$APTSTATE -o Dir::Etc
exit 0;
}

# list installed packages
[[ "$operation" = "list" ]] && {
while read package
do
version=$(cat $PKG_PATH/$package/$package.version)
echo $package $version;
done < <(ls $PKG_PATH);
exit 0;
}

# Installs/updates Crackle into ~/.local ~/.config and ~/.cache
[ "$operation" = "setup" ] && {
[[ $(basename $SCRP_DIR) = "bin" ]] && upgrade_crackle;
Expand Down Expand Up @@ -249,6 +260,21 @@ APT_CACHE="apt-cache -o Dir::Cache=$APTCACHE -o Dir::State=$APTSTATE -o Dir::Etc
crackle install ${PKG[@]};
}

# remove a package
[[ "$operation" = "remove" ]] && {
for pkg in "${PKG[@]}"
do
say "removing $pkg";
[ -d $PKGS_DIR ] && rm -r $PKGS_DIR;
done;
find "$PKG_PREFIX/bin" -xtype l -exec rm {} +;
sudo_run "find $SUDO_BIN -xtype l -exec rm {} +";
sudo_run "find $SUDO_CONFIG -xtype l -exec rm {} +";
find "$CRACKLECMP" -xtype l -exec rm {} +;
say "Done";
exit 0;
}

# remove crackle from the system
[[ "$operation" = "nuke" ]] && {
[[ -d "$APTCACHE" ]] && rm -r "$APTCACHE";
Expand All @@ -264,14 +290,13 @@ APT_CACHE="apt-cache -o Dir::Cache=$APTCACHE -o Dir::State=$APTSTATE -o Dir::Etc
[[ -f "$PKG_PREFIX/bin/rorw" ]] && rm $SCRP_DIR/rorw;
[[ -f "$PKG_PREFIX/bin/remount" ]] && rm $SCRP_DIR/remount;
[[ -f "$CRACKLECMP/crackle" ]] && rm $CRACKLECMP/crackle;
[[ -d "$PKG_PREFIX/bin/scripts" ]] && rm -r $PKG_PREFIX/bin/scripts;
[[ -d "$PKG_PREFIX/lib/crackle" ]] && rm -r $PKG_PREFIX/lib/crackle;
find "$PKG_PREFIX/bin" -xtype l -exec rm {} +;
find "$PKG_PREFIX/lib" -xtype l -exec rm {} +;
find "$SUDO_BIN" -xtype l -exec rm {} +;
find "$SUDO_CONFIG" -xtype l -exec rm {} +;
find "${XDG_DATA_HOME:-$HOME/.local/share}" -xtype l -exec rm {} + 2> /dev/null;
sed -i '/cracklerc/d' $HOME/.bashrc
sed -i '/cracklerc/d' $HOME/.profile
find "$CRACKLECMP" -xtype l -exec rm {} +;
[ -f $HOME/.bash_completion ] && say "please check ~/.bash_completion for leftover references to crackle";
exit 0;
}

0 comments on commit e8ba0fb

Please sign in to comment.