Files
build/tools/gen-series.sh
Paolo Sabatino 562d96128b consolidate rk322x and rockchip 32 bit families
* merge patches from rockchip and rk322x families for current and edge
   kernels
 * adjust patches for tinkerboard to remove some cruft and overclocking
 * rework kernel configs
 * fix rk322x dmc to avoid lockup on rk3288
 * migrate rockchip-6.6 into patch series, rename all patches with
   more understandable names
 * add gen-series.sh script in tools directory (it is a naive tool to
   create patch series when you don't want to rebase everything)
2023-12-26 16:45:30 +01:00

91 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# Generate *.series and series.conf from existing patches.* directories
LOG_VERBOSE=0
function print_usage() {
TOOL=$(basename $0)
echo -e "Naive tool to create .series and series.conf file from existing local directories"
echo -e "Usage:"
echo -e "\t$TOOL [-v] <directory...>"
echo -e ""
echo -e "Flags:"
echo -e "\t-v - enable verbose output"
echo -e ""
echo -e "Example:"
echo -e "\t$TOOL -v patches.libreelec patches.armbian"
}
function log() {
[[ $LOG_VERBOSE -ne 1 ]] && return
echo -e "$1"
}
function log_error() {
echo -e "$1"
}
for arg in "$@"; do
shift
case $arg in
(-v) : ;LOG_VERBOSE=1;;
(*) set -- "$@" "$arg" ;;
esac
done
DIRECTORIES=$@
if [[ -z "$DIRECTORIES" ]]; then
print_usage
exit 0
fi
for DIR in $@; do
SERIE=$(echo $DIR | cut -d "." -f 2- | tr -d "/")
if [[ -z "$SERIE" ]]; then
log_error "Invalid series directory $DIR"
exit 1
fi
log "Evaluating directory $DIR - $SERIE series"
FILES=$(find "$DIR" -type f -printf "\t%p\n" | sort -g)
if [[ $? -ne 0 ]]; then
log_error "Error while evaluating $DIR"
exit 1
fi
log "$FILES"
echo "# Series from $DIR" > "$SERIE.series"
echo "$FILES" >> "$SERIE.series"
done
# Zeroes series.conf file, creates it if does not exist
truncate --size 0 "series.conf"
if [[ $? -ne 0 ]]; then
log_error "Could not truncate file series.conf"
exit 1
fi
# Concatenate the *.series files into series.conf file with respect to
# the order of the series directories specified on the command line
for DIR in $@; do
SERIE=$(echo $DIR | cut -d "." -f 2- | tr -d "/")
cat "$SERIE.series" >> "series.conf"
if [[ $? -ne 0 ]]; then
log_error "Error while writing $SERIE.series to series.conf"
exit 1
fi
done
exit 0