#!/bin/sh # Publish local patches as quilt trees. # # Copyright (C) 2008-2011 Jean Delvare # # 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 2 # 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: # http://www.gnu.org/copyleft/gpl.html # # The latest official version of this script can be found at: # ftp://ftp.kernel.org/pub/linux/kernel/people/jdelvare/scripts/publish-patches if [ $# -lt 1 ] then echo "Subsystem?" exit 1 fi if [ ! -d "patches" -o ! -f "Makefile" ] then echo "Invalid working directory" exit 1 fi # Determine the base version get_base() { local ver0 ver1 ver2 ver3 ver0=`sed -ne 's/^VERSION[[:space:]]*=[[:space:]]*//p' Makefile` ver1=`sed -ne 's/^PATCHLEVEL[[:space:]]*=[[:space:]]*//p' Makefile` ver2=`sed -ne 's/^SUBLEVEL[[:space:]]*=[[:space:]]*//p' Makefile` ver3=`sed -ne 's/^EXTRAVERSION[[:space:]]*=[[:space:]]*//p' Makefile` # Strip sublevel for 3.x kernel series if [ "$ver0" = "3" -a "$ver2" = "0" ] then echo "$ver0.$ver1$ver3" else echo "$ver0.$ver1.$ver2$ver3" fi } PUBLIC_ROOT="$HOME/devel/linux/kernel.org/linux-2.6" BASE=`get_base` echo "BASE = $BASE" # Make sure addresses in headers are well-formatted check_address() { local total good total=`grep -c "^$2: " $patch` good=`grep -c "^$2: \(.* <.*@.*\..*>\|stable@kernel\.org\( \[.*\]\)\?\)\$" $patch` if [ "$total" -ne "$good" ] then echo "Warning: patch $1 has malformed $2: header." fi } # Do the real work publish_subsystem() { local SUBSYSTEM="$1" local PUBLIC="$PUBLIC_ROOT/jdelvare-$SUBSYSTEM" if [ ! -d "patches/$SUBSYSTEM" ] then echo "Invalid subsystem: $SUBSYSTEM" exit 1 fi echo "Publishing subsystem $SUBSYSTEM" # Create directory if needed [ -d "$PUBLIC" ] || mkdir -p "$PUBLIC" # Delete the old stuff rm -f "$PUBLIC"/* # Copy the new stuff echo "# BASE $BASE" > "$PUBLIC"/series sed -e "s/[[:space:]][[:space:]]*#.*//" -ne "s/^$SUBSYSTEM\///p;s/\(NEXT_\(BASE\|PATCHES_START\|PATCHES_END\)\)($SUBSYSTEM)/\1/p" < patches/series >> "$PUBLIC"/series chmod 644 "$PUBLIC"/series local WARNED=0 if grep -q '^[^#]' "$PUBLIC"/series then for patch in "patches/$SUBSYSTEM"/*.patch do # Check for missing headers if ! grep -q '^From: ' $patch then echo "Warning: patch $patch lacks a From: header." WARNED=1 fi if ! grep -q '^Subject: ' $patch then echo "Warning: patch $patch lacks a Subject: header." WARNED=1 fi if ! grep -q '^Signed-off-by: ' $patch then echo "Warning: patch $patch lacks a Signed-off-by: line." WARNED=1 fi # Check for extra headers if grep -q '^To: ' $patch then echo "Warning: patch $patch has extra headers." WARNED=1 fi # Check for malformed headers check_address $patch 'From' check_address $patch 'Cc' check_address $patch 'Signed-off-by' done cp --preserve=timestamps "patches/$SUBSYSTEM"/*.patch "$PUBLIC" chmod 644 "$PUBLIC"/*.patch fi # Make sure that all the files referenced in series, exist local ORPHAN=`grep -v -e '^#' -e '\.patch$' "$PUBLIC"/series` if [ -n "$ORPHAN" ] then echo "Warning! Unexpected references in series:" echo "$ORPHAN" WARNED=1 fi # Create a tarball for easier download rm -f "$PUBLIC_ROOT/jdelvare-$SUBSYSTEM.tar.gz" tar zcf "$PUBLIC_ROOT/jdelvare-$SUBSYSTEM.tar.gz" -C "$PUBLIC_ROOT" "jdelvare-$SUBSYSTEM" # Push everything to kernel.org if [ "$WARNED" -ne "1" ] then rsync -av --delete "$PUBLIC_ROOT/jdelvare-$SUBSYSTEM.tar.gz" "$PUBLIC_ROOT/jdelvare-$SUBSYSTEM" master.kernel.org:people-jdelvare/linux-2.6 fi } for SUBSYSTEM in "$@" do publish_subsystem $SUBSYSTEM done