Ticket #9433: root-spkg-install.v2

File root-spkg-install.v2, 2.2 KB (added by jhpalmieri, 9 years ago)

the file SAGE_ROOT/spkg/root-spkg-install

Line 
1#!/usr/bin/env bash
2
3# spkg-install file for sage root repo.
4
5CUR=`pwd`
6
7TARGET="$SAGE_ROOT"
8
9cd "$TARGET"
10# see if there is a valid Mercurial repository in $SAGE_ROOT
11hg verify 1>/dev/null 2>/dev/null
12if [ $? -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 ci || { echo "Committing changes failed"; exit 1; } 
29    hg pull "$CUR" || { echo "Pulling from repo failed"; exit 1; } 
30    hg merge tip
31    hg ci -m "Check-in during upgrade of Sage." || \
32        { echo "Checking in new repo failed"; exit 1; }
33    hg update || { echo "'hg update' failed"; exit 1; }
34
35else
36
37    # Initial install.  First get rid of "makefile" (since it's been
38    # renamed to "Makefile" in the repo, and if both "makefile" and
39    # "Makefile" are present, the former gets used).
40    if [ -f "$TARGET"/makefile ]; then
41        mv "$TARGET"/makefile "$TARGET"/Makefile.old
42    fi
43    if [ $? -ne 0 ]; then
44        echo "Root repo: Error backing up old makefile"
45        exit 1
46    fi
47
48    # Now just copy all the files over.
49    cd "$CUR"
50    cp -rp .hg* COPYING.txt README.txt sage ipython "$TARGET"
51    if [ $? -ne 0 ]; then
52        echo "Root repo: Error copying files from Sage root repo to $TARGET"
53        exit 1
54    fi
55   
56    if [ -f makefile ]; then
57        cp makefile "$TARGET"/Makefile
58    else
59        cp Makefile "$TARGET"
60    fi
61    if [ $? -ne 0 ]; then
62        echo "Root repo: Error copying Makefile"
63        exit 1
64    fi
65   
66    mkdir -p "$TARGET/spkg/standard"
67    if [ $? -ne 0 ]; then
68        echo "Root repo: Error creating directory $TARGET/spkg/standard"
69        exit 1
70    fi
71
72    cd spkg
73    cp README.txt gen_html install pipestatus root-spkg-install "$TARGET/spkg"
74    if [ $? -ne 0 ]; then
75        echo "Root repo: Error copying files to $TARGET/spkg"
76        exit 1
77    fi
78
79    cd standard
80    cp README.txt deps libdist_filelist newest_version "$TARGET/spkg/standard"
81    if [ $? -ne 0 ]; then
82        echo "Root repo: Error copying files to $TARGET/spkg/standard"
83        exit 1
84    fi
85
86fi