3: ${MAFIA_HOME:=$HOME/.mafia}
6 if [ -z ${MAFIA_TEST_MODE+x} ]; then
8 curl --silent "https://raw.githubusercontent.com/ambiata/mafia/master/script/mafia?$TZ"
15 git ls-remote https://github.com/ambiata/mafia | grep refs/heads/master | cut -f 1
19 awk '/^# Version: / { print $3; exit 0; }' $0
23 MAFIA_TEMP=$(mktemp 2>/dev/null || mktemp -t 'upgrade_mafia')
33 if [ -L "$MAFIA_CUR" ]; then
34 echo 'Refusing to overwrite a symlink; run `upgrade` from the canonical path.' >&2
38 echo "Checking for a new version of mafia ..."
39 fetch_latest > $MAFIA_TEMP
41 LATEST_VERSION=$(latest_version)
42 echo "# Version: $LATEST_VERSION" >> $MAFIA_TEMP
44 if ! cmp $MAFIA_CUR $MAFIA_TEMP >/dev/null 2>&1; then
45 mv $MAFIA_TEMP $MAFIA_CUR
47 echo "New version found and upgraded. You can now commit it to your git repo."
49 echo "You have latest mafia."
54 MAFIA_VERSION=$(local_version)
56 if [ "x$MAFIA_VERSION" = "x" ]; then
57 # If we can't find the mafia version, then we need to upgrade the script.
60 MAFIA_BIN=$MAFIA_HOME/bin
61 MAFIA_FILE=mafia-$MAFIA_VERSION
62 MAFIA_PATH=$MAFIA_BIN/$MAFIA_FILE
64 [ -f "$MAFIA_PATH" ] || {
65 # Create a temporary directory which will be deleted when the script
66 # terminates. Unfortunately `mktemp` doesn't behave the same on
67 # Linux and OS/X so we need to try two different approaches.
68 MAFIA_TEMP=$(mktemp -d 2>/dev/null || mktemp -d -t 'exec_mafia')
70 # Create a temporary file in MAFIA_BIN so we can do an atomic copy/move dance.
79 echo "Building $MAFIA_FILE in $MAFIA_TEMP"
83 git clone https://github.com/ambiata/mafia
86 git reset --hard $MAFIA_VERSION
88 bin/bootstrap ) || exit $?
90 MAFIA_PATH_TEMP=$(mktemp --tmpdir=$MAFIA_BIN $MAFIA_FILE-XXXXXX 2>/dev/null || TMPDIR=$MAFIA_BIN mktemp -t $MAFIA_FILE)
94 rm -f "$MAFIA_PATH_TEMP"
96 trap clean_up_temp EXIT
98 cp "$MAFIA_TEMP/mafia/.cabal-sandbox/bin/mafia" "$MAFIA_PATH_TEMP"
99 chmod 755 "$MAFIA_PATH_TEMP"
100 mv "$MAFIA_PATH_TEMP" "$MAFIA_PATH"
105 exec $MAFIA_PATH "$@"
110# The actual start of the script.....
120upgrade) shift; run_upgrade "$@" ;;
123# Version: 360716306a06db842ec022a7b9f161d2208483f0
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list