Skip to content

Commit 5c462c5

Browse files
authored
Merge pull request #35 from guallo/allow-to-skip-specific-cleanups
Allow to skip specific cleanups
2 parents a54ff10 + 18b01d1 commit 5c462c5

File tree

1 file changed

+53
-10
lines changed

1 file changed

+53
-10
lines changed

linuxdeploy-plugin-conda.sh

+53-10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ show_usage() {
2121
echo " PIP_REQUIREMENTS=\"packageA packageB -r requirements.txt -e git+https://...\""
2222
echo " PIP_PREFIX=\"AppDir/usr/share/conda\""
2323
echo " ARCH=\"x86_64\" (further supported values: i686)"
24+
echo " CONDA_SKIP_CLEANUP=\"[all;][conda-pkgs;][__pycache__;][.so;][.a;][cmake;][doc;][man;][site-packages;]\""
2425
}
2526

2627
_isterm() {
@@ -184,17 +185,59 @@ done
184185
popd
185186

186187

187-
# remove bloat
188-
if [ "$CONDA_SKIP_CLEANUP" == "" ]; then
188+
# remove bloat, optionally skipped via $CONDA_SKIP_CLEANUP
189+
IFS=';' read -ra cleanup <<< "$CONDA_SKIP_CLEANUP"
190+
for skip in "${cleanup[@]}"; do
191+
lskip="$(tr '[:upper:]' '[:lower:]' <<< "$skip")"
192+
case "$lskip" in
193+
"all"| \
194+
"1"|"true"|"y"|"yes") # To allow SOME backward compatibility - versions previous
195+
# to this comment allowed any value of $CONDA_SKIP_CLEANUP.
196+
skip_cleanup=1
197+
;;
198+
"conda-pkgs")
199+
skip_conda_pkgs_cleanup=1
200+
;;
201+
"__pycache__")
202+
skip_pycache_cleanup=1
203+
;;
204+
".so")
205+
skip_so_cleanup=1
206+
;;
207+
".a")
208+
skip_a_cleanup=1
209+
;;
210+
"cmake")
211+
skip_cmake_cleanup=1
212+
;;
213+
"doc")
214+
skip_doc_cleanup=1
215+
;;
216+
"man")
217+
skip_man_cleanup=1
218+
;;
219+
"site-packages")
220+
skip_site_packages_cleanup=1
221+
;;
222+
*)
223+
log "ERROR: Unknown CONDA_SKIP_CLEANUP value: $skip"
224+
log
225+
show_usage
226+
exit 1
227+
;;
228+
esac
229+
done
230+
231+
if [ "$skip_cleanup" != "1" ]; then
189232
pushd "$APPDIR"/usr/conda
190-
rm -rf pkgs
191-
find -type d -iname '__pycache__' -print0 | xargs -0 rm -r
192-
find -type f -iname '*.so*' -print -exec strip '{}' \;
193-
find -type f -iname '*.a' -print -delete
194-
rm -rf lib/cmake/
195-
rm -rf share/{gtk-,}doc
196-
rm -rf share/man
197-
rm -rf lib/python?.?/site-packages/{setuptools,pip}
233+
(($skip_conda_pkgs_cleanup)) || rm -rf pkgs
234+
(($skip_pycache_cleanup)) || find -type d -iname '__pycache__' -print0 | xargs -0 rm -r
235+
(($skip_so_cleanup)) || find -type f -iname '*.so*' -print -exec strip '{}' \;
236+
(($skip_a_cleanup)) || find -type f -iname '*.a' -print -delete
237+
(($skip_cmake_cleanup)) || rm -rf lib/cmake/
238+
(($skip_doc_cleanup)) || rm -rf share/{gtk-,}doc
239+
(($skip_man_cleanup)) || rm -rf share/man
240+
(($skip_site_packages_cleanup)) || rm -rf lib/python?.?/site-packages/{setuptools,pip}
198241
popd
199242
fi
200243

0 commit comments

Comments
 (0)