#!/bin/bash # # Copyright 2005 Greg Kroah-Hartman # # Released under the GPL v2 only. # # Horrible hack of a script to let kernel maintainers, who use quilt # export a series of patches in a form that is rolled up, and in-order # for others to pick up and use. Examples of this is for the -mm releases. # # Here are the things you should modify: # AUTHOR is your name, it will be pre-appended to all patches AUTHOR=gregkh # KERNEL is the base kernel version your quilt series is against. You need to # have this kernel tree already uncompressed and waiting in the TMP directory KERNEL=2.6.15-rc1-git5 # TMP is where you want everything to happen. You need to have a base kernel # version (specified by KERNEL) in here, all unpacked. This is also where the # end result files will be placed. TMP=~/linux/tmp # PATCH_DIR is the location of your quilt patches. There should be a file in # here called "series" and a bunch of patches in subdirectories below that (the # subdirs are how you divide stuff up by TREES) PATCH_DIR=~/linux/patches # TREES is a list of the different sets of kernel patches you wish to produce. # If you only have one set of patches, this can be a single value. The strings # here need to have a subdirectory in the PATCH_DIR to get the patches from. TREES="driver i2c pci usb devfs" # Don't touch anything below here, unless you really want to... do_it() { NEW=$BASE-$TREE CLEAN_TREE="$BASE$OLD_TREE" BASENAME=`echo "$AUTHOR" "$SERIES" "$TREE" | \ awk '{ printf("%s-%02d-%s\n", $1, $2, $3, $4);}'` TMPDIR=$TMP/$BASENAME echo "Building series file for $TREE" chmod 644 $PATCH_DIR/$TREE/*.patch mkdir $TMPDIR echo "Use the 'series' file in this directory to determine the order in" > $TMPDIR/README echo "which to apply the patches." >> $TMPDIR/README echo "" >> $TMPDIR/README echo "These patches are based on the $KERNEL version of the kernel." >> $TMPDIR/README echo "Applying them to any other kernel version might not work at all." >> $TMPDIR/README touch $TMPDIR/series count=1 for x in `grep "^$TREE\/" $PATCH_DIR/series` do file=`basename $x` #name=`echo "$AUTHOR" "$TREE" "$count" "$file" | \ # awk '{ printf("%s-%s-%03d_%s\n", $1, $2, $3, $4);}'` #cp $PATCH_DIR/$x $TMPDIR/$name cp -a $PATCH_DIR/$x $TMPDIR/$file #echo "$name" >> $TMPDIR/series echo "$file" >> $TMPDIR/series let count++ done echo "Creating $NEW kernel tree" cp -alp $CLEAN_TREE $NEW # apply quilt series cd $NEW QUILT_PATCHES=$TMPDIR QUILT_SERIES=$TMPDIR/series quilt push -aq --quiltrc #rm $TMPDIR/series cd .. # TODO put "changelog" in patch. echo "diffing $CLEAN_TREE and $NEW" diff -Naur -X ../dontdiff $CLEAN_TREE $NEW > $BASENAME-$KERNEL.patch echo "cleaning up quilt remnants $NEW" rm -rf $NEW/.pc echo "Patch is at $BASENAME-$KERNEL.patch" echo "Dir of patches is at $TMPDIR" echo "" let SERIES++ } BASE=linux-$KERNEL # make sure we have a base tree to diff off of. if [ ! -d "$TMP/$BASE" ] ; then echo "I need $TMP/$BASE present in order to work properly." exit 1 fi # make sure everything is readable by world for when we upload the patches find $PATCH_DIR -type f | xargs chmod 644 # initialize some variables SERIES=1 OLD_TREE="" # do the work cd $TMP for TREE in $TREES do do_it if [ "X$OLD_TREE" != "X" ] ; then echo "Cleaning up $BASE$OLD_TREE" rm -rf $BASE$OLD_TREE fi OLD_TREE="-$TREE" done # TODO put "changelog" in patch. echo "" echo "diffing $BASE and $NEW" diff -Naur -X ../dontdiff $BASE $NEW > $AUTHOR-all-$KERNEL.patch echo "Patch is at $AUTHOR-all-$KERNEL.patch" if [ "X$OLD_TREE" != "X" ] ; then echo "Cleaning up $BASE$OLD_TREE" rm -rf $BASE$OLD_TREE fi