You are not logged in.

#1 2022-02-25 17:42:57

saleem
Member
Registered: 2011-09-21
Posts: 168

Pacman command for new packages

Hello,

Is there any pacman command that can tell about a new package added to the Arch Linux packages database ? e.g I want to check if there has been any new package added to the community repository which was previously not there in community repository , so is there any pacman command for checking this?

Thanks.

Offline

#2 2022-02-25 17:45:47

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: Pacman command for new packages

There is no history in the database, so the only way to do this would be to compare an old database to a newer one. Not something pacman can do without scripting it yourself.

Last edited by Scimmia (2022-02-25 17:46:23)

Offline

#3 2022-02-25 18:09:07

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,491
Website

Re: Pacman command for new packages

And in order to plan a good approach to scripting this, you'd need to define the relevant time frame.  All packages currently in community were previously not there - but many of them have been for a long time.  One approach is if - for example - you wanted a periodic check of new packages in the repos since your last check, just run `pacman -Ssq` putting the results into a list file and compare it to the previous list (e.g., with `comm`).


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2022-02-26 14:13:24

papajoke
Member
From: france
Registered: 2014-10-10
Posts: 45

Re: Pacman command for new packages

I have a script for this (sorry, not in english in code)

before update : `script -b`; pacman -Sy ; after: `script -a` (for get new version) and, `script -n` and `script -r` for compare

#!/usr/bin/bash
pkgname="diff-maj"
# show diff before/after pacman db update

CG='\033[1m\033[32m'
CB='\033[1m'
CE='\033[0m'

confdir="${HOME}/.config/share/${pkgname}"
[ -d "$confdir" ] || mkdir -p "$confdir"
fbefore="${confdir}/before-maj.pkgs"
fafter="${confdir}/after-maj.pkgs"

if [[ "$1" == '-h' || "$1" == '' ]]; then
    cat <<EOF
 ${pkgname} Usage:
    -b:  save package list before update
    -a:  save package list after update
    -d:  diff before/after
    -n:  show new packages
    -r:  show pakages removed
EOF
    exit
fi


if [[ "$1" == '-b' ]]; then
    pacman -Ssq | sort > "${fbefore}"
    [ -f "${fafter}" ] && rm -vf "${fafter}"
    echo "saved in ${fbefore}"
    printf "%s paquets avant mise à jour\n" $(cat "${fbefore}" | wc -l)
    ls -l "${confdir}"
    exit 0
fi

if [[ "$1" == '-a' ]]; then
    pacman -Ssq | sort > "${fafter}"
    echo "saved in ${fafter}"
    printf "%s paquets après la mise à jour\n" $(cat "${fafter}" | wc -l)
    exit 0
fi

if [[ "$1" == "-d" ]]; then
    [ -f "${fbefore}" ] || exit 8
    [ -f "${fafter}" ] || exit 9
    echo "diff ${fbefore} ${fafter} --color"
    diff "${fbefore}" "${fafter}" --color
fi

if [[ "$1" == "-n" ]]; then
    [ -f "${fbefore}" ] || exit 8
    [ -f "${fafter}" ] || exit 9
    diffs=($(diff "${fbefore}" "${fafter}" | awk '/^>/ {print $2}'))
    echo "-- ${diffs[*]}"
    echo "-- Détails des ${#diffs[@]} nouveaux paquets:"
    LANG=C pacman -Si ${diffs[*]} | awk -F': ' '/^Name/ {name=$2} /^Desc/ {desc=$2} /^URL/ {printf "\033[34m%-28s\033[0m %s \033[38;5;246m%s\033[0m\n",name,desc,$2}'
fi

if [[ "$1" == "-r" ]]; then
    [ -f "${fbefore}" ] || exit 8
    [ -f "${fafter}" ] || exit 9
    count=$(diff "${fbefore}" "${fafter}" | awk '/^</ {print $2}' |wc -l)
    echo "-- ${count} paquets supprimés:"
    diff "${fbefore}" "${fafter}" | awk '/^</ {printf $2" "}'
    echo
fi

LTS - Fish - Kde - intel M100 - 16Go RAM - ssd

Offline

#5 2022-02-26 14:19:05

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,491
Website

Re: Pacman command for new packages

`comm` would be better than `diff ... | awk ...`


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2022-02-28 18:13:31

saleem
Member
Registered: 2011-09-21
Posts: 168

Re: Pacman command for new packages

Thanks for all the kind replies , this info is very helpful indeed.

Offline

#7 2022-02-28 18:54:54

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,491
Website

Re: Pacman command for new packages

FYI, you could also get the changes since the last time you upgraded (or really since the last db sync, which should have been an upgrade) by using pacman's -b or --dbpath flag to download the new datases to an alternative location (e.g., under /tmp).  E.g., something like the following:

mkdir -p /tmp/db
pacman -Sy -b /tmp/db
pacman -Ssq -b /tmp/db >| /tmp/packages
pacman -Ssq | comm -3 - /tmp/packages

With bash you could do without the /tmp/packages file and save a line by using process substitution:

#!/bin/bash
mkdir -p /tmp/db
pacman -Sy -b /tmp/db
comm -3 <(pacman -Ssq) <(pacman -Ssq -b /tmp/db)

The comm command as written shows packages removed in the first column, and packages added in the second column.  If you really just want to see the new ones replace the -3 flag with -13.

Last edited by Trilby (2022-02-28 18:56:12)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB