Giter VIP home page Giter VIP logo

fapt's Introduction

Faux' apt

Build status

This is a library-like tool for interacting with Debian/Ubuntu package metadata, like one would expect from apt or aptitude. These tools are not arranged as libraries, however, so it is rather hard to drive them in this manner.

This project is pure, safe Rust, and runs fine on Windows, OSX, etc. It does not need root, unless you want it to write to root-only directories.

It does not currently contain a way to install packages, so cannot be used as a replacement for apt.

It is intended to give access to the data when necessary, for example:

let mut fapt = System::cache_only()?;
commands::add_sources_entries_from_str(&mut fapt, src_line)?;
commands::add_builtin_keys(&mut fapt);
fapt.update()?;

for block in commands::all_blocks(&fapt)? {

This can be seen in one of the examples:

% cargo run -q --example \
   list_source_packages deb-src https://deb.debian.org/debian buster main non-free
Downloading: https://deb.debian.org/debian/dists/buster/InRelease ... complete.
Downloading: https://deb.debian.org/debian/dists/buster/main/source/by-hash/SHA256/c3a1781dc47ba30d2c29eafd556d36917bb180c1f55c4862fedd48da28a2042f ... complete.
0ad
0ad-data
0xffff
...

There is also support for parsing these HashMap<String, Strings>s into a proper object.

This difference between the two APIs can be seen in the list_latest_source_map (for the map API), and the list_latest_source_obj (for the object API). The map API is more stable, as it does less work, and leaves parsing and error handling to you.

Data model

Here is an example sources list entry on an amd64 machine:

deb     https://deb.debian.org/debian sid main contrib
deb-src https://deb.debian.org/debian sid main contrib

This is interpreted as:

  1. Download https://deb.debian.org/debian/dists/sid/Release. This is called the ReleaseFile.
  2. Look through it for entries named the following. Each of these is called a Listing:
    • main/binary-amd64/Packages
    • contrib/binary-amd64/Packages
    • main/source/Sources
    • contrib/source/Sources
  3. Download them all.

This result (ignoring verification and compression) is now a list of Blocks.

Each Block contains multiple Fields.

Each group of Fields probably describes a Package, either a source or binary package.

fapt's People

Contributors

fauxfaux avatar oddbloke avatar

Stargazers

 avatar Kira Bruneau avatar GAURAV avatar Joel Gallant avatar Philippe Ombredanne avatar Andrejs Agejevs avatar

Watchers

 avatar James Cloos avatar  avatar

fapt's Issues

Does not handle non-"Name <Email>" as `Original-Maintainer`

This stanza is in xenial's main Packages and causes fapt to fail to parse the file:

Package: onboard
Priority: optional
Section: gnome
Installed-Size: 3448
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: https://launchpad.net/~onboard/+contactuser
Architecture: amd64
Version: 1.2.0-0ubuntu5
Depends: python3 (<< 3.6), python3 (>= 3.5~), libc6 (>= 2.14), libcairo2 (>= 1.10.0), libcanberra0 (>= 0.2), libdconf1 (>= 0.14.0), libgcc1 (>= 1:3.0), libglib2.0-0 (>= 2.31.8), libgtk-3-0 (>= 3.0.0), libhunspell-1.3-0 (>= 1.3.3), libstdc++6 (>= 5.2), libx11-6, libxi6 (>= 2:1.2.99.4), libxkbfile1, libxtst6, dconf-gsettings-backend | gsettings-backend, python3-cairo, python3-gi-cairo, python3-dbus, gir1.2-gtk-3.0, gir1.2-pango-1.0 (>= 1.29.3), gir1.2-glib-2.0, gir1.2-gdkpixbuf-2.0, librsvg2-common, iso-codes
Recommends: gir1.2-appindicator3-0.1, gir1.2-atspi-2.0, onboard-data (>= 0.99.0~alpha1~tr1531), xdg-utils
Suggests: mousetweaks (>= 3.3.90)
Filename: pool/main/o/onboard/onboard_1.2.0-0ubuntu5_amd64.deb
Size: 512272
MD5sum: a850ebb030974c63a04be8fc6fe9dfaf
SHA1: e83fc1cb906a033d25d22ae15a4f59fa260b4c7e
SHA256: 8b82b9e2642dd2c74a4de37256479bcd8527744ca25d08950243afe87a9e83e0
Description: Simple On-screen Keyboard
Homepage: https://launchpad.net/onboard
Description-md5: eb9f6a3a613f7e33ed5ad60de6a693f6
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 5y
Task: ubuntu-desktop, ubuntu-usb, edubuntu-desktop, edubuntu-usb, xubuntu-desktop, ubuntustudio-desktop, ubuntukylin-desktop, ubuntu-mate-core, ubuntu-mate-desktop, ubuntu-mate-cloudtop

Asynchronous fetching of dist files

For Pop!_OS, I've just written async-fetcher (Crates.io), which could greatly enhance your current capabilities. It has been implemented with fetching apt dist files in mind, as can be seen from the example that fetches a few files from our debian repository.

Some of the key features are:

  • Checking if a file requires to be downloaded based on the modified time if no checksum is provided.
  • Comparing the checksum of a local file to determine if a GET request is required.
  • Enabling the caller to provide a checksum to check against the downloaded file's contents.
  • Enabling the caller to define how the downloaded file is processed into the destination, such as decompression.
  • Enabling the caller to use a different checksum to compare the checksum of the destination file.
  • Setting the file time of the fetched files to the modified time on the server.
  • Supports execution in a parallel tokio runtime.

This would be useful to fetch a compressed dist file, compare the checksum of the compressed checksum, decompress it if it's fine, and then check the checksum of the decompressed files.

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.