Commit 3d8d89cad3302ce2f58644f66eba53d55e68f064

Authored by mj
1 parent 7b79866ceb
Exists in master

[FIX] repos.sh

Showing 1 changed file with 3 additions and 3 deletions Inline Diff

1 #!/bin/bash 1 #!/bin/bash
2 2
3 # export ADD_REMOTE="NO" 3 # export ADD_REMOTE="NO"
4 # export REMOTE_BRANCH="8.0" 4 # export REMOTE_BRANCH="8.0"
5 # export PATH_PREFIX=".repos" 5 # export PATH_PREFIX=".repos"
6 # export PATH_START="addons" 6 # export PATH_START="addons"
7 # export SYMLINKS_PATH="odoo-addons" 7 # export SYMLINKS_PATH="odoo-addons"
8 # export ADHOC_PATH="addons-adhoc" 8 # export ADHOC_PATH="addons-adhoc"
9 # export CREATE_LINKS=1 9 # export CREATE_LINKS=1
10 # export DEF_REPO="XX" 10 # export DEF_REPO="XX"
11 11
12 # Build environment from env.txt file 12 # Build environment from env.txt file
13 while read line; do 13 while read line; do
14 export "$line" 14 export "$line"
15 done < env.txt 15 done < env.txt
16 16
17 export GIT_EDITOR=true 17 export GIT_EDITOR=true
18 18
19 read -e -p "Enter a list of github repos, separated by comma; or enter for update: " -i "" ACTION 19 read -e -p "Enter a list of github repos, separated by comma; or enter for update: " -i "" ACTION
20 20
21 if [ "$ACTION" != "" ]; then 21 if [ "$ACTION" != "" ]; then
22 ADD_ADDON_REPOS=($(printf "$ACTION" | tr "," "\n")) 22 ADD_ADDON_REPOS=($(printf "$ACTION" | tr "," "\n"))
23 ACTION="" 23 ACTION=""
24 else 24 else
25 UPDATE="1" 25 UPDATE="1"
26 i=0 26 i=0
27 j=0 27 j=0
28 while read line; do 28 while read line; do
29 if [ "$i" -gt "6" ] && [ "$line" != "" ]; then 29 if [ "$i" -gt "6" ] && [ "$line" != "" ]; then
30 if [ "$line" != "Unsorted (inserted by repos.sh)" ] && [ "$line" != "===============================" ]; then 30 if [ "$line" != "Unsorted (inserted by repos.sh)" ] && [ "$line" != "===============================" ]; then
31 ADD_ADDON_REPOS[$j]=$line 31 ADD_ADDON_REPOS[$j]=$line
32 j=$[j+1] 32 j=$[j+1]
33 fi 33 fi
34 fi 34 fi
35 i=$[i+1] 35 i=$[i+1]
36 done < ADD.md 36 done < ADD.md
37 # set some vars for updating: 37 # set some vars for updating:
38 ADD_REMOTE="NO" 38 ADD_REMOTE="NO"
39 read -e -p "Trying to update $[j+1] repos; enter to continue, input to quit: " -i "" ACTION 39 read -e -p "Trying to update $[j+1] repos; enter to continue, input to quit: " -i "" ACTION
40 fi 40 fi
41 41
42 if [ "$ACTION" != "" ]; then 42 if [ "$ACTION" != "" ]; then
43 exit 0 43 exit 0
44 else 44 else
45 printf "...................................................START...................................................\n" 45 printf "...................................................START...................................................\n"
46 if [ "$DEF_REPO" ]; then 46 if [ "$DEF_REPO" ]; then
47 if [ "$DEF_REPO" != "XX" ]; then 47 if [ "$DEF_REPO" != "XX" ]; then
48 printf "set var 'ADD_ADDON_REPOS'\n" 48 printf "set var 'ADD_ADDON_REPOS'\n"
49 ADD_ADDON_REPOS=("$DEF_REPO") 49 ADD_ADDON_REPOS=("$DEF_REPO")
50 fi 50 fi
51 fi 51 fi
52 if [ ! "$REMOTE_BRANCH" ]; then 52 if [ ! "$REMOTE_BRANCH" ]; then
53 REMOTE_BRANCH="8.0" 53 REMOTE_BRANCH="8.0"
54 fi 54 fi
55 if [ ! "$SYMLINKS_PATH" ]; then 55 if [ ! "$SYMLINKS_PATH" ]; then
56 SYMLINKS_PATH="odoo-addons" 56 SYMLINKS_PATH="odoo-addons"
57 fi 57 fi
58 if [ ! "$PATH_START" ]; then 58 if [ ! "$PATH_START" ]; then
59 PATH_START="addons" 59 PATH_START="addons"
60 fi 60 fi
61 if [ ! "$PATH_PREFIX" ]; then 61 if [ ! "$PATH_PREFIX" ]; then
62 PATH_PREFIX=".repos" 62 PATH_PREFIX=".repos"
63 fi 63 fi
64 if [ ! "$ADD_REMOTE" ]; then 64 if [ ! "$ADD_REMOTE" ]; then
65 ADD_REMOTE="YES" 65 ADD_REMOTE="YES"
66 fi 66 fi
67 if [ ! "$CREATE_LINKS" ]; then 67 if [ ! "$CREATE_LINKS" ]; then
68 CREATE_LINKS=1 68 CREATE_LINKS=1
69 fi 69 fi
70 # :' = Multiline Comment 70 # :' = Multiline Comment
71 # ADDED_REPOS=":'\n" 71 # ADDED_REPOS=":'\n"
72 ADDED_REPOS="" 72 ADDED_REPOS=""
73 NOT_ADDED_REPOS="" 73 NOT_ADDED_REPOS=""
74 74
75 MAIN_BRANCH=${REMOTE_BRANCH} 75 MAIN_BRANCH=${REMOTE_BRANCH}
76 76
77 for i in "${ADD_ADDON_REPOS[@]}"; do 77 for i in "${ADD_ADDON_REPOS[@]}"; do
78 printf "repo '$i'\n" 78 printf "repo '$i'\n"
79 79
80 # Defaults 80 # Defaults
81 CREATE_LINKS=1 81 CREATE_LINKS=1
82 82
83 83
84 j=($(printf "$i" | tr "~!~" "\n")) 84 j=($(printf "$i" | tr "~!~" "\n"))
85 if [ ${j[1]} ]; then 85 if [ ${j[1]} ]; then
86 i=${j[0]} 86 i=${j[0]}
87 if [ ${j[1]} = "CREATE_LINKS=2" ]; then 87 if [ ${j[1]} = "CREATE_LINKS=2" ]; then
88 CREATE_LINKS=2 88 CREATE_LINKS=2
89 fi 89 fi
90 fi 90 fi
91 91
92 j=($(printf "$i" | tr ":" "\n")) 92 j=($(printf "$i" | tr ":" "\n"))
93 if [ ${j[1]} ]; then 93 if [ ${j[1]} ]; then
94 i=${j[0]} 94 i=${j[0]}
95 REMOTE_BRANCH=${j[1]} 95 REMOTE_BRANCH=${j[1]}
96 fi 96 fi
97 printf "~~~~~~~~~~~~ USING BRANCH: $REMOTE_BRANCH ~~~~~~~~~~~~\n" 97 printf "~~~~~~~~~~~~ USING BRANCH: $REMOTE_BRANCH ~~~~~~~~~~~~\n"
98 98
99 REPO=${i} && REPL="--" && REMOTE=${REPO/\//$REPL} 99 REPO=${i} && REPL="--" && REMOTE=${REPO/\//$REPL}
100 if [ "$UPDATE" = "1" ]; then 100 if [ "$UPDATE" = "1" ]; then
101 git fetch --no-tags remote--${REMOTE} 101 git fetch --no-tags remote--${REMOTE}
102 SUBTREE_CMD="pull" 102 SUBTREE_CMD="pull"
103 git subtree ${SUBTREE_CMD} --prefix=${PATH_PREFIX}/${REPO} remote--${REMOTE} ${REMOTE_BRANCH} --squash -q 103 git subtree ${SUBTREE_CMD} --prefix=${PATH_PREFIX}/${REPO} remote--${REMOTE} ${REMOTE_BRANCH} --squash -q
104 104
105 # while read line; do 105 # while read line; do
106 # if [[ ${REPO} == ${line} ]]; then 106 # if [[ ${REPO} == ${line} ]]; then
107 # printf "++++++ MATCH ++++++\n" 107 # printf "++++++ MATCH ++++++\n"
108 # CREATE_LINKS=0 108 # CREATE_LINKS=0
109 # fi 109 # fi
110 # printf "+++++ NOMATCH +++++ ${REPO} \n" 110 # printf "+++++ NOMATCH +++++ ${REPO} \n"
111 # #printf ${REPO} 111 # #printf ${REPO}
112 # done < ignore.txt 112 # done < ignore.txt
113 113
114 elif [ "$ADD_REMOTE" = "YES" ]; then 114 elif [ "$ADD_REMOTE" = "YES" ]; then
115 git remote add -f --no-tags remote--${REMOTE} https://github.com/${REPO}.git 115 git remote add -f --no-tags remote--${REMOTE} https://github.com/${REPO}.git
116 SUBTREE_CMD="add" 116 SUBTREE_CMD="add"
117 git subtree ${SUBTREE_CMD} --prefix=${PATH_PREFIX}/${REPO} remote--${REMOTE}/${REMOTE_BRANCH} --squash 117 git subtree ${SUBTREE_CMD} --prefix=${PATH_PREFIX}/${REPO} remote--${REMOTE}/${REMOTE_BRANCH} --squash
118 fi 118 fi
119 ADDED_REPOS+=${REPO} 119 ADDED_REPOS+=${REPO}
120 ADDED_REPOS+='\n' 120 ADDED_REPOS+='\n'
121 121
122 if [ "$CREATE_LINKS" != 0 ]; then 122 if [ "$CREATE_LINKS" != 0 ]; then
123 if [ "$CREATE_LINKS" = 1 ]; then 123 if [ "$CREATE_LINKS" = 1 ]; then
124 for j in ${PATH_PREFIX}/${REPO}/* ; do 124 for j in ${PATH_PREFIX}/${REPO}/* ; do
125 if [ -d "$j" ]; then 125 if [ -d "$j" ]; then
126 n=${j##*/} 126 n=${j##*/}
127 if [ "$n" != "__unported__" ]; then 127 if [ "$n" != "__unported__" ]; then
128 if [ -h ${SYMLINKS_PATH}/$n ]; then 128 if [ -h "${SYMLINKS_PATH}/$n" ]; then
129 printf "symlink exists '${REPO}/$n'\n" 129 printf "symlink exists '${REPO}/$n'\n"
130 if [ "$ADD_REMOTE" = "YES" ]; then 130 if [ "$ADD_REMOTE" = "YES" ]; then
131 NOT_ADDED_REPOS="$NOT_ADDED_REPOS\n${REPO}/$n" 131 NOT_ADDED_REPOS="$NOT_ADDED_REPOS\n${REPO}/$n"
132 fi 132 fi
133 else 133 else
134 printf "create symlink 1: '${REPO}/$n'\n" 134 printf "create symlink 1: '${REPO}/$n'\n"
135 ln -s "../../${PATH_PREFIX}/${REPO}/$n" "${SYMLINKS_PATH}/$n" 135 ln -s "../../${PATH_PREFIX}/${REPO}/$n" "${SYMLINKS_PATH}/$n"
136 fi 136 fi
137 if [ -h ${ADHOC_PATH}/$n ]; then 137 if [ -h "${ADHOC_PATH}/$n" ]; then
138 printf "delete adhoc\n" 138 printf "delete adhoc\n"
139 rm ${ADHOC_PATH}/$n 139 rm "${ADHOC_PATH}/$n"
140 fi 140 fi
141 fi 141 fi
142 fi 142 fi
143 done 143 done
144 elif [ "$CREATE_LINKS" = 2 ]; then 144 elif [ "$CREATE_LINKS" = 2 ]; then
145 printf "create symlink 2: '${REPO}/'\n" 145 printf "create symlink 2: '${REPO}/'\n"
146 REPO_SEP=($(printf "$REPO" | tr "/" "\n")) 146 REPO_SEP=($(printf "$REPO" | tr "/" "\n"))
147 if [ ${REPO_SEP[1]} ]; then 147 if [ ${REPO_SEP[1]} ]; then
148 REPO=${REPO_SEP[1]} 148 REPO=${REPO_SEP[1]}
149 PATH_PREFIX+="/${REPO_SEP[0]}" 149 PATH_PREFIX+="/${REPO_SEP[0]}"
150 fi 150 fi
151 ln -s "../../${PATH_PREFIX}/${REPO}" "${SYMLINKS_PATH}/${REPO}" 151 ln -s "../../${PATH_PREFIX}/${REPO}" "${SYMLINKS_PATH}/${REPO}"
152 PATH_PREFIX=".repos" 152 PATH_PREFIX=".repos"
153 elif [ "$CREATE_LINKS" = 3 ]; then 153 elif [ "$CREATE_LINKS" = 3 ]; then
154 ln -s ${SYMLINKS_PATH}/${REPO} ${PATH_START}/ 154 ln -s ${SYMLINKS_PATH}/${REPO} ${PATH_START}/
155 else 155 else
156 ln -s ${SYMLINKS_PATH}/${REPO} ${PATH_START}/${CREATE_LINKS} 156 ln -s ${SYMLINKS_PATH}/${REPO} ${PATH_START}/${CREATE_LINKS}
157 fi 157 fi
158 CREATE_LINKS=1 158 CREATE_LINKS=1
159 fi 159 fi
160 160
161 REMOTE_BRANCH=${MAIN_BRANCH} 161 REMOTE_BRANCH=${MAIN_BRANCH}
162 162
163 printf "..................................................DONE.................................................\n\n" 163 printf "..................................................DONE.................................................\n\n"
164 done 164 done
165 165
166 if [ "$UPDATE" = "1" ]; then 166 if [ "$UPDATE" = "1" ]; then
167 printf 'Repos updated:\n---------------\n' + "$ADDED_REPOS" + '\n' 167 printf 'Repos updated:\n---------------\n' + "$ADDED_REPOS" + '\n'
168 elif [ "$ADDED_REPOS" != "" ]; then 168 elif [ "$ADDED_REPOS" != "" ]; then
169 printf "$ADDED_REPOS\n" >> ADD.md 169 printf "$ADDED_REPOS\n" >> ADD.md
170 fi 170 fi
171 171
172 if [ "$NOT_ADDED_REPOS" != "" ]; then 172 if [ "$NOT_ADDED_REPOS" != "" ]; then
173 printf "$NOT_ADDED_REPOS" >> exists.txt 173 printf "$NOT_ADDED_REPOS" >> exists.txt
174 fi 174 fi
175 175
176 find -name "*.pyc" -delete 176 find -name "*.pyc" -delete
177 find -name "*.pyo" -delete 177 find -name "*.pyo" -delete
178 find -name "*.pyd" -delete 178 find -name "*.pyd" -delete
179 find -name "*.py~" -delete 179 find -name "*.py~" -delete
180 find -name "*.mo" -delete 180 find -name "*.mo" -delete
181 find -name "pip-log.txt" -delete 181 find -name "pip-log.txt" -delete
182 find -name "pip-delete-this-directory.txt" -delete 182 find -name "pip-delete-this-directory.txt" -delete
183 find -name "Thumbs.db" -delete 183 find -name "Thumbs.db" -delete
184 find -name ".directory" -delete 184 find -name ".directory" -delete
185 find -name ".DS_Store" -delete 185 find -name ".DS_Store" -delete
186 find -name ".*.kate-swp" -delete 186 find -name ".*.kate-swp" -delete
187 find -name ".swp.*" -delete 187 find -name ".swp.*" -delete
188 find -name "*.~1~" -delete 188 find -name "*.~1~" -delete
189 find -name "*.egg-info" -delete 189 find -name "*.egg-info" -delete
190 find -name ".installed.cfg" -delete 190 find -name ".installed.cfg" -delete
191 find -name "*.egg" -delete 191 find -name "*.egg" -delete
192 find -name "*.manifest" -delete 192 find -name "*.manifest" -delete
193 find -name "*.spec" -delete 193 find -name "*.spec" -delete
194 find -name "*.so" -delete 194 find -name "*.so" -delete
195 find -name "__MACOSX" -exec rm -r "{}" \; 195 find -name "__MACOSX" -exec rm -r "{}" \;
196 find -name "__pycache__" -exec rm -r "{}" \; 196 find -name "__pycache__" -exec rm -r "{}" \;
197 find -name "develop-eggs" -exec rm -r "{}" \; 197 find -name "develop-eggs" -exec rm -r "{}" \;
198 fi 198 fi
199 199