pkgin Package Manager

repository·master·Indexed 41 days ago

https://github.com/netbsdfr/pkgin

A package management tool for NetBSD designed to provide an experience similar to apt or yum for managing pkgsrc binary packages. It includes utilities for installing, upgrading, and removing packages, as well as tools for dependency inspection, repository configuration, and managing package 'keep' status.

Tokens
2.6K
Snippets
8
Records
12
Agent score
50%

What's inside pkgin

  1. Control package 'keep' status

    master

    In pkgsrc terminology, you can mark packages as either 'automatic' or 'non-automatic'. This affects whether pkgin autoremove will delete them.

    • keep [package] ...: Marks a package as "non auto-removable".
    • unkeep [package] ...: Marks a package as "auto-removable". If no other package depends on it, it will be removed during an autoremove operation.
    • show-keep: Displays all "non auto-removable" packages.
    • show-no-keep: Displays all "auto-removable" packages.
  2. Set up pkgin and initialize the database

    master

    To use pkgin, you must first configure your repository URIs and then initialize the local database.

    1. Configure repositories by writing the URI to /usr/pkg/etc/pkgin/repositories.conf.
    2. Run pkgin update to create and populate the initial database of locally installed and available packages from the remote pkg_summary(5) list.
    # Configure the repository (example for NetBSD i386 5.0)
    echo ftp://ftp.fr.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/5.0/All > /usr/pkg/etc/pkgin/repositories.conf
    
    # Initialize the database
    pkgin update
  3. Manage packages with pkgin commands

    master

    The pkgin utility provides a suite of commands for package lifecycle management, similar to apt or yum.

    Installation and Upgrades

    • install [package|glob] ...: Installs or upgrades specified packages. You can use globs to target specific versions (e.g., pkgin install 'mysql-server>5.1<5.6').
    • upgrade: Upgrades all installed packages to the newest versions available in the repository.
    • import [file]: Installs a list of packages from a file (one per line).

    Removal

    • remove [package] ...: Removes the specified package and all packages that depend on it.
    • autoremove: Removes orphan dependencies. Use the -n flag to preview which packages would be removed without actually performing the action.
    • clean: Deletes downloaded packages from the cache directory (/var/db/pkgin/cache/).

    Information and Inspection

    • avail: Lists all packages available in the repository.
    • list: Lists all locally installed packages. Use the -l [STATUS_FLAG] modifier to filter by status.
    • search [pattern]: Performs a regular expression search in the repository.
    • show-deps: Displays direct dependencies.
    • show-full-deps [package]: Displays all direct dependencies recursively.
    • show-rev-deps [package]: Displays all reverse direct dependencies (recursively if multiple packages are provided).
    • pkg-content [package]: Shows remote package content.
    • pkg-descr [package]: Shows remote package long-description.
    • pkg-build-defs [package]: Shows remote package build definitions.
    • provides [package]: Shows what a package provides to others.
    • requires [package]: Shows what a package requires from other packages.
    • show-category [category]: Shows packages in a specific category.
    • show-pkg-category [package]: Shows the category of a specific package.
  4. Configure pkgin via environment variables and files

    master

    Environment Variables

    • PKG_REPOS: A space-separated list of repository URIs. This overrides the default configuration in /usr/pkg/etc/pkgin/repositories.conf.

    Configuration Files

    • /usr/pkg/etc/pkgin/repositories.conf: Contains repository URIs. Supports $arch (machine platform) and $osrelease (OS release) macros.
    • /usr/pkg/etc/pkgin/preferred.conf: Defines package preferences (e.g., specific versions to prefer) using glob patterns.

    Data Directories

    • /var/db/pkgin/: Contains runtime components. If the database is corrupted, this directory can be emptied to trigger a rebuild from pkg_install's PKG_DB on the next call.
    • /var/db/pkgin/pkgin.db: The main SQLite database used for querying and matching packages.
    • /var/db/pkgin/cache/: Stores downloaded packages. Can be cleared via pkgin clean or rm -rf /var/db/pkgin/cache.
  5. Inspect package dependencies and metadata

    master

    pkgin allows you to inspect the dependency tree and package metadata without installing them. This is useful for understanding what a package requires or what it provides to the system.

    pkgin show-full-deps <package>    # Show full dependency tree
    pkgin show-provides <package>    # Show what a package provides
    pkgin show-requires <package>   # Show what a package requires
    pkgin search <query>             # Search for packages
  6. Manage package installation and removal

    master

    Use pkgin install to add packages and their dependencies to your system. Use pkgin remove to uninstall packages and their unused reverse dependencies. You can use the -d flag with install to download packages without installing them.

    pkgin install <package>
    pkgin install -d <package>
    pkgin remove <package>
  7. Use pkgin command line options

    master

    Common flags to modify pkgin behavior:

    • -y: Assumes "yes" as the default answer for prompts (except for autoremove).
    • -n: Assumes "no" as the default answer and prints actions line by line (useful for dry-runs).
    • -V: Enables verbose output during (un)installation.
    • -p: Displays results in a parsable format.
    • -F: Forces a package reinstallation.
    • -f: Forces a database update.
    • -d: Download only (does not install).
    • -l [limit_chars]: Filters list output by specific [STATUS FLAGS].
    pkgin [-dfFhpPvVyn] [-l limit_chars] [-c chroot_path] [-t log_file] command [package ...]
  8. Filter installed packages by status flags

    master

    When using the list command with the -l modifier, you can filter installed packages using these status flags:

    • =: The installed version is current.
    • <: The installed version is older than the current version.
    • >: The installed version is newer than the current version.
    # Example: List only packages that have an update available
    pkgin list -l <
  9. Reference: pkgin global flags

    master

    The following flags can be used with the pkgin command to modify its execution behavior:

    -4          Force IPv4
    -6          Force IPv6
    -c <path>   Specify a chroot path
    -d          Download only (do not install)
    -f          Force update
    -h          Show usage
    -l <limit>  Set list output limit
    -n          No (automatic 'no' to prompts)
    -y          Yes (automatic 'yes' to prompts)
    -P          Show package version
    -t <file>   Trace output to file
    -v          Verbose
    -V          Show pkgin and pdb version
    -p          Parsable output
  10. Reference: pkgin subcommands

    master

    The following commands are available in pkgin (note: exact shortcuts depend on the internal cmd table defined in cmd.h):

    update              Update packages database
    install              Install a package and its dependencies
    upgrade               Upgrade packages
    full-upgrade         Full upgrade of all packages
    remove               Remove packages and reverse dependencies
    autoremove           Remove orphan packages
    keep                 Mark a package as "keep" (not automatic)
    unkeep               Mark a package as "unkeep" (automatic)
    show-keep            Show keep packages
    show-nokeep          Show non-keep packages
    search               Search for a package
    clean                Clean pkgin's packages cache
    export               Export PKGPATH for keep packages
    import               Import keep packages and install them
    show-provides        Show what a package provides
    show-requires        Show what a package requires
    show-info            Show remote package info (content, DESCR, build defs)
    show-category       Show package's category
    show-all-categories  Show all categories
    show-direct-deps     Show direct dependencies
    show-full-deps       Show full dependency tree
    show-rev-deps        Show full reverse dependency tree
    list-local           List local packages
    list-remote           List available packages
    stats                Show package statistics
  11. List available pkgin commands

    master
    The pkgin utility provides a wide range of commands for managing pkgsrc binary packages, including installation, removal, searching, and dependency inspection. Commands can often be invoked via their full name or a short alias.
  12. Use pkgin CLI options

    master

    The pkgin command supports several global flags that modify its behavior across different subcommands. These include network protocol selection, automation flags, and verbosity settings.

    pkgin [-46cdfhlnPtvVy] command [package ...]