1
0
Fork
You've already forked bash-script-archlinux
0
No description
  • Shell 100%
2026年03月26日 21:55:15 +00:00
check_packages.sh Edit check_packages.sh 2026年03月26日 21:55:15 +00:00
LICENSE Add new file 2026年03月26日 21:49:57 +00:00
packages.txt Upload New File 2026年03月26日 21:46:06 +00:00
README.md Edit README.md 2026年03月26日 21:49:11 +00:00

📦 check_packages

A lightweight Bash script for Arch Linux that verifies installed packages against a reference list, checking that each package is present and at the expected version.

Requirements

  • Arch Linux (or any system using pacman)
  • Bash 4.0+
  • No root privileges required

File Structure

.
├── check_packages.sh # Main script
└── packages.txt # Your reference package list

Package List Format

The package list file follows pacman -Q output format: one package per line with the package name and version separated by a space. Blank lines and lines starting with # are ignored.

# System base
base 3-2
linux 6.13.5.arch1-1
# Shell
bash 5.2.037-2
# Development
git 2.48.1-1
vim 9.1.1436-1

You can generate a list from your current system with:

pacman -Q > packages.txt

Installation

Clone the repository and make the script executable:

git clone https://gitlab.com/<your-username>/check_packages.git
cd check_packages
chmod +x check_packages.sh

Usage

./check_packages.sh <package-list-file>

Example:

./check_packages.sh packages.txt

Output

Each package is reported with one of three statuses:

Status Meaning
[OK] Package is installed at the expected version
[MISMATCH] Package is installed but at a different version
[MISSING] Package is not installed at all

Example output:

Checking packages listed in: packages.txt
--------------------------------------------
[OK] firefox 134.0-2
[MISMATCH] git — expected: 2.48.1-1, installed: 2.49.0-1
[MISSING] vim (expected: 9.1.1436-1)
--------------------------------------------
Summary: 1 OK | 1 mismatch(es) | 1 missing

Exit Codes

Code Meaning
0 All packages match the expected versions
1 Invalid usage or input file error
2 One or more packages are missing or mismatched

The non-zero exit code on failure makes the script easy to integrate into CI/CD pipelines or larger automation workflows.

License

MIT