GNU Linux-libre 6.8.7-gnu
[releases.git] / tools / power / pm-graph / install_latest_from_github.sh
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3 #
4 # Script which clones and installs the latest pm-graph
5 # from http://github.com/intel/pm-graph.git
6
7 OUT=`mktemp -d 2>/dev/null`
8 if [ -z "$OUT" -o ! -e $OUT ]; then
9         echo "ERROR: mktemp failed to create folder"
10         exit
11 fi
12
13 cleanup() {
14         if [ -e "$OUT" ]; then
15                 cd $OUT
16                 rm -rf pm-graph
17                 cd /tmp
18                 rmdir $OUT
19         fi
20 }
21
22 git clone http://github.com/intel/pm-graph.git $OUT/pm-graph
23 if [ ! -e "$OUT/pm-graph/sleepgraph.py" ]; then
24         echo "ERROR: pm-graph github repo failed to clone"
25         cleanup
26         exit
27 fi
28
29 cd $OUT/pm-graph
30 echo "INSTALLING PM-GRAPH"
31 sudo make install
32 if [ $? -eq 0 ]; then
33         echo "INSTALL SUCCESS"
34         sleepgraph -v
35 else
36         echo "INSTALL FAILED"
37 fi
38 cleanup