distribution/scripts/clean

52 lines
1.3 KiB
Text
Raw Normal View History

2022-02-05 14:23:32 +00:00
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
. config/options "${1}"
clean_package() {
build_msg "CLR_CLEAN" "CLEAN" "${1}" "indent"
if [ "${CLEAN_SOURCES}" = "true" ]; then
rm -rf "${SOURCES}/${1}"
return
fi
# Use a wilcard here to remove all versions of the package
for i in "${BUILD}/${1}-"*; do
if [ -d "${i}" -a -f "${i}/.jelos-unpack" ]; then
. "${i}/.jelos-unpack"
2022-02-05 14:23:32 +00:00
if [ "${STAMP_PKG_NAME}" = "${1}" ]; then
build_msg "CLR_WARNING" "*" "$(print_color "CLR_WARNING_DIM" "Removing ${i} ...")"
rm -rf "${i}"
fi
elif [ -d "${i}" -a -f "${i}/.jelos-package" ]; then
2022-02-05 14:23:32 +00:00
# force clean if no stamp found (previous unpack failed)
. "${i}/.jelos-package"
2022-02-05 14:23:32 +00:00
if [ "${INFO_PKG_NAME}" = "${1}" ]; then
build_msg "" "" "* Removing ${i} ..."
rm -rf "${i}"
fi
fi
done
for dir in "${STAMPS}/${1}" "${BUILD}/image/.stamps/${1}"
do
if [ -d "${dir}" ]
then
rm -rf ${dir}
mkdir ${dir}
fi
done
2022-02-05 14:23:32 +00:00
}
if [ "${1}" = "--all" -a -n "${2}" ]; then
for build_dir in $(ls -1d "${ROOT}/build."*); do
load_build_config "${build_dir}" && "${SCRIPTS}/clean" "${2}"
done
elif [ -n "${1}" ]; then
clean_package "${1}"
fi