Blame view
repos.sh
5.3 KB
|
16572de04
|
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 |
#!/bin/bash
# export ADD_REMOTE="NO"
# export REMOTE_BRANCH="8.0"
# export PATH_PREFIX=".repos"
# export PATH_START="addons"
# export SYMLINKS_PATH="odoo-addons"
# export ADHOC_PATH="addons-adhoc"
# export CREATE_LINKS=1
# export DEF_REPO="XX"
# Build environment from env.txt file
while read line; do
export "$line"
done < env.txt
export GIT_EDITOR=true
read -e -p "Enter a list of github repos, separated by comma; or enter for update: " -i "" ACTION
if [ "$ACTION" != "" ]; then
ADD_ADDON_REPOS=($(printf "$ACTION" | tr "," "
"))
ACTION=""
else
UPDATE="1"
i=0
j=0
while read line; do
if [ "$i" -gt "6" ] && [ "$line" != "" ]; then
if [ "$line" != "Unsorted (inserted by repos.sh)" ] && [ "$line" != "===============================" ]; then
ADD_ADDON_REPOS[$j]=$line
j=$[j+1]
fi
fi
i=$[i+1]
done < ADD.md
# set some vars for updating:
ADD_REMOTE="NO"
read -e -p "Trying to update $[j+1] repos; enter to continue, input to quit: " -i "" ACTION
fi
if [ "$ACTION" != "" ]; then
exit 0
else
|
|
c90f9c270
|
46 47 |
printf "...................................................START................................................... " |
|
16572de04
|
48 49 |
if [ "$DEF_REPO" ]; then if [ "$DEF_REPO" != "XX" ]; then |
|
c90f9c270
|
50 51 |
printf "set var 'ADD_ADDON_REPOS' " |
|
16572de04
|
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 |
ADD_ADDON_REPOS=("$DEF_REPO")
fi
fi
if [ ! "$REMOTE_BRANCH" ]; then
REMOTE_BRANCH="8.0"
fi
if [ ! "$SYMLINKS_PATH" ]; then
SYMLINKS_PATH="odoo-addons"
fi
if [ ! "$PATH_START" ]; then
PATH_START="addons"
fi
if [ ! "$PATH_PREFIX" ]; then
PATH_PREFIX=".repos"
fi
if [ ! "$ADD_REMOTE" ]; then
ADD_REMOTE="YES"
fi
if [ ! "$CREATE_LINKS" ]; then
CREATE_LINKS=1
fi
# :' = Multiline Comment
# ADDED_REPOS=":'
"
ADDED_REPOS=""
NOT_ADDED_REPOS=""
|
|
c90f9c270
|
78 79 80 |
MAIN_BRANCH=${REMOTE_BRANCH}
|
|
16572de04
|
81 |
for i in "${ADD_ADDON_REPOS[@]}"; do
|
|
c90f9c270
|
82 83 |
printf "repo '$i' " |
|
16572de04
|
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# Defaults
CREATE_LINKS=1
j=($(printf "$i" | tr "~!~" "
"))
if [ ${j[1]} ]; then
i=${j[0]}
if [ ${j[1]} = "CREATE_LINKS=2" ]; then
CREATE_LINKS=2
fi
fi
j=($(printf "$i" | tr ":" "
"))
if [ ${j[1]} ]; then
i=${j[0]}
REMOTE_BRANCH=${j[1]}
fi
|
|
c90f9c270
|
104 105 |
printf "~~~~~~~~~~~~ USING BRANCH: $REMOTE_BRANCH ~~~~~~~~~~~~ " |
|
16572de04
|
106 107 108 109 110 111 |
REPO=${i} && REPL="--" && REMOTE=${REPO/\//$REPL}
if [ "$UPDATE" = "1" ]; then
git fetch --no-tags remote--${REMOTE}
SUBTREE_CMD="pull"
git subtree ${SUBTREE_CMD} --prefix=${PATH_PREFIX}/${REPO} remote--${REMOTE} ${REMOTE_BRANCH} --squash -q
|
|
c90f9c270
|
112 113 114 115 116 117 118 119 120 121 |
# while read line; do
# if [[ ${REPO} == ${line} ]]; then
# printf "++++++ MATCH ++++++
"
# CREATE_LINKS=0
# fi
# printf "+++++ NOMATCH +++++ ${REPO}
"
# #printf ${REPO}
# done < ignore.txt
|
|
16572de04
|
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
elif [ "$ADD_REMOTE" = "YES" ]; then
git remote add -f --no-tags remote--${REMOTE} https://github.com/${REPO}.git
SUBTREE_CMD="add"
git subtree ${SUBTREE_CMD} --prefix=${PATH_PREFIX}/${REPO} remote--${REMOTE}/${REMOTE_BRANCH} --squash
fi
ADDED_REPOS+=${REPO}
ADDED_REPOS+='
'
if [ "$CREATE_LINKS" != 0 ]; then
if [ "$CREATE_LINKS" = 1 ]; then
for j in ${PATH_PREFIX}/${REPO}/* ; do
if [ -d "$j" ]; then
n=${j##*/}
|
|
7b79866ce
|
137 |
if [ "$n" != "__unported__" ]; then |
|
3d8d89cad
|
138 |
if [ -h "${SYMLINKS_PATH}/$n" ]; then
|
|
c90f9c270
|
139 140 |
printf "symlink exists '${REPO}/$n'
"
|
|
16572de04
|
141 |
if [ "$ADD_REMOTE" = "YES" ]; then |
|
c90f9c270
|
142 143 |
NOT_ADDED_REPOS="$NOT_ADDED_REPOS
${REPO}/$n"
|
|
16572de04
|
144 145 |
fi else |
|
c90f9c270
|
146 147 |
printf "create symlink 1: '${REPO}/$n'
"
|
|
16572de04
|
148 149 |
ln -s "../../${PATH_PREFIX}/${REPO}/$n" "${SYMLINKS_PATH}/$n"
fi
|
|
3d8d89cad
|
150 |
if [ -h "${ADHOC_PATH}/$n" ]; then
|
|
c90f9c270
|
151 152 |
printf "delete adhoc " |
|
3d8d89cad
|
153 |
rm "${ADHOC_PATH}/$n"
|
|
16572de04
|
154 155 156 157 158 |
fi fi fi done elif [ "$CREATE_LINKS" = 2 ]; then |
|
c90f9c270
|
159 160 |
printf "create symlink 2: '${REPO}/'
"
|
|
16572de04
|
161 162 163 164 165 166 |
REPO_SEP=($(printf "$REPO" | tr "/" "
"))
if [ ${REPO_SEP[1]} ]; then
REPO=${REPO_SEP[1]}
PATH_PREFIX+="/${REPO_SEP[0]}"
fi
|
|
c90f9c270
|
167 |
ln -s "../../${PATH_PREFIX}/${REPO}" "${SYMLINKS_PATH}/${REPO}"
|
|
16572de04
|
168 169 170 171 172 173 174 175 |
PATH_PREFIX=".repos"
elif [ "$CREATE_LINKS" = 3 ]; then
ln -s ${SYMLINKS_PATH}/${REPO} ${PATH_START}/
else
ln -s ${SYMLINKS_PATH}/${REPO} ${PATH_START}/${CREATE_LINKS}
fi
CREATE_LINKS=1
fi
|
|
c90f9c270
|
176 177 178 179 180 181 |
REMOTE_BRANCH=${MAIN_BRANCH}
printf "..................................................DONE.................................................
"
|
|
16572de04
|
182 |
done |
|
c90f9c270
|
183 |
|
|
16572de04
|
184 185 186 187 188 189 190 191 192 |
if [ "$UPDATE" = "1" ]; then printf 'Repos updated: --------------- ' + "$ADDED_REPOS" + ' ' elif [ "$ADDED_REPOS" != "" ]; then printf "$ADDED_REPOS " >> ADD.md fi |
|
c90f9c270
|
193 |
|
|
16572de04
|
194 195 196 |
if [ "$NOT_ADDED_REPOS" != "" ]; then printf "$NOT_ADDED_REPOS" >> exists.txt fi |
|
c90f9c270
|
197 |
|
|
a1fbb1da3
|
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# ToDo: Don't cleanup ... check later
CLEANUP=0
if [ "$CLEANUP" = "1" ]; then
find -name "*.pyc" -delete
find -name "*.pyo" -delete
find -name "*.pyd" -delete
find -name "*.py~" -delete
find -name "*.mo" -delete
find -name "pip-log.txt" -delete
find -name "pip-delete-this-directory.txt" -delete
find -name "Thumbs.db" -delete
find -name ".directory" -delete
find -name ".DS_Store" -delete
find -name ".*.kate-swp" -delete
find -name ".swp.*" -delete
find -name "*.~1~" -delete
find -name "*.egg-info" -delete
find -name ".installed.cfg" -delete
find -name "*.egg" -delete
find -name "*.manifest" -delete
find -name "*.spec" -delete
find -name "*.so" -delete
find -name "__MACOSX" -exec rm -r "{}" \;
find -name "__pycache__" -exec rm -r "{}" \;
find -name "develop-eggs" -exec rm -r "{}" \;
fi
|
|
c90f9c270
|
224 |
fi |