• This repository has been archived on 29/Sep/2022
  • Stars
    star
    387
  • Rank 110,534 (Top 3 %)
  • Language
    Prolog
  • License
    BSD 2-Clause "Sim...
  • Created over 11 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Test-driven system administration with a little extra logic.

Marelle ("hopscotch")

Build Status Gitter

Test-driven system administration in SWI-Prolog, in the style of Babushka.

Marelle uses logic programming to describe system targets and rules by which these targets can be met. Prolog's built-in search mechanism makes writing and using these dependencies elegant. Anecdotally, writing deps for Marelle has the feel of teaching it about types of packages, rather than the feel of writing package templates.

Hopscotch for Seniors

Current status

Experimental but working. Not actively maintained.

Features

Marelle has some features common to other configuration management frameworks:

  • Checking and meeting dependencies (preconditions)
  • Testing whether a target installed correctly (post-conditions)
  • Ability to use platform-dependent instructions

It also has some interesting differences:

  • Can write checks (met predicates) without needing to say how to meet them (meet predicates)
  • The dependencies of a target can vary by platform
  • Succinct definition of new classes of packages using logical rules

Installing marelle

Quickstart

Pick a bootstrap script from the options below. If you're not sure, choose the stable version.

Version Bootstrap command
0.1.0 (stable) bash -c "$(curl -fsSL https://raw.githubusercontent.com/larsyencken/marelle/versions/0.1.0/bootstrap.sh)"
master (dev) bash -c "$(curl -fsSL https://raw.githubusercontent.com/larsyencken/marelle/master/bootstrap.sh)"

This will install marelle for all users, putting the executable in /usr/local/bin/marelle.

Manual version

  1. Get Prolog
    • On OS X, with Homebrew: brew install swi-prolog
    • On Ubuntu, with apt-get: sudo apt-get install swi-prolog-nox
    • On FreeBSD, with pkgng: sudo pkg install swi-pl
  2. Get git
    • On OS X, with Homebrew: brew install git
    • On Ubuntu, with apt-get: sudo apt-get install git
    • On FreeBSD, with pkgng: sudo pkg install git
  3. Clone and set up marelle
# clone the repo
mkdir -p ~/.local
git clone https://github.com/larsyencken/marelle ~/.local/marelle

# set up an executable in ~/.local/bin
mkdir -p ~/.local/bin
cat >~/.local/bin/marelle <<EOF
#!/bin/sh
exec swipl -q -t main -s ~/.local/marelle/marelle.pl "\$@"
EOF
chmod a+x ~/.local/bin/marelle

# add ~/.local/bin to your PATH
# (the exact commands depend on the shell you use)
echo 'export PATH=~/.local/bin:$PATH' >>~/.profile
source ~/.profile

Writing deps

Make a marelle-deps/ folder inside your project repo. Each package has two components, a met/2 goal which checks if the dependency is met, and an meet/2 goal with instructions on how to actually meet it if it's missing.

For example, suppose I want to write a dep for Python that works on recent Ubuntu flavours. I might write:

% python is a target to meet
pkg(python).

% it's installed if it exists at /usr/bin/python
met(python, linux(_)) :- exists_file('/usr/bin/python').

% we can install by running apt-get in shell
meet(python, linux(_)) :-
    % could also use: install_apt('python-dev')
    sh('sudo apt-get install -y python-dev').

To install python on a machine, I'd now run marelle meet python.

To install pip, I might write:

pkg(pip).

% pip is installed if we can run it
met(pip, _) :- which(pip).

% on all flavours of linux, try to install the python-pip package
meet(pip, linux(_)) :- install_apt('python-pip').

% on all platforms, pip depends on python
depends(pip, _, [python]).

Note our our use of platform specifiers and the _ wildcard in their place. To see your current platform as described by marelle, run marelle platform. Examples include: osx, linux(precise) and linux(raring).

Running deps

See available deps

This runs every met/2 statement that's valid for your platform.

marelle scan

Install something

This will run the meet/2 clause for your package, provided a valid one exists for your current platform.

marelle meet python

See your platform

To find the right platform code to use in deps you're writing, run:

marelle platform

It reports the code for the platform you're currently on.

Where to put your deps

Like both Babushka and Babashka, Marelle looks for deps in ~/.marelle/deps and in a folder called marelle-deps in the current directory, if either exists. This allows you to set up a personal set of deps for your environment, as well as project-specific deps.

Examples

See my marelle-deps repo for working examples.

Developing

Run make test to run the test suite.

More Repositories

1

csvdiff

Generate a diff between two tabular datasets expressed in CSV files.
Python
132
star
2

wide-language-index

An index of public broadcasts tagged by their primary language.
Python
50
star
3

pandoc-talk

A cookiecutter template for pandoc / XeTeX talks.
21
star
4

cjktools

Tools for processing CJK strings in Python
Python
19
star
5

simplecv-demo

SimpleCV demo scripts teaching some fundamentals of Computer Vision.
Python
17
star
6

marelle-deps

Configuration targets for Marelle.
Prolog
17
star
7

slowclap

Detect claps from your computer's microphone and act on them.
Python
11
star
8

simsearch

Search-by-similarity for Japanese kanji
CSS
10
star
9

questioner

Quickly ask questions on the command-line and annotate examples
Python
9
star
10

anytop

A command-line tool for viewing frequency distributions over streaming input.
Python
8
star
11

kanjitester

A research project which generates randomized vocab and kanji tests for JLPT levels N4 and N5.
Python
5
star
12

wegan

Generate an HTTP Archive dump for a page's performance using Chrome and Selenium
Scala
4
star
13

sql-constraint-checker

Check for violations of soft constraints in MySQL to keep data quality high.
Python
4
star
14

coursera-ml-2013-notes

Study notes for Coursera's 2013 Q4 Machine Learning subject.
4
star
15

cookiecutter-go-service

A template for new Go projects.
Go
4
star
16

cjkdata

Data files for the cjktools package.
Python
4
star
17

dotvim

My personal vim config.
Lua
3
star
18

doko

A command-line utility and Python module which reports your current location.
Python
3
star
19

cookiecutter-gitbook

A template for a new gitbook book.
Makefile
2
star
20

docker-vm

A Vagrant recipe for a VM with Docker installed and nothing else.
Prolog
2
star
21

shelly

Shell tools for working with data
Python
2
star
22

simplecv-vm

A Vagrant image for SimpleCV.
Shell
2
star
23

proj

Manage many folders of projects by periodically archiving them.
Python
1
star
24

gitbook-mcpy

Study notes: concurrency in Python
Makefile
1
star
25

ckan-vm

A Vagrant virtual machine for the CKAN open source data portal.
Prolog
1
star
26

referredby

A Python module for parsing referrer URLs, in particular for common search engines.
Python
1
star
27

dotcheat

Custom cheatsheets for use with the cheat command.
Julia
1
star
28

simplestats

A lightweight and minimal stats library for Python.
Python
1
star
29

babushka-deps

Ruby
1
star
30

code-library

A polyglot library of code examples.
Python
1
star
31

govhack2013-hansard

Hansard data hacking for GovHack 2013.
JavaScript
1
star
32

web-kata

Practice runs for building simple web tools.
Clojure
1
star
33

spatula

Web scraper for online recipe sites.
Python
1
star