Repo: https://github.com/UWCS/dcspkg
dcspkg is a simple 'package manager' designed primarily for distributing games from our servers to DCS systems. It was built to replace dcs-get, which was a cursed mess of PHP scripts.
dcspkg consists of 3 Rust crates:
.dcspkg
archivesInstalling via cargo is the easiest way to do it. Getting GitHub Actions to compile binaries and attatch them to a release would be useful (https://github.com/UWCS/dcspkg/issues/17).
cargo install dcspkg
(add --force
to update to latest version)❯ dcspkg --help
A command line installer and runner for dcspkg
Usage: dcspkg [OPTIONS] <COMMAND>
Commands:
list List all packages available for install
install Install a package
installed Show all installed packages and their versions
run Run the executable from the package specified
help Print this message or the help of the given subcommand(s)
Options:
-v, --verbose... Set the verbosity level
-h, --help Print help
-V, --version Print version
The repo is organised as a cargo workspace. It's one cargo project, but contains 3 crates:
dcspkg
is the command line client for downloading packagesdcspkg_server
is the server for serving packagesdcspkg_create
is a command line utility for adding a package to the serverdcspkg
)This is the tool that is used to interact with the server.
clap
is used to provide a nice clireqwest
is used for http requestsconfig-rs
is used to provide a configuration systemlist
install <pkgname>
installed
run <pkgname>
main.rs
lib.rs
Package
structconfig.rs
util.rs
cli.rs
commands
install.rs
list.rs
dcspkg_server
)The server provides a REST API for downloading packages. A database contains a registry of packages on disk, which are all just tarballs sat in a directory the server provides a file server into. Rocket is used as an async web framework, and sqlx is used to provide async database interaction.
It uses the lib exposed by dcspkg
to provide the definition of the Package
struct.
/list
- returns a list of all the packages in the database/pkgdata/<name>
- get all the data of a package by name/download
- a file server into the package directorymain.rs
db.rs
handlers.rs
dcspkg_create
)This tool takes a directory and packages it up, writing the metadata you give it to the database. See dcspkg-create --help
for usage info. The tool will prompt you with various options that you may configure.
main.rs
clap
db.rs
sqlx
here too, but use the smol
async runtime to wrap the async calls into synchronous functionsarchive.rs
opts.rs
All three crates in this repo serve different purposes, and have different deployment methods
The CLI is published to crates.io. CI is set up such that whenever a version tag is pushed, it will automatically create a release on Github, and then publish the current version to crates.io.
To trigger this, create a tag that starts with the letter v and contains a valid semver version, ie v0.2.1
(git tag v0.2.1
will tag the current commit), and then push the tag to Github (git push --tags
).
It would be nice if this CI job also built a binary and attached it to the release on Github for download.
The server is designed to run within a docker container. Every push to master will build a new container image for dcspkg-server
and publish it to ghcr.io/uwcs/dcspkg-server:latest
. Note that the server does not use the version of the library exposed by dcspkg
from crates.io, but from the main branch on Github
.
Re-deployment on the host will need to be done manually. This is done easiest using portainer, see the tech team wiki for more.
This doesn't really need deploying. If you need this tool, just pull the repo and build a binary.
A .dcspkg
file is just a .tar.gz
.
pkgname
in the databasedcspkg run
install.sh
script, which will be run by dcspkg install
if the database says that there is oneThe package repo is on beryllium at /home/uwcs/packages
.
packages/packagedb.sqlite
is the package databasepackages/packages
directory contains all the package archivesDocker uses a bind mount to mount this directory in the container. A bind mount is used over a volume to make it easier to add to/edit the package repos on the host system.
The CLI creates $HOME/.dcspkg
when you first use it.
.dcspkg/config.toml
contains the config for the cli
.dcspkg/registry.json
contains the metadata for all packages you have installed.dcspkg/bin
contains symlinks to executables for packages that requested to be added to path.dcspkg/package
contains all the packages