<commit_before>#! /bin/bash
#
#  update.pacman.sh
#
#  This script will:
#    Update/sync repos and packages downloaded from Arch
#    Create files containing the names of all packages
#    installed on the local system
#
#  TODO:  Add ability to update private repos vs ABS
#         test for and install pacmatic
#         add option to delete orphaned packages
#################################################################################
# home dir of pacman scripts
PACMAN_USER_SCRIPT_DIR="~/bin/PACMAN"
PACMAN_USER_CONFIG_DIR="~/.config/pacman"
# n.b. TMPDIR is set in .bash_profile
DROPBOX_DIR="~/Dropbox/TW/SCRIPTS"

#################################################################################
# pacman -Q   List all local packages
# pacman -Qm  List all foreign packages (typically manually downloaded and installed)
# pacman -Qn  List all native packages (installed from official sync'd database(s))
PKG_ALL=$PACMAN_USER_CONFIG_DIR"/all_pkgs.txt"
PKG_PAC_ALL=$PACMAN_USER_CONFIG_DIR"/pacman_pkgs.txt"
PKG_FOR_ALL=$PACMAN_USER_CONFIG_DIR"/for_pkgs.txt"
# pacman -Qe  List all explicitly installed packages
# pacman -Qe  List explicitly installed packages available in the official repos
# pacman -Qe  List explicitly installed packages *not* available in official repos
PKG_INSTALL=$PACMAN_USER_CONFIG_DIR"/all_installed_pkgs.txt"
PKG_INSTALL_PAC=$PACMAN_USER_CONFIG_DIR"/pacman_installed_pkgs.txt"
PKG_INSTALL_FOR=$PACMAN_USER_CONFIG_DIR"/for_installed_pkgs.txt"

#################################################################################
echo $TMPDIR
echo
echo $R_HOME
#################################################################################
RESET='\e[0m'           # Text Reset
BRed='\e[1;31m'         # Red
BGreen='\e[1;32m'       # Green
BYellow='\e[1;33m'      # Yellow
BBlue='\e[1;34m'        # Blue
#################################################################################
UPDATE=""
prYellow()
{
    echo
    printf "${BYellow}$1${RESET}\n"
    echo
}
prRed()
{
    echo
    printf "${BRed}$1${RESET}\n"
    echo
}
prBlue()
{
    echo
    printf "${BBlue}$1${RESET}\n"
    echo
}
prGreen()
{
    echo
    printf "${BGreen}$1${RESET}\n"
    echo
}

# Refresh and sync all repositories and packages
prGreen "Refresh, sync, and update all repos and packages"
#sudo pacmatic -Syyu
echo; echo

prYellow "Updating the Arch Build System local package repo"
# sudo abs
echo; echo

# make sure that cache is cleared
prRed "Clearing cache of tarballs..."
# sudo pacman -Sc
echo; echo

#################################################################################
## Output files
##
# update the mirror list for pacman
prYellow "Updating the mirrorlist: /etc/pacman.d/mirrorlist"
# ~/bin/reflector.sh > $TMPDIR/mirrorlist
# sudo mv $TMPDIR/mirrorlist /etc/pacman.d/mirrorlist
echo; echo

# backing up list of all installed packages
prYellow "Creating list of all installed packages in: ~/.config/pacman/installed_pkglist.txt"
# mkdir -p $PACMAN_USER_CONFIG_DIR
# pacman -Qq > $PKG_ALL
# cp $PKG_ALL  $DROPBOX_DIR  #~/Dropbox/TW/SCRIPTS/installed_pkglist.txt

#  backup the current list of pacman installed packages: $ pacman -Qqen > pkglist.txt
prYellow "Creating list of all pacman installed packages in: ~/.config/pacman/pacman_installed_pkglist.txt"
# pacman -Qqen > $PKG_PAC_ALL
# cp $PKG_PAC_ALL  $DROPBOX_DIR   #~/Dropbox/TW/SCRIPTS/pacman_installed_pkglist.txt

# installed packages not available in official repositories, -m, for foreign packages
prYellow "All installed foreign packages -- i.e. those *NOT* available in official repositories "
#pacman -Qem > $PKG_FOR_ALL
echo; echo

# creating list of all orphaned packages
prRed "All orphaned packages: \nPackages installed as depedencies but are now neither dependencies nor optional."
#pacman -Qdt;
echo; echo


prGreen "Sync/Upgrade complete!!"
#################################################################################<commit_msg>Added final todos (rough code, commented out) for this version to go to prodn<commit_after>#! /bin/bash
#
#  update.pacman.sh
#
#  This script will:
#    Update/sync repos and packages downloaded from Arch
#    Create files containing the names of all packages
#    installed on the local system
#
#  TODO:  Add ability to update private repos vs ABS
#         test for and install pacmatic
#         add option to delete orphaned packages
#################################################################################
# home dir of pacman scripts
PACMAN_USER_SCRIPT_DIR="~/bin/PACMAN"
PACMAN_USER_CONFIG_DIR="~/.config/pacman"
# n.b. TMPDIR is set in .bash_profile
DROPBOX_DIR="~/Dropbox/TW/SCRIPTS"

#################################################################################
# pacman -Q   List all local packages
# pacman -Qm  List all foreign packages (typically manually downloaded and installed)
# pacman -Qn  List all native packages (installed from official sync'd database(s))
PKG_ALL=$PACMAN_USER_CONFIG_DIR"/all_pkgs.txt"
PKG_PAC_ALL=$PACMAN_USER_CONFIG_DIR"/pacman_pkgs.txt"
PKG_FOR_ALL=$PACMAN_USER_CONFIG_DIR"/for_pkgs.txt"
# pacman -Qe  List all explicitly installed packages
# pacman -Qe  List explicitly installed packages available in the official repos
# pacman -Qe  List explicitly installed packages *not* available in official repos
PKG_INSTALL=$PACMAN_USER_CONFIG_DIR"/all_installed_pkgs.txt"
PKG_INSTALL_PAC=$PACMAN_USER_CONFIG_DIR"/pacman_installed_pkgs.txt"
PKG_INSTALL_FOR=$PACMAN_USER_CONFIG_DIR"/for_installed_pkgs.txt"

#################################################################################
echo $TMPDIR
echo
echo $R_HOME
#################################################################################
RESET='\e[0m'           # Text Reset
BRed='\e[1;31m'         # Red
BGreen='\e[1;32m'       # Green
BYellow='\e[1;33m'      # Yellow
BBlue='\e[1;34m'        # Blue
#################################################################################
UPDATE=""
prYellow()
{
    echo
    printf "${BYellow}$1${RESET}\n"
    echo
}
prRed()
{
    echo
    printf "${BRed}$1${RESET}\n"
    echo
}
prBlue()
{
    echo
    printf "${BBlue}$1${RESET}\n"
    echo
}
prGreen()
{
    echo
    printf "${BGreen}$1${RESET}\n"
    echo
}

# Refresh and sync all repositories and packages
prGreen "Refresh, sync, and update all repos and packages"
#sudo pacmatic -Syyu
echo; echo

prYellow "Updating the Arch Build System local package repo"
# sudo abs
echo; echo

# make sure that cache is cleared
prRed "Clearing cache of tarballs..."
# sudo pacman -Sc
echo; echo

#################################################################################
## Output files
##
# update the mirror list for pacman
prYellow "Updating the mirrorlist: /etc/pacman.d/mirrorlist"
# ~/bin/reflector.sh > $TMPDIR/mirrorlist
# sudo mv $TMPDIR/mirrorlist /etc/pacman.d/mirrorlist
echo; echo

# backing up list of all installed packages
prYellow "Creating list of all installed packages in: ~/.config/pacman/installed_pkglist.txt"
# mkdir -p $PACMAN_USER_CONFIG_DIR
# pacman -Qq > $PKG_ALL
# cp $PKG_ALL  $DROPBOX_DIR  #~/Dropbox/TW/SCRIPTS/installed_pkglist.txt

#  backup the current list of pacman installed packages: $ pacman -Qqen > pkglist.txt
prYellow "Creating list of all pacman installed packages in: ~/.config/pacman/pacman_installed_pkglist.txt"
# pacman -Qqen > $PKG_PAC_ALL
# cp $PKG_PAC_ALL  $DROPBOX_DIR   #~/Dropbox/TW/SCRIPTS/pacman_installed_pkglist.txt

# installed packages not available in official repositories, -m, for foreign packages
prYellow "All installed foreign packages -- i.e. those *NOT* available in official repositories "
#pacman -Qem > $PKG_FOR_ALL
echo; echo

# creating list of all orphaned packages
prRed "All orphaned packages: \nPackages installed as depedencies but are now neither dependencies nor optional."
#pacman -Qdt;
echo; echo
#############
# list only optional deps that are installed:   (comm -13 <(pacman -Qdtq) <(pacman -Qdttq))
# Check changelogs easily
# When maintainers update packages, commits are often commented in a useful fashion. Users can quickly check these from the command line by installing paclogAUR. This utility lists recent commit messages for packages from the official repositories or the AUR, by using paclog package
#############

###############
# ignoregrp="base base-devel"
# ignorepkg=""

# comm -23 <(pacman -Qqt | sort) <(echo $ignorepkg | tr ' ' '\n' | cat <(pacman -Sqg $ignoregrp) - | sort -u)

# For list with descriptions for packages:

# expac -HM "%-20n\t%10d" $( comm -23 <(pacman -Qqt|sort) <(pacman -Qqg base base-devel|sort) )

# Back-up the pacman database
# The following command can be used to back up the local pacman database:

# $ tar -cjf pacman_database.tar.bz2 /var/lib/pacman/local

# Store the backup pacman database file on one or more offline media, such as a USB stick, external hard drive, or CD-R. See also Pacman tips#Backing up Local database with systemd for an alternative method.
# The database can be restored by moving the pacman_database.tar.bz2 file into the / directory and executing the following command:

# # tar -xjvf pacman_database.tar.bz2
#####################
prGreen "Sync/Upgrade complete!!"
#################################################################################
{'fraction_non_alphanumeric': 0.21407751268487532, 'fraction_numerical': 0.005073950124149844, 'mean_word_length': 5.027325959661678, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5064738', 'n_tokens_mistral': 2960, 'n_tokens_neox': 2788, 'n_words': 866}