Pacman

From Chakra | Wiki
Jump to: navigation, search
Utilities-terminal.pngPacman
Pacman is the current package manager for Chakra. It's a command-line application by the Arch Linux developers. Pacman will be eventually replaced by Akabei.
Package: pacman

Usage

Some very basic commands.

To update the system:

sudo pacman -Syu

Force synchronization of the database:

sudo pacman -Syy

Installing

To install a package (best to always run pacman -Syu, before installing):

sudo pacman -S package_name

To install a local package, or from a website:

sudo pacman -U /path/to/the/package

To re-install all packages, except ccr, in case of emergency:

sudo pacman -Sy $(pacman -Q | cut -d " " -f1 | grep -v "$(pacman -Qm | cut -d " " -f1)")

Removing Packages

If you want to only remove the package, the following command is sufficient:

sudo pacman -R <package_name>

To remove the package and those of its dependencies that aren't needed by any other application, do

sudo pacman -Rs <package_name>

Finally, to remove the package, avoid orphaned dependencies and erase its global configuration, type

sudo pacman -Rns package_name

which in most cases is the proper command to remove software in Chakra Gnu/Linux.

Searches/Queries

Info about an installed package:

pacman -Qi package_name

Queries the repo about a package:

pacman -Ss package_name

Queries the repo about a packages, and all that depend on it:

pacman -Sii package_name

Howto

List and Remove Installed Packages that are not in the Official Repositories

If you want a list of the packages you installed and are not in the official repositories, you can run this script:

#! /bin/bash
installed=`pacman -Q | sed -e "s|\(.*[^ ]*\) .*|\1|g" `
repos=`pacman -Sl | sed -e "s|[^ ]* \(.*[^ ]*\) .*|\1|g"`

for pkg in $installed
do
    found=`echo $repos | grep $pkg`
    if [ "$found" == "" ]; then
        echo $pkg
    fi
done
# end

Save it in a file, give it execution permission (chmod +x file.sh) and run it:

./file.sh

It will print the packages you have installed which are not in the official repositories. You can also send the list to a text file:

./file.sh > ccrlist.txt

Then, you can edit the list (to remove from it the software you still want in your system), and once the list has only software packages you want to remove, you can run this command to remove those:

sudo pacman -R $(cat ccrlist.txt)

Pacman is completely broken! How do I reinstall it?

In the case that pacman is broken beyond repair, manually download the necessary packages (openssl, libarchive, and pacman) and extract them. The pacman binary will be restored along with its default configuration file. Afterwards, reinstall these packages with pacman to maintain package database integrity. You Can use this command to extract them.

 sudo tar -xvpf <Package Name> -C / --exclude .PKGINFO --exclude .INSTALL

Low disc space

Pacman stores installed packages in '/var/cache/pacman/pkg'. Even old packages are not dropped.
If as a result the partition too full, you can clean the cache as follows.

Clean the package cache of packages that are not currently installed:
Warning: Only do this if certain that the installed packages are stable and that a downgrade will not be necessary, since it will remove all of the old versions from the cache folder, leaving behind only the versions of the packages that are currently installed. Having older versions of packages comes in handy in case a future upgrade causes breakage.

sudo pacman -Sc

Clean the entire package cache: Warning: This clears out the entire package cache. Doing this is considered a bad practice; it prevents the ability to downgrade something directly from the cache folder.

sudo pacman -Scc

Alternatively you can use paccache. It will give you more control over what packages are to deleted.
Run for instructions:

paccache -h