- Incorrectly handles packages with
Provides
field.
./native.sh > native.txt
./external.sh > external.txt
#!/usr/bin/bash | |
################################################################################ | |
# # | |
# Well, generate minimal list of currently installed AUR packages. # | |
# # | |
################################################################################ | |
pacman -Qqemtt | sort |
#!/usr/bin/bash | |
######################################################################################################################## | |
# # | |
# Generate minimal native packages and groups list to reproduce current installation. # | |
# # | |
######################################################################################################################## | |
native=$( pacman -Qqn | sort ) # ← All packages installed from Arch repos (excluding AUR, ofc). | |
explicit=$( pacman -Qqentt | sort ) # ← Explicitly installed packages excluding AUR that aren't direct dependencies. | |
installedGroups="" # ← Groups with all packages installed. | |
grouped="" # ← Packages from installed groups. | |
# ↓ All groups: | |
groups=$(curl -s "https://archlinux.org/groups/" | pup '.results a text{}') | |
# ↓ Iterate over groups: | |
while read name; do | |
# ↓ Packages in group: | |
group=$(curl -s "https://archlinux.org/groups/x86_64/${name}/" | pup '.results a text{}' | sort | uniq) | |
# ↓ Packages that are both in current group and in installed packages list: | |
common=$(comm -12 <(echo "${native}") <(echo "${group}") | sort) | |
# ↓ Check if all packages from group are installed: | |
if [ "${common}" = "${group}" ]; then | |
grouped=$( cat <<< "${grouped}"; cat <<< "${group}" ) | |
installedGroups=$( cat <<< "${installedGroups}"; cat <<< "${name}" ) | |
fi | |
done <<< $(echo "${groups}") | |
# ↓ Remove grouped packages from explitcitly installed list: | |
woGrouped=$(comm -23 <(echo "${explicit}") <(sort <<< "${grouped}")) | |
# ↓ Add group names, remove blank lines (idk if they may be or not may be, but idc): | |
wGroups=$((cat <<< "${woGrouped}"; cat <<< "${installedGroups}") | sort | awk "NF") | |
echo "${wGroups}" # ← Print result. |