Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: stockpile - Git-Based Installation Management  (Read 2394 times)

TC01

  • Bay Watcher
    • View Profile
stockpile - Git-Based Installation Management
« on: January 20, 2017, 11:49:58 pm »

Over the holidays, I wrote stockpile: a program to manage Dwarf Fortress installations using version control. The goal is to allow a user to install DF once, create a git repository in that installation, and then install mods and tilesets on various branches of the repository. When a user wants to switch to a different mod, they simply switch the branch, and then any launcher or script that they have in place to launch their copy of DF will now run on top of the other branch.

I wrote stockpile because I wanted a solution for managing Dwarf Fortress mods that would not require me to maintain multiple installations of DF on my system. It was designed to integrate well with the Fedora packages of Dwarf Fortress that I maintain-- packages where a single copy of all the data and raw files are installed on the root filesystem and symbolically linked into each user's home directory. This means that updates to the package automatically update each user's DF installation, which is very convenient if you only want to play vanilla but less convenient if you want to deal with mods and tilesets.

There are three obvious problems that needed to be resolved:
  • Installing mods would require modification of files owned by root (in e.g. /usr/share/dwarffortress).
  • Installed mods would be permanent, i.e. there'd be no way to switch back to vanilla, at least until...
  • Installed mods would get overwritten by package updates the next time DF updated, and your modded copy of the game would no longer work.
Stockpile solves these problems as follows:
  • Now, installing mods can be done by creating a new branch in your local DF installation in your home directory.
  • Switching back to vanilla is as easy as switching to the master branch.
  • All non-master branches will be un-symlinked; that is to say, instead of having symbolic links to /usr/share/dwarffortress/raw, when you run "stockpile branch" to create a new branch, the symbolic link is removed and the raw files copied. Thus DF updates will not update your modded copies of DF but continue to update the vanilla copy.
While primarily useful for system-packaged Dwarf Fortress (as available on Fedora, Arch, and possibly other distributions too), managing modded installations via version control might potentially be of interest to other users too, which is why I figured I'd post about it. Note that stockpile is a command line program that's intended to be a lightweight solution to the problem of installation management.

Hopefully, this manages to be useful to someone other than me. :)

The code is MIT-licensed and written in Python 3 as a light wrapper around pygit2.

Installation:

Note that stockpile is, more or less, Linux only. That's not to say that it won't *work* on Windows (as noted, the code is in Python and should be cross platform), but that I'm mostly uninterested in testing things on Windows.

You can download Version 0.1 here.

If you're not running Fedora Linux, installing stockpile involves a couple of steps. While it's just written in Python, the name "stockpile" was already registered on PyPI, so installation is a bit trickier. You first need to download a release from the Gitlab page, and then install it. That can be done as follows on a Linux system with wget and pip installed:

Code: [Select]
$ wget https://gitlab.com/TC01/stockpile/uploads/619c3b6411a19ef8c8aa37324c58c2e6/stockpile-0.1.0.tar.gz
$ pip install ./stockpile-0.1.0.tar.gz

If you don't have pygit2 already installed, you may need libgit2-devel (or whatever the development headers are called on your system) in order for pip to build and install pygit2. Note that you will also need git installed and on your path. (This is likely to be what prevents stockpile from easily working on Windows).

If you are using Fedora, a Fedora package is available from my repository (alongside packages of dwarffortress, dfhack, etc.), and can be installed using the following commands.

Code: [Select]
$ wget -P /etc/yum.repos.d/ https://www.acm.jhu.edu/~bjr/fedora/dwarffortress/dwarffortress.repo
$ dnf install stockpile

Usage

Refer to the README for more detailed notes, but the basic idea is that you run "stockpile setup" to turn your DF installation into a git repository, then "stockpile branch [name]" to create a branch and "stockpile switch [branch]" to switch to and from a branch. "stockpile list-branches" will show you the current branches and which one you're on, and "stockpile delete" will allow you to delete a branch.

stockpile will always automatically commit the current state of the repository when creating a new branch or switching to a new branch (if there have been changes, that is).

By default, stockpile assumes that DF is installed in ~/.dwarffortress/, as it is done by the Fedora and Arch Linux packages. This can be overridden using a command line flag.

This is the first actual release, so it's totally possible that there are bugs or corner cases I've neglected. I have played around with stockpile a little since I wrote it and it seems to work just fine, though.

If you are using my Fedora repository, you can also install (work-in-progress) packages of milo christiansen's Rubble modding suite and install them in a stockpile branch. That can be done by e.g.:

Code: [Select]
$ dnf install rubble
$ stockpile setup
$ stockpile branch rubble
$ rubble
Logged
stockpile: git based installation management.
Dwarf Fortress for Fedora: Packages of DF and friends for Fedora Linux.

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: stockpile - Git-Based Installation Management
« Reply #1 on: January 24, 2017, 12:45:43 pm »

This looks interesting, too bad I don't have Linux installed on anything worth playing DF on...

Just from reading the instructions it sounds fairly easy to use too :)
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

jaked122

  • Bay Watcher
  • [PREFSTRING:Lurker tendancies]
    • View Profile
Re: stockpile - Git-Based Installation Management
« Reply #2 on: January 28, 2017, 01:16:08 pm »

This looks interesting, too bad I don't have Linux installed on anything worth playing DF on...


It's in python, it ought to work so long as you have a working python installation.


Python even has that pip tool to install pygit2 so you don't have to muck around with the binary files, I think.

tenach

  • Bay Watcher
    • View Profile
    • Personal Blog
Re: stockpile - Git-Based Installation Management
« Reply #3 on: March 12, 2017, 02:26:53 pm »

I'd been maintaining several installs of Dwarf Fortress in addition to the package I'd installed. This will simplify things so much! Thank you for sharing this script. :D
Logged