Code Monkey home page Code Monkey logo

obsdpkgup's Introduction

obsdpkgup

x1$ time obsdpkgup
up to date
    0m01.69s real     0m00.51s user     0m00.25s system

Pre-requisites

  • Go: pkg_add go

Installation

go install github.com/neutralinsomniac/obsdpkgup/cmd/obsdpkgup@latest

Usage

Check for upgrades using signatures:

(see The Same-Version Rebuild Problem):

PKGUP_URL=https://pintobyte.com/pkgup/ obsdpkgup

Force checking snapshot directory for upgrades:

obsdpkgup -s

Run and apply found package upgrades:

obsdpkgup |doas sh

Cron mode (don't output anything when packages are up-to-date):

obsdpkgup -c

Rationale

OpenBSD's package tools are great. They've been battle-tested and designed to correctly handle package installation/upgrades even in the face of uncertain mirror conditions. They suffer from one problem however: with no central package index, in order to calculate an upgrade, the signature of every installed package must be checked against its signature on the configured mirror. This process can take anywhere from 1 to over 30 minutes to complete and uses a non-trivial amount of bandwidth, even if no updates are actually available. A simple solution to this would be to run package upgrades overnight through cron or some other mechanism, but not all OpenBSD machines are always-on computers, laptops being the prime example of this.

obsdpkgup attempts to solve the slow pkg_add -u dilemma while maintaining the consistency safeguards built into the pkgtools.

Theory of Operation

The lack of a central-index in the packaging system is an intentional decision. When an upgrade is requested while a mirror is in a partially-synced state, any central index may inevitably be out-of-sync with the state of the files present. If this index is solely relied on as a source of truth, then Bad Things can happen when an upgrade is attempted.

Because a central index may not accurately reflect the current state of a mirror, obsdpkgup uses its own index to seed a pkg_add -u call with a subset of packages it thinks have upgrades (with version numbers removed, to allow for flexibility in the mirror state). This prevents pkg_add from having to check every installed package individually, and instead enables it to check a much smaller list of potential upgrade candidates. This way, pkg_add will either do what it would've done with a full pkg_add -u call anyway (but with a much smaller list of packages to check), or in the case of a de-synced index, maybe report that a subset of the package candidate(s) are up-to-date, which will have no adverse effect on the system.

The Same-Version Rebuild Problem

Or, why can't we just compare version numbers in the mirror index?

Currently, the only index-like file available for obsdpkgup to check is a mirror's index.txt file. This file contains the external-facing version numbers of the packages available on the mirror, but does not reveal the internal openbsd-specific version that can be incremented in certain situations. When packages are rebuilt, and their external-facing versions aren't incremented, obsdpkgup can't tell that an upgrade occurred. Thus, a new index file format was created that contains a hash of a package's "signature" (the same thing that the pkgtools themselves check) and stores it in a secondary index file (called index.pkgup.gz). This file can be easily generated from an existing mirror using the genpkgup command included in this repo.

obsdpkgup's People

Contributors

neutralinsomniac avatar qbit avatar jrick avatar

Stargazers

Alin Mechenici avatar Jenn Wheeler avatar Marshall Conover avatar  avatar Anirudh Oppiliappan avatar Kamil avatar Diego Abad avatar Morgan Aldridge avatar Steve Jahl avatar Jay Williams avatar Andrew Vieyra avatar  avatar Jacob Moody avatar Sigrid Solveig Haflínudóttir avatar Evan Tann avatar

Watchers

Jay Williams avatar  avatar  avatar James Cloos avatar  avatar

Forkers

qbit murilobsd jrick

obsdpkgup's Issues

Respect Environnent Variables

I don't know if you are looking to handle other possible use cases, but pkg_add(1) supports a number of environment variables, two of which are relevant to your program PKG_PATH & TRUSTED_PKG_PATH.

Also, as of OpenBSD 6.6, syspatch(8) defaults to cdn.openbsd.org if an installurl isn't defined. I don't know if that would be useful to add or not, but I figured it was worth mentioning.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.