packages: Add distclean

The various scripts present in GNU Boot are very fragile, so it's a
good idea to have a pristine GNU Boot source code for making releases.

The issue is that 'git clean -dfx' doesn't remove existing git
repositories like coreboot/ grub/ etc, so we need additional code to
take care of that.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Acked-by: Adrien 'neox' Bourmault <neox@gnu.org>
This commit is contained in:
Denis 'GNUtoo' Carikli 2023-11-28 16:33:33 +01:00 committed by Adrien 'neox' Bourmault
parent 514c573b4d
commit c7e28dc660
Signed by: neox
GPG Key ID: 2974E1D5F25DFCC8
18 changed files with 478 additions and 1 deletions

View File

@ -59,6 +59,9 @@ clean:
crossgcc-clean: crossgcc-clean:
./build clean crossgcc ./build clean crossgcc
distclean:
./build distclean all
install-dependencies-ubuntu: install-dependencies-ubuntu:
./build dependencies ubuntu2004 ./build dependencies ubuntu2004
@ -72,4 +75,5 @@ install-dependencies-void:
./build dependencies void ./build dependencies void
check: check:
./tests/lint ./tests/lint
./tests/distclean
./tests/u-boot-libre ./tests/u-boot-libre

1
build
View File

@ -37,6 +37,7 @@ tasks="\
clean \ clean \
dependencies \ dependencies \
descriptors \ descriptors \
distclean \
install \ install \
module \ module \
payload \ payload \

View File

@ -0,0 +1,27 @@
#!/bin/sh
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# shellcheck source=resources/scripts/tasks/distclean.sh
. "$(dirname "$0")"/../../scripts/tasks/distclean.sh
distclean_coreboot()
{
rm -rf coreboot
}
# shellcheck disable=SC2068
distclean_main distclean_coreboot $@

View File

@ -0,0 +1,27 @@
#!/bin/sh
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# shellcheck source=resources/scripts/tasks/distclean.sh
. "$(dirname "$0")"/../../scripts/tasks/distclean.sh
distclean_descriptors()
{
rm -rf descriptors
}
# shellcheck disable=SC2068
distclean_main distclean_descriptors $@

View File

@ -0,0 +1,27 @@
#!/bin/sh
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# shellcheck source=resources/scripts/tasks/distclean.sh
. "$(dirname "$0")"/../../scripts/tasks/distclean.sh
distclean_flashrom()
{
rm -rf flashrom
}
# shellcheck disable=SC2068
distclean_main distclean_flashrom $@

View File

@ -0,0 +1,27 @@
#!/bin/sh
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# shellcheck source=resources/scripts/tasks/distclean.sh
. "$(dirname "$0")"/../../scripts/tasks/distclean.sh
distclean_grub()
{
rm -rf grub
}
# shellcheck disable=SC2068
distclean_main distclean_grub $@

View File

@ -0,0 +1,27 @@
#!/bin/sh
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# shellcheck source=resources/scripts/tasks/distclean.sh
. "$(dirname "$0")"/../../scripts/tasks/distclean.sh
distclean_ich9utils()
{
rm -rf ich9utils
}
# shellcheck disable=SC2068
distclean_main distclean_ich9utils $@

View File

@ -0,0 +1,27 @@
#!/bin/sh
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# shellcheck source=resources/scripts/tasks/distclean.sh
. "$(dirname "$0")"/../../scripts/tasks/distclean.sh
distclean_memtest86plus()
{
rm -rf memtest86plus
}
# shellcheck disable=SC2068
distclean_main distclean_memtest86plus $@

View File

@ -0,0 +1,27 @@
#!/bin/sh
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# shellcheck source=resources/scripts/tasks/distclean.sh
. "$(dirname "$0")"/../../scripts/tasks/distclean.sh
distclean_payloads()
{
rm -rf payloads
}
# shellcheck disable=SC2068
distclean_main distclean_payloads $@

View File

@ -0,0 +1,27 @@
#!/bin/sh
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# shellcheck source=resources/scripts/tasks/distclean.sh
. "$(dirname "$0")"/../../scripts/tasks/distclean.sh
distclean_romimages()
{
rm -rf bin
}
# shellcheck disable=SC2068
distclean_main distclean_romimages $@

View File

@ -0,0 +1,27 @@
#!/bin/sh
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# shellcheck source=resources/scripts/tasks/distclean.sh
. "$(dirname "$0")"/../../scripts/tasks/distclean.sh
distclean_roms()
{
rm -rf release
}
# shellcheck disable=SC2068
distclean_main distclean_roms $@

View File

@ -0,0 +1,27 @@
#!/bin/sh
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# shellcheck source=resources/scripts/tasks/distclean.sh
. "$(dirname "$0")"/../../scripts/tasks/distclean.sh
distclean_seabios()
{
rm -rf seabios
}
# shellcheck disable=SC2068
distclean_main distclean_seabios $@

View File

@ -0,0 +1,27 @@
#!/bin/sh
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# shellcheck source=resources/scripts/tasks/distclean.sh
. "$(dirname "$0")"/../../scripts/tasks/distclean.sh
distclean_src()
{
rm -rf release
}
# shellcheck disable=SC2068
distclean_main distclean_src $@

View File

@ -0,0 +1,27 @@
#!/bin/sh
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# shellcheck source=resources/scripts/tasks/distclean.sh
. "$(dirname "$0")"/../../scripts/tasks/distclean.sh
distclean_u_boot_libre()
{
rm -rf release
}
# shellcheck disable=SC2068
distclean_main distclean_u_boot_libre $@

View File

@ -0,0 +1,27 @@
#!/bin/sh
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# shellcheck source=resources/scripts/tasks/distclean.sh
. "$(dirname "$0")"/../../scripts/tasks/distclean.sh
distclean_u_boot()
{
rm -rf u-boot
}
# shellcheck disable=SC2068
distclean_main distclean_u_boot $@

View File

@ -0,0 +1,55 @@
#!/bin/bash
#
# Copyright (C) 2022-2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# shellcheck source=resources/scripts/misc/sysexits.sh
topdir="$(dirname "${BASH_SOURCE[0]}")"/../../../
. "${topdir}"/resources/scripts/misc/sysexits.sh
progname="$0"
package="$(basename "$(dirname "${progname}")")"
distclean_usage()
{
printf "Usage:\n"
printf "\t%s --help # %s\n" \
"${progname}" \
"Print this help"
printf "\t%s # remove %s source code.\n" \
"${progname}" \
"${package}"
}
distclean_main()
{
func="$1"
shift 1
if [ $# -eq 0 ] ; then
if [ ! -f projectname ] ; then
echo "Error: for safety reasons " \
"this program can only run in the top directory."
exit 1
else
eval "${func}"
fi
elif [ $# -eq 1 ] && [ "$1" = "--help" ] ; then
distclean_usage "${progname}"
exit 0
else
distclean_usage "${progname}"
exit "${EX_USAGE}"
fi
}

51
tests/distclean Executable file
View File

@ -0,0 +1,51 @@
#!/bin/sh
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
printf "+-------------------------+\n"
printf "| Running distclean test: |\n"
printf "+-------------------------+\n"
# shellcheck source=resources/scripts/tasks/distclean.sh
. "$(dirname "$0")"/../resources/scripts/tasks/distclean.sh
report()
{
ret=$?
message="$1"
if [ ${ret} -eq 0 ] ; then
echo "[ OK ] ${message}"
else
echo "[ !! ] ${message} failed"
exit ${ret}
fi
}
tmpdir="$(mktemp -d)" && test -d "${tmpdir}" ; report "\${tmpdir} created"
distclean_test()
{
rmdir "${tmpdir}" && test ! -d "${tmpdir}" ; report "\${tmpdir} removed"
}
# shellcheck disable=SC2068
distclean_main distclean_test $@
printf "+---------------------+\n"
printf "| Running tests done: |\n"
printf "+---------------------+\n"

View File

@ -33,7 +33,7 @@ report()
run_shellcheck() run_shellcheck()
{ {
for path in "$@" ; do for path in "$@" ; do
shellcheck "${path}" ; report "${path}" shellcheck -x "${path}" ; report "${path}"
done done
} }
@ -41,6 +41,21 @@ printf "+---------------------+\n"
printf "| Running lint tests: |\n" printf "| Running lint tests: |\n"
printf "+---------------------+\n" printf "+---------------------+\n"
run_shellcheck \ run_shellcheck \
resources/packages/descriptors/distclean \
resources/packages/flashrom/distclean \
resources/packages/grub/distclean \
resources/packages/ich9utils/distclean \
resources/packages/memtest86plus/distclean \
resources/packages/payloads/distclean \
resources/packages/rom_images/distclean \
resources/packages/roms/distclean \
resources/packages/seabios/distclean \
resources/packages/src/distclean \
resources/packages/u-boot-libre/distclean \
resources/packages/u-boot/distclean \
resources/packages/coreboot/distclean \
resources/scripts/tasks/distclean.sh \
tests/distclean \
tests/lint tests/lint
printf "+---------------------+\n" printf "+---------------------+\n"