1 | #!/usr/bin/env bash |
---|
2 | |
---|
3 | # spkg-install file for sage root repo. |
---|
4 | |
---|
5 | CUR=`pwd` |
---|
6 | |
---|
7 | TARGET="$SAGE_ROOT" |
---|
8 | |
---|
9 | cd "$TARGET" |
---|
10 | # see if there is a valid Mercurial repository in $SAGE_ROOT |
---|
11 | hg verify 1>/dev/null 2>/dev/null |
---|
12 | if [ $? -eq 0 ]; then # valid repo |
---|
13 | |
---|
14 | # Merge the repository, rather than overwrite changes that the |
---|
15 | # user may have made. |
---|
16 | hg incoming "$CUR" 1> /dev/null |
---|
17 | if [ $? -eq 1 ]; then |
---|
18 | # No changes to pull |
---|
19 | exit 0 |
---|
20 | fi |
---|
21 | if [ $? -ne 0 ]; then |
---|
22 | echo "Error with Sage root repository: 'hg incoming' failed." |
---|
23 | exit 1 |
---|
24 | fi |
---|
25 | # $? = 0: There are changes to pull. |
---|
26 | # First check in any changes. |
---|
27 | |
---|
28 | hg commit |
---|
29 | status=$? |
---|
30 | if [ $status -ne 0 -a $status -ne 1 ]; then |
---|
31 | echo "Committing changes failed" |
---|
32 | exit 1 |
---|
33 | fi |
---|
34 | hg pull "$CUR" || { echo "Pulling from repo failed"; exit 1; } |
---|
35 | hg merge tip |
---|
36 | hg commit -m "Check-in during upgrade of Sage" |
---|
37 | status=$? |
---|
38 | if [ $status -ne 0 -a $status -ne 1 ]; then |
---|
39 | echo "Checking in new repo failed" |
---|
40 | exit 1 |
---|
41 | fi |
---|
42 | hg update || { echo "'hg update' failed"; exit 1; } |
---|
43 | |
---|
44 | else |
---|
45 | |
---|
46 | # Initial install. First get rid of "makefile" (since it's been |
---|
47 | # renamed to "Makefile" in the repo, and if both "makefile" and |
---|
48 | # "Makefile" are present, the former gets used). |
---|
49 | if [ -f "$TARGET"/makefile ]; then |
---|
50 | mv "$TARGET"/makefile "$TARGET"/Makefile.old |
---|
51 | fi |
---|
52 | if [ $? -ne 0 ]; then |
---|
53 | echo "Root repo: Error backing up old makefile" |
---|
54 | exit 1 |
---|
55 | fi |
---|
56 | |
---|
57 | # Now just copy all the files over. |
---|
58 | cd "$CUR" |
---|
59 | cp -rp .hg* COPYING.txt README.txt sage ipython "$TARGET" |
---|
60 | if [ $? -ne 0 ]; then |
---|
61 | echo "Root repo: Error copying files from Sage root repo to $TARGET" |
---|
62 | exit 1 |
---|
63 | fi |
---|
64 | |
---|
65 | if [ -f makefile ]; then |
---|
66 | cp makefile "$TARGET"/Makefile |
---|
67 | else |
---|
68 | cp Makefile "$TARGET" |
---|
69 | fi |
---|
70 | if [ $? -ne 0 ]; then |
---|
71 | echo "Root repo: Error copying Makefile" |
---|
72 | exit 1 |
---|
73 | fi |
---|
74 | |
---|
75 | mkdir -p "$TARGET/spkg/standard" |
---|
76 | if [ $? -ne 0 ]; then |
---|
77 | echo "Root repo: Error creating directory $TARGET/spkg/standard" |
---|
78 | exit 1 |
---|
79 | fi |
---|
80 | |
---|
81 | cd spkg |
---|
82 | cp README.txt gen_html install pipestatus root-spkg-install "$TARGET/spkg" |
---|
83 | if [ $? -ne 0 ]; then |
---|
84 | echo "Root repo: Error copying files to $TARGET/spkg" |
---|
85 | exit 1 |
---|
86 | fi |
---|
87 | |
---|
88 | cd standard |
---|
89 | cp README.txt deps libdist_filelist newest_version "$TARGET/spkg/standard" |
---|
90 | if [ $? -ne 0 ]; then |
---|
91 | echo "Root repo: Error copying files to $TARGET/spkg/standard" |
---|
92 | exit 1 |
---|
93 | fi |
---|
94 | |
---|
95 | fi |
---|