forked from sagemath/sagenb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist.sh
executable file
·70 lines (58 loc) · 1.71 KB
/
dist.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
# This script should be run when creating a new SPKG for shipping sagenb
# with Sage. For more complete instructions on how to generate a new
# SPKG, read the SPKG.txt file in the current SPKG.
#
# Usage: dist.sh [-g] [-s]
#
# -g Also package the git repository
# -s Only package the sagenb repository
die () {
echo >&2 "$@"
exit 1
}
while getopts ":gs" opt; do
case $opt in
g) INSTALL_REPO=1 ;;
s) SAGENB_ONLY=1 ;;
*) die "Invalid option!"
esac
done
cd ${0%/*}
if [ -n "$INSTALL_REPO" ]; then
git diff --quiet && git diff --cached --quiet ||
die "Uncommitted changes in sagenb - please commit, stash, or discard"
fi
if [ -n "$SAGENB_ONLY" ]; then
if [ -d dist ]; then
rm -f dist/sagenb-*
else
mkdir -p dist
fi
else
rm -rf dist
mkdir -p dist
fi
if [ -z "$SAGENB_ONLY" ]; then
echo "Fetching source tarballs of (sub)dependencies of sagenb to dist/"
python util/fetch_deps.py dist || die "Couldn't fetch all (sub)dependencies"
fi
echo "Creating source tarball of sagenb itself in dist/"
python setup.py sdist > sdist.log || die "Couldn't make sagenb source tarball"
if [ -n "$INSTALL_REPO" ]; then
echo "Sanitizing sagenb git repo (with backup)"
mv .git .git-backup
git init
git fetch .git-backup
git remote add sagemath https://github.com/sagemath/sagenb
git branch -f master FETCH_HEAD
git remote update sagemath
git branch --set-upstream master sagemath/master
git reset --mixed
git gc --aggressive --prune=0
echo "Moving sanitized sagenb git repo to dist/"
mv .git dist/sagenb.git
echo "Restoring backup of git repo"
mv .git-backup .git
fi
echo "Done!"