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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
#!/bin/bash
# Branch specs
PWD=$(pwd)
ARGS=("$@")
UCS_BRANCH=lp:component-store
UCS_FILEPATH=lp:~ubuntu-touch-community-dev/component-store/trunk.14.10/ComponentStore
BOOTSTRAP_FOLDER=${PWD}/ComponentStoreSetup
# Color Output
RC='\e[0;31m'
GC='\e[0;32m'
NC='\e[0m'
show_usage() {
echo "Usage:"
echo " ucs <command> [options]"
echo ""
echo "Commands:"
echo -e " install \tInstall Components"
echo -e " update \tUpdate Components"
echo -e " help \tdisplay this help and exit"
echo -e " version \toutput version information and exit"
}
install_prerequisites() {
if [ $(dpkg-query -W -f='${Status}' bzr 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
echo "bzr is not installed...installing it now.."
sudo apt-get install -y bzr --no-install-recommends;
fi
}
if [ $# -lt 1 ]
then
show_usage
exit 1
fi
#CASE: HELP ARGUMENT
if [[ $1 == "help" ]]; then
show_usage
exit 0
#CASE: ABOUT ARGUMENT
elif [[ $1 == "version" ]]; then
echo "Ubuntu Component Store (UCS) v0.1.2"
echo "Copyright (C) 2014 Ubuntu Touch Community Dev Team"
echo "License GPLv3: GNU version 3 <http://gnu.org/licenses/gpl.html>."
echo "This is free software: you are free to change and redistribute it."
echo "There is NO WARRANTY, to the extent permitted by law."
echo
echo "Written by Ubuntu Touch Community Dev"
exit 0
#CASE: INSTALL ARGUMENT
elif [[ $1 == "install" ]]; then
install_prerequisites
if [ $# -gt 1 ]; then
for (( i=1; i<$#; i++ ))
do
echo -n "[$i/`expr $# - 1`] Installing ${ARGS[$i]}..."
componentfilelist=(`bzr ls -q $UCS_FILEPATH/${ARGS[$i]}`)
componentfilelistcount=${#componentfilelist[@]}
if (( componentfilelistcount == 0 )); then
echo -e "${RC}FAILED${NC} (Invalid component name)"
else
for (( j=0; j<componentfilelistcount; j++ ))
do
filename=$(basename ${componentfilelist[j]})
bzr cat -q ${componentfilelist[j]} > ${PWD}/${filename}
done
echo -e "${GC}DONE${NC}"
fi
done
else
echo -n "Installing all components..."
componentlist=(`bzr ls -q $UCS_FILEPATH`)
componentlistcount=${#componentlist[@]}
for (( i=0; i<componentlistcount; i++ ))
do
componentfilelist=(`bzr ls -q ${componentlist[i]}`)
componentfilelistcount=${#componentfilelist[@]}
for (( j=0; j<componentfilelistcount; j++ ))
do
bzr cat -q ${componentlist[i]}${componentfilelist[j]} > ${PWD}/${componentfilelist[j]}
done
done
echo -e "${GC}DONE${NC}"
fi
echo -e "${GC}Installation Complete!${NC}"
#CASE: UPDATE ARGUMENT
elif [[ $1 == "update" ]]; then
if [ $# -gt 1 ]; then
for (( i=1; i<$#; i++ ))
do
echo -n "[$i/`expr $# - 1`] Updating ${ARGS[$i]}..."
componentfilelist=(`bzr ls -q $UCS_FILEPATH/${ARGS[$i]}`)
componentfilelistcount=${#componentfilelist[@]}
if (( componentfilelistcount == 0 )); then
echo -e "${RC}FAILED${NC} (Invalid component name)"
else
for (( j=0; j<componentfilelistcount; j++ ))
do
filename=$(basename ${componentfilelist[j]})
bzr cat -q ${componentfilelist[j]} > ${PWD}/${filename}
done
echo -e "${GC}DONE${NC}"
fi
done
echo -e "${GC}Updating Components Complete!${NC}"
else
echo -e "${RC}Error updating components! Please specify the component name you want to update. Eg. ucs update EmptyState${NC}"
fi
fi
|