Skip to content

Instantly share code, notes, and snippets.

@100ideas
Created December 7, 2016 12:01
Show Gist options
  • Save 100ideas/009d4f5e1d6f619c755d04c3aad28438 to your computer and use it in GitHub Desktop.
Save 100ideas/009d4f5e1d6f619c755d04c3aad28438 to your computer and use it in GitHub Desktop.
Lists how many deps apt-get will install for a given set of packages
#!/bin/bash
# repo https://gist.github.com/100ideas/009d4f5e1d6f619c755d04c3aad28438
echo "how many new packages are added if we apt-get install:" > apt-plan.txt;
echo $@ >> apt-plan.txt;
printf "\n\tLists how many deps apt-get will install for a given set of packages.\n\tExtended output saved to apt-plan.txt\n";
COLFRMT="%-6s %-25s %-49s\n";
# printf "\nnew\tpkg\n----- \t---------------\n";
printf "\n$COLFRMT" "new" "package" "homepage";
printf "$COLFRMT" "---" "-------" "--------";
# for p in $(cat sn1perdeps.txt); do
for p in $@; do
APT=$(apt-get --no-upgrade --simulate install "$p");
NEWP=$(echo "$APT" | egrep -o '([0-9]+) newly installed' | egrep -o '([0-9]+)';)
SHOW=$(apt-cache show $p | grep -E "(Description:|Homepage)");
URL=$(echo "$SHOW" | grep --max-count=1 -oE 'https?://.+$');
# extended info for apt-plain.txt
printf "\n$p ($NEWP new)\n========================\n$SHOW" >> apt-plan.txt;
printf "\n$APT\n" >> apt-plan.txt;
# console num - name
# printf "$NEWP $p $URL\n" | column -t;
printf "$COLFRMT" "$NEWP" "$p" "$URL";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment