Skip to content

Commit

Permalink
Add a script to create a self-contained distribution tarball.
Browse files Browse the repository at this point in the history
  • Loading branch information
agraef authored and pierreguillot committed Aug 4, 2020
1 parent 22237ed commit 3fac5c8
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions make-dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#! /bin/bash

# Copyright (c) 2020 Albert Gräf <[email protected]>. Distributed under the
# MIT license, please check the toplevel LICENSE file for details.

# Create a self-contained distribution tarball from the source, including all
# the submodules.

# Invoke this in the toplevel directory as `./make-dist.sh`. It will leave the
# tarball as pd-faustgen-<version>.tar.gz in the toplevel directory. Temporary
# data is written to the pd-faustgen-<version> directory, which is
# automatically deleted afterwards. The version number is extracted from
# src/faustgen_tilde.c, so make sure to keep that up-to-date.

# NOTE: git and tar need to be installed to make this work. As a side-effect,
# all submodules will be checked out recursively, using `git submodule update
# --init --recursive`.

# This may need adjusting if the file is edited and the macro name changes.
version=$(grep "#define FAUSTGEN_VERSION_STR" src/faustgen_tilde.c | sed 's|^#define *FAUSTGEN_VERSION_STR *"\(.*\)".*|\1|')

# Distribution basename and name of the source tarball.
dist=pd-faustgen-$version
src=$dist.tar.gz

# Make sure that the submodules are initialized.
git submodule update --init --recursive

# List of submodules to include in the package. This requires git version
# 1.7.8 or later to work.
submodules=$(find . -mindepth 2 -name '.git' -type f -print | xargs grep -l "gitdir" | sed -e 's/^\.\///' -e 's/\.git$//')

# Remove any left-over temp directory and previous tarball.
rm -rf $dist $src
# Grab the main source.
git archive --format=tar.gz --prefix=$dist/ HEAD | tar xfz -
# Grab the submodules.
for x in $submodules; do (cd $dist && git -C ../$x archive --format=tar.gz --prefix=$x HEAD | tar xfz -); done

# Create the source tarball.
tar cfz $src $dist
rm -rf $dist

0 comments on commit 3fac5c8

Please sign in to comment.