mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 11:43:25 +02:00
make.sh: Integrate the rootfile consistency check
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
120
make.sh
120
make.sh
@@ -46,6 +46,13 @@ KVER="${KVER/-rc/.0-rc}${KVER_SUFFIX}"
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
# All supported architectures
|
||||||
|
ARCHES=(
|
||||||
|
aarch64
|
||||||
|
riscv64
|
||||||
|
x86_64
|
||||||
|
)
|
||||||
|
|
||||||
HOST_ARCH="${HOSTTYPE}"
|
HOST_ARCH="${HOSTTYPE}"
|
||||||
LC_ALL=POSIX
|
LC_ALL=POSIX
|
||||||
PS1='\u:\w$ '
|
PS1='\u:\w$ '
|
||||||
@@ -2159,8 +2166,8 @@ exec_in_namespace() {
|
|||||||
"${0}" "${args[@]}" "$@"
|
"${0}" "${args[@]}" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_logfiles() {
|
check_for_missing_rootfiles() {
|
||||||
print_headline "Checking Log Files..."
|
print_headline "Checking for missing rootfiles..."
|
||||||
|
|
||||||
local file
|
local file
|
||||||
for file in ${LOG_DIR}/*_missing_rootfile; do
|
for file in ${LOG_DIR}/*_missing_rootfile; do
|
||||||
@@ -2174,6 +2181,102 @@ check_logfiles() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_rootfiles_for_arch() {
|
||||||
|
local arch="${1}"
|
||||||
|
|
||||||
|
local args=(
|
||||||
|
# Search path
|
||||||
|
"${BASEDIR}/config/rootfiles"
|
||||||
|
|
||||||
|
# Exclude old core updates
|
||||||
|
"--exclude-dir" "oldcore"
|
||||||
|
|
||||||
|
# Ignore the update scripts
|
||||||
|
"--exclude" "update.sh"
|
||||||
|
)
|
||||||
|
|
||||||
|
# A list of files that are not scanned
|
||||||
|
# because they probably cause some false positives.
|
||||||
|
local excluded_files=(
|
||||||
|
qemu
|
||||||
|
)
|
||||||
|
|
||||||
|
# Exclude any architecture-specific directories
|
||||||
|
local a
|
||||||
|
for a in ${ARCHES[@]}; do
|
||||||
|
args+=( "--exclude-dir" "${a}" )
|
||||||
|
done
|
||||||
|
|
||||||
|
# Exclude all excluded files
|
||||||
|
local x
|
||||||
|
for x in ${excluded_files[@]}; do
|
||||||
|
args+=( "--exclude" "${x}" )
|
||||||
|
done
|
||||||
|
|
||||||
|
# Search for all lines that contain the architecture, but exclude commented lines
|
||||||
|
if grep -r "^[^#].*${arch}" "${args[@]}"; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
check_rootfiles_for_pattern() {
|
||||||
|
local pattern="${1}"
|
||||||
|
local message="${2}"
|
||||||
|
|
||||||
|
local args=(
|
||||||
|
# Search path
|
||||||
|
"${BASEDIR}/config/rootfiles"
|
||||||
|
|
||||||
|
# Exclude old core updates
|
||||||
|
"--exclude-dir" "oldcore"
|
||||||
|
|
||||||
|
# Ignore the update scripts
|
||||||
|
"--exclude" "update.sh"
|
||||||
|
)
|
||||||
|
|
||||||
|
if grep -r "${pattern}" "${args[@]}"; then
|
||||||
|
if [ -n "${message}" ]; then
|
||||||
|
print_line "${message}"
|
||||||
|
print_status FAIL
|
||||||
|
else
|
||||||
|
print_file "Files matching '${pattern}' have been found in the rootfiles"
|
||||||
|
print_status FAIL
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
check_rootfiles() {
|
||||||
|
local failed=0
|
||||||
|
|
||||||
|
print_headline "Checking for rootfile consistency..."
|
||||||
|
|
||||||
|
# Check for /etc/init.d
|
||||||
|
if ! check_rootfiles_for_pattern "^etc/init\.d/" \
|
||||||
|
"/etc/init.d/* has been found. Please replace by /etc/rc.d/init.d"; then
|
||||||
|
failed=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for /var/run
|
||||||
|
if ! check_rootfiles_for_pattern "^var/run/.*" \
|
||||||
|
"You cannot ship files in /var/run as it is a ramdisk"; then
|
||||||
|
failed=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check architectures
|
||||||
|
local arch
|
||||||
|
for arch in ${ARCHES[@]}; do
|
||||||
|
check_rootfiles_for_arch "${arch}" || failed=$?
|
||||||
|
done
|
||||||
|
|
||||||
|
# Return the error
|
||||||
|
return ${failed}
|
||||||
|
}
|
||||||
|
|
||||||
# Set BASEDIR
|
# Set BASEDIR
|
||||||
readonly BASEDIR="$(find_base)"
|
readonly BASEDIR="$(find_base)"
|
||||||
|
|
||||||
@@ -2369,14 +2472,13 @@ build)
|
|||||||
# Build all packages
|
# Build all packages
|
||||||
build_packages
|
build_packages
|
||||||
|
|
||||||
# Check log files
|
# Check for missing rootfiles
|
||||||
check_logfiles
|
check_for_missing_rootfiles
|
||||||
|
|
||||||
print_headline "Checking Logfiles for new Files"
|
# Check for rootfile consistency
|
||||||
|
if ! check_rootfiles; then
|
||||||
pushd "${BASEDIR}" &>/dev/null
|
exiterror "Rootfiles are inconsistent"
|
||||||
tools/checkrootfiles
|
fi
|
||||||
popd &>/dev/null
|
|
||||||
|
|
||||||
print_build_summary $(( SECONDS - START_TIME ))
|
print_build_summary $(( SECONDS - START_TIME ))
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -1,114 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
###############################################################################
|
|
||||||
# #
|
|
||||||
# IPFire.org - A linux based firewall #
|
|
||||||
# Copyright (C) 2007-2023 IPFire Team info@ipfire.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 <http://www.gnu.org/licenses/>. #
|
|
||||||
# #
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
# All supported architectures
|
|
||||||
ARCHES=(
|
|
||||||
aarch64
|
|
||||||
riscv64
|
|
||||||
x86_64
|
|
||||||
)
|
|
||||||
|
|
||||||
# A list of files that are not scanned
|
|
||||||
# because they probably cause some false positives.
|
|
||||||
EXCLUDED_FILES=(
|
|
||||||
qemu
|
|
||||||
)
|
|
||||||
|
|
||||||
ARGS=(
|
|
||||||
# Search path
|
|
||||||
"config/rootfiles"
|
|
||||||
|
|
||||||
# Exclude old core updates
|
|
||||||
"--exclude-dir" "oldcore"
|
|
||||||
|
|
||||||
# Ignore the update scripts
|
|
||||||
"--exclude" "update.sh"
|
|
||||||
)
|
|
||||||
|
|
||||||
check_for_arch() {
|
|
||||||
local arch="${1}"
|
|
||||||
|
|
||||||
local args=(
|
|
||||||
"${ARGS[@]}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Exclude any architecture-specific directories
|
|
||||||
local a
|
|
||||||
for a in ${ARCHES[@]}; do
|
|
||||||
args+=( "--exclude-dir" "${a}" )
|
|
||||||
done
|
|
||||||
|
|
||||||
# Exclude all excluded files
|
|
||||||
local x
|
|
||||||
for x in ${EXCLUDED_FILES[@]}; do
|
|
||||||
args+=( "--exclude" "${x}" )
|
|
||||||
done
|
|
||||||
|
|
||||||
# Search for all lines that contain the architecture, but exclude commented lines
|
|
||||||
grep -r "^[^#].*${arch}" "${args[@]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
check_for_pattern() {
|
|
||||||
local pattern="${1}"
|
|
||||||
local message="${2}"
|
|
||||||
|
|
||||||
local args=(
|
|
||||||
"${ARGS[@]}"
|
|
||||||
)
|
|
||||||
|
|
||||||
if grep -r "${pattern}" "${args[@]}"; then
|
|
||||||
if [ -n "${message}" ]; then
|
|
||||||
echo "ERROR: ${message}"
|
|
||||||
else
|
|
||||||
echo "ERROR: Files matching '${pattern}' have been found in the rootfiles"
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
local failed=0
|
|
||||||
|
|
||||||
# Check for /etc/init.d
|
|
||||||
if ! check_for_pattern "^etc/init\.d/" \
|
|
||||||
"/etc/init.d/* has been found. Please replace by /etc/rc.d/init.d"; then
|
|
||||||
failed=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check for /var/run
|
|
||||||
if ! check_for_pattern "^var/run/.*" \
|
|
||||||
"You cannot ship files in /var/run as it is a ramdisk"; then
|
|
||||||
failed=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check architectures
|
|
||||||
local arch
|
|
||||||
for arch in ${ARCHES[@]}; do
|
|
||||||
check_for_arch "${arch}" || failed=$?
|
|
||||||
done
|
|
||||||
|
|
||||||
# Return the error
|
|
||||||
return ${failed}
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@" || exit $?
|
|
||||||
Reference in New Issue
Block a user