Commit 16572de04bd4a739998b49ec8e9ecb00a27307c0

Authored by mj
1 parent a860f2a121
Exists in master

[IMP] ADD repos.sh (from REPO 'foreign-addons')

Showing 1 changed file with 189 additions and 0 deletions Inline Diff

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