Skip to main content

Layered source layouts for software development projects

Project description

Layers
--------------

Layers is small utility for software developers that use aufs to merge several layers project into one.

.. note::
Project is in alpha-dev stage. Contributions, testing, feedback are really welcome.

Why?
====================

Layers allow to apply DRY principle to your project by merging several folders into one. Every software
project has some files that are copied from project to project without modification.

Examples:

- configuration files for your development stack
- .gitignore files
- directory structure
- ... more samples?


Usually this files are copied once, and it's big work to update them all after.


Aufs to help
===================

Aufs is layered filesystem that allows to merge several directories into one, and keep them writable.
Layers utility use aufs, to compose layers automatically.


Installation
===================


You need linux (not tested on other OSes yet) with aufs-tools installed, python-pip is also needed.
Usually you have all those if you ever use Docker, if not then google how to install this tools.

Install Layers::

sudo pip install layers

As mount command against curent directory is not possible (shows "directory busy" error), add alias for layers
command to execute it from parent dir, and then get you back in project directory. Execute in shell::

echo "layers() { LPD=\$PWD; cd ..; layers-util \$LPD \$@; cd \$LPD; }" >> ~/.bashrc
source ~/.bashrc

This will update your .bashrc automatically.


Quick start
===================


Let's prepare example directory structure::

mkdir project1
mkdir some-layer
mkdir another

project1 - is our project directory. Another too are layers.
We will put some data into "some-layer" and another::

echo "*.pyc" > some-layer/.gitignore
echo "Empty yet" > some-layer/README.txt

echo "John Doe (c) 2076 year" > another/AUTHOR.txt

Now create layers.yml file in your project1 directory, like this::

layers:

every-python-project-should-have-this:
path: ../some-layer

just-my-ego:
path: ../another

Now, lets mount this::

cd project1
layers mount

Now, ls should show the following::

ls project1

AUTHOR.txt layers.yml README.txt


Working with layers
=========================

If you make any changes in project1 directory, all changes will be recorded only on this layer,
so, if we change project1/README.txt, it will not affect "some-layer"::

$ cat project1/README.txt

Empty yet

$ echo "This is project readme" > project1/README.txt

$ cat project1/README.txt

This is project readme

$ cat some-layer/README.txt

Empty yet

But if you modify layers, changes are reflected::

$ echo ".more-to-ignore" >> some-layer/.gitignore

$ cat project1/.gitignore

*.pyc
.more-to-ignore


Auto-create mount-points
==========================

layers.yml have one interesting option that allow to create mount point before it mounted.
For example it can be checked out from git::


layers:

mfcloud-python:
path: ../python-django
create: git clone git@bitbucket.org:ribozz/python-django.git


Syntax here is::

create: {any valid bash command}


This may allow you to bootstrap your projects very quickly::

$ git clone my-repo-url-here my-project
$ cd my-project
$ layers mount


And magically all your layers are checked out and mounted.



Mount to different directory
==============================

"to" allows to mount to sub-directories::

layers:

cratis:
path: ../cratis
create: git clone git@bitbucket.org:itpeople/cratis.git
to: lib/cratis

cratis-features:
path: ../cratis-features
create: git clone git@bitbucket.org:itpeople/cratis-features.git
to: lib/cratis-features

mfcloud-python:
path: ../python-django
create: git clone git@bitbucket.org:ribozz/python-django.git



Command reference
======================

layers mount
*****************

Syntax:

layers mount

Mounts all layers referred in layers.yml


layers umount
*****************

Syntax:

layers umount

Unmounts all layers from current directory


layers commands
*****************

Syntax:

layers {some commmand}

chdir into every directory specified in layers.yml, and execute command.
Example::

$ layers ls -la

Layer /home/alex/dev/example/project1

total 24
drwxrwxr-x 8 alex alex 4096 sept 30 14:43 .
drwxrwxr-x 5 alex alex 4096 sept 30 13:59 ..
-rw-rw-r-- 1 alex alex 23 sept 30 14:04 AUTHOR.txt
-rw-rw-r-- 1 alex alex 22 sept 30 14:46 .gitignore
-rw-rw-r-- 1 alex alex 113 sept 30 14:05 layers.yml
-rw-rw-r-- 1 alex alex 23 sept 30 14:43 README.txt

Layer /home/alex/dev/example/some-layer

total 24
drwxrwxr-x 4 alex alex 4096 sept 30 14:06 .
drwxrwxr-x 5 alex alex 4096 sept 30 13:59 ..
-rw-rw-r-- 1 alex alex 22 sept 30 14:46 .gitignore
-rw-rw-r-- 1 alex alex 10 sept 30 14:42 README.txt
-r--r--r-- 1 root root 0 sept 30 14:06 .wh..wh.aufs
drwx------ 2 root root 4096 sept 30 14:06 .wh..wh.orph
drwx------ 2 root root 4096 sept 30 14:06 .wh..wh.plnk

Layer /home/alex/dev/example/another

total 20
drwxrwxr-x 4 alex alex 4096 sept 30 14:06 .
drwxrwxr-x 5 alex alex 4096 sept 30 13:59 ..
-rw-rw-r-- 1 alex alex 23 sept 30 14:04 AUTHOR.txt
-r--r--r-- 1 root root 0 sept 30 14:06 .wh..wh.aufs
drwx------ 2 root root 4096 sept 30 14:06 .wh..wh.orph
drwx------ 2 root root 4096 sept 30 14:06 .wh..wh.plnk


Another useful command is::

layers git status

Licence
======================

Apache licecne. See LICENCE for details

Changelog
======================


----------------------

0.1.5

- Improved handling of sub-mounts (to: ). (Alex.R.)

----------------------

0.1.4

- Fix installation pocess in setup.py. (Alex. R.)
- Improved sh script, made it more user-friendly. Added instructions to README how to pudate bashrc (Alex.R.)

----------------------

0.1.3

Added "to" to layers.yml (Alex R.)

---------------------

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

layers-0.1.5.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file layers-0.1.5.tar.gz.

File metadata

  • Download URL: layers-0.1.5.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for layers-0.1.5.tar.gz
Algorithm Hash digest
SHA256 641153e690ab39a86bc5da00a19bd2daad107ff983d0e24955d006e1cb86030c
MD5 a0128b3b8f5f7963dc5bc227a712aae3
BLAKE2b-256 d99235202726dd7c4408700914d997d42687b88b90c50ac808ebb81a85a12f36

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page