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
|
2024-02-09 22:18:38 +00:00
|
|
|
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
|
2024-02-09 22:18:38 +00:00
|
|
|
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)
|
2024-02-09 22:18:38 +00:00
|
|
|
. "${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
|
2023-05-23 12:57:58 +00:00
|
|
|
for dir in "${STAMPS}/${1}" "${BUILD}/image/.stamps/${1}"
|
|
|
|
do
|
2023-05-23 15:28:57 +00:00
|
|
|
if [ -d "${dir}" ]
|
|
|
|
then
|
|
|
|
rm -rf ${dir}
|
|
|
|
mkdir ${dir}
|
|
|
|
fi
|
2023-05-23 12:57:58 +00:00
|
|
|
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
|
|
|
|
|