public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* Script to cross-apply libxfs changes
@ 2015-05-15 18:01 Eric Sandeen
  2015-06-15  0:01 ` Dave Chinner
  2015-06-15  3:40 ` Eric Sandeen
  0 siblings, 2 replies; 4+ messages in thread
From: Eric Sandeen @ 2015-05-15 18:01 UTC (permalink / raw)
  To: xfs-oss

I'm terrible at bash, so don't laugh.  But this more or less works for me ...

This script takes either a patch name or a commit ID in the current
tree, and massages that change into a libxfs patch for the other tree;
i.e. it applies a kernel libxfs patch to xfsprogs, or vice versa.
It'll create a guilt patch if it looks like a guilt dir, or just smack
it in with "patch" if not.

It can surely be improved, but it's a start.

Example below, and script at the end.  Requires filterdiff.

[root@bp-05 xfsprogs]# git log
commit 9681b791929795cd7dc6c7a79c3a69354f34e0b0
...
[root@bp-05 xfsprogs]# libxfs-apply /mnt/test2/git/linux-xfs/ 9681b791929795cd7dc6c7a79c3a69354f34e0b0
Filtered patch for /mnt/test2/git/linux-xfs/ contains:
a/fs/xfs/libxfs/xfs_alloc.c
a/fs/xfs/libxfs/xfs_alloc_btree.c
a/fs/xfs/libxfs/xfs_attr_leaf.c
a/fs/xfs/libxfs/xfs_attr_remote.c
a/fs/xfs/libxfs/xfs_bmap_btree.c
a/fs/xfs/libxfs/xfs_btree.c
a/fs/xfs/libxfs/xfs_da_btree.c
a/fs/xfs/libxfs/xfs_dir2_block.c
a/fs/xfs/libxfs/xfs_dir2_data.c
a/fs/xfs/libxfs/xfs_dir2_leaf.c
a/fs/xfs/libxfs/xfs_dir2_node.c
a/fs/xfs/libxfs/xfs_dquot_buf.c
a/fs/xfs/libxfs/xfs_format.h
a/fs/xfs/libxfs/xfs_ialloc.c
a/fs/xfs/libxfs/xfs_ialloc_btree.c
a/fs/xfs/libxfs/xfs_inode_buf.c
a/fs/xfs/libxfs/xfs_sb.c
a/fs/xfs/libxfs/xfs_symlink_remote.c
/mnt/test2/git/linux-xfs/ looks like a guilt directory.
Top patch is: percpu-2
Create new Guilt patch? (Enter patch name or return to skip) new-uuid
Applying patch..new-uuid
Patch applied.
Patch was applied in /mnt/test2/git/linux-xfs/; check for rejects, guilt push -f, etc
[root@bp-05 xfsprogs]#

==========

#!/bin/bash

# 2 args:
#	libxfs-apply <repo> <commit ID or patchfile>

usage()
{
	echo "libxfs-apply repodir [patchfile|commitid]"
	exit
}

cleanup()
{
	rm -f $PATCH $LIBXFS_FILES $NEWPATCH
}

fail()
{
	cleanup
	cd $ORIG_DIR
	exit
}

if [ "$#" -eq 2 -a -d "$1" -a -f "$2" ]; then
	REPO=$1
	PATCH=$2
elif [ "$#" -eq 2 -a -d "$1" ]; then
	REPO=$1
	PATCH=`mktemp`
	git show $2 > $PATCH || usage
else
	usage
fi


ORIG_DIR=`pwd`
LIBXFS_FILES=`mktemp`
NEWPATCH=`mktemp`

cd $REPO

# Are we using guilt? This works even if no patch is applied.
guilt top &> /dev/null
if [ $? -eq 0 ]; then
	GUILT=1
else
	GUILT=0
fi

# Filter the patch into the right format & files for the other tree

if   [ -d "fs/xfs/libxfs" ]; then	# We are applying a progs patch to the kernel tree
	lsdiff $PATCH | grep -q "a/libxfs/"
	if [ $? -ne 0 ]; then
		echo "Doesn't look like an xfsprogs patch with libxfs changes"
		fail
	fi

	# The files we will try to apply to
	ls -1 fs/xfs/libxfs/*.[ch] | sed -e "s%.*/\(.*\)%*\1%" > $LIBXFS_FILES

	# Create the new patch
	filterdiff \
		-I $LIBXFS_FILES \
		--strip=1 \
		--addoldprefix=a/fs/xfs/ \
		--addnewprefix=b/fs/xfs/ \
		$PATCH > $NEWPATCH 

elif [ -d "libxfs" -a -d "libxlog" ]; then	# We are applying a kernel patch to the xfsprogs tree
	lsdiff $PATCH | grep -q "a/fs/xfs/libxfs/"
	if [ $? -ne 0 ]; then
		echo "Doesn't look like a kernel patch with libxfs changes"
		fail
	fi

	# The files we will try to apply to
	ls -1 libxfs/*.[ch] | sed -e "s%.*/\(.*\)%*\1%" > $LIBXFS_FILES

	# Create the new patch
	filterdiff \
		-I $LIBXFS_FILES \
		--strip=3 \
		--addoldprefix=a/ \
		--addnewprefix=b/ \
		$PATCH > $NEWPATCH 
else
	echo "Sorry, I don't recognize repo $REPO"
	fail
fi

echo "Filtered patch for $REPO contains:"
lsdiff $NEWPATCH


# Ok, now apply with guilt or patch; either may fail and require a force
# and/or a manual reject fixup
if [ $GUILT -eq 1 ]; then
	echo "$REPO looks like a guilt directory."
	PATCHES=`guilt applied | wc -l`
	if [ $PATCHES -gt 0 ]; then
		echo -n "Top patch is: "
		guilt top
	fi
	read -r -p "Create new Guilt patch? (Enter patch name or return to skip) " response
	[ -z "$response" ] && guilt refresh; guilt import -P $response $NEWPATCH; guilt push
else
	echo "Applying with patch utility:"
	patch -p1 < $NEWPATCH
fi

echo "Patch was applied in $REPO; check for rejects, guilt push -f, etc"

cleanup

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Script to cross-apply libxfs changes
  2015-05-15 18:01 Script to cross-apply libxfs changes Eric Sandeen
@ 2015-06-15  0:01 ` Dave Chinner
  2015-06-15  0:13   ` Dave Chinner
  2015-06-15  3:40 ` Eric Sandeen
  1 sibling, 1 reply; 4+ messages in thread
From: Dave Chinner @ 2015-06-15  0:01 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs-oss

On Fri, May 15, 2015 at 01:01:07PM -0500, Eric Sandeen wrote:
> I'm terrible at bash, so don't laugh.  But this more or less works for me ...
> 
> This script takes either a patch name or a commit ID in the current
> tree, and massages that change into a libxfs patch for the other tree;
> i.e. it applies a kernel libxfs patch to xfsprogs, or vice versa.
> It'll create a guilt patch if it looks like a guilt dir, or just smack
> it in with "patch" if not.
> 
> It can surely be improved, but it's a start.
> 
> Example below, and script at the end.  Requires filterdiff.
> 
> [root@bp-05 xfsprogs]# git log
> commit 9681b791929795cd7dc6c7a79c3a69354f34e0b0
> ...
> [root@bp-05 xfsprogs]# libxfs-apply /mnt/test2/git/linux-xfs/ 9681b791929795cd7dc6c7a79c3a69354f34e0b0
> Filtered patch for /mnt/test2/git/linux-xfs/ contains:
> a/fs/xfs/libxfs/xfs_alloc.c
> a/fs/xfs/libxfs/xfs_alloc_btree.c
> a/fs/xfs/libxfs/xfs_attr_leaf.c
> a/fs/xfs/libxfs/xfs_attr_remote.c
> a/fs/xfs/libxfs/xfs_bmap_btree.c
> a/fs/xfs/libxfs/xfs_btree.c
> a/fs/xfs/libxfs/xfs_da_btree.c
> a/fs/xfs/libxfs/xfs_dir2_block.c
> a/fs/xfs/libxfs/xfs_dir2_data.c
> a/fs/xfs/libxfs/xfs_dir2_leaf.c
> a/fs/xfs/libxfs/xfs_dir2_node.c
> a/fs/xfs/libxfs/xfs_dquot_buf.c
> a/fs/xfs/libxfs/xfs_format.h
> a/fs/xfs/libxfs/xfs_ialloc.c
> a/fs/xfs/libxfs/xfs_ialloc_btree.c
> a/fs/xfs/libxfs/xfs_inode_buf.c
> a/fs/xfs/libxfs/xfs_sb.c
> a/fs/xfs/libxfs/xfs_symlink_remote.c
> /mnt/test2/git/linux-xfs/ looks like a guilt directory.
> Top patch is: percpu-2
> Create new Guilt patch? (Enter patch name or return to skip) new-uuid
> Applying patch..new-uuid
> Patch applied.
> Patch was applied in /mnt/test2/git/linux-xfs/; check for rejects, guilt push -f, etc
> [root@bp-05 xfsprogs]#

Eric, can you add a sign-off on this? I'll add it to the xfsprogs
repo under a tools/ directory and write some docco for it. No point
in having someone write a script like this and then ignoring it...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Script to cross-apply libxfs changes
  2015-06-15  0:01 ` Dave Chinner
@ 2015-06-15  0:13   ` Dave Chinner
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Chinner @ 2015-06-15  0:13 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs-oss

On Mon, Jun 15, 2015 at 10:01:15AM +1000, Dave Chinner wrote:
> On Fri, May 15, 2015 at 01:01:07PM -0500, Eric Sandeen wrote:
> > I'm terrible at bash, so don't laugh.  But this more or less works for me ...
> > 
> > This script takes either a patch name or a commit ID in the current
> > tree, and massages that change into a libxfs patch for the other tree;
> > i.e. it applies a kernel libxfs patch to xfsprogs, or vice versa.
> > It'll create a guilt patch if it looks like a guilt dir, or just smack
> > it in with "patch" if not.
> > 
> > It can surely be improved, but it's a start.
> > 
> > Example below, and script at the end.  Requires filterdiff.
> > 
> > [root@bp-05 xfsprogs]# git log
> > commit 9681b791929795cd7dc6c7a79c3a69354f34e0b0
> > ...
> > [root@bp-05 xfsprogs]# libxfs-apply /mnt/test2/git/linux-xfs/ 9681b791929795cd7dc6c7a79c3a69354f34e0b0
> > Filtered patch for /mnt/test2/git/linux-xfs/ contains:
> > a/fs/xfs/libxfs/xfs_alloc.c
> > a/fs/xfs/libxfs/xfs_alloc_btree.c
> > a/fs/xfs/libxfs/xfs_attr_leaf.c
> > a/fs/xfs/libxfs/xfs_attr_remote.c
> > a/fs/xfs/libxfs/xfs_bmap_btree.c
> > a/fs/xfs/libxfs/xfs_btree.c
> > a/fs/xfs/libxfs/xfs_da_btree.c
> > a/fs/xfs/libxfs/xfs_dir2_block.c
> > a/fs/xfs/libxfs/xfs_dir2_data.c
> > a/fs/xfs/libxfs/xfs_dir2_leaf.c
> > a/fs/xfs/libxfs/xfs_dir2_node.c
> > a/fs/xfs/libxfs/xfs_dquot_buf.c
> > a/fs/xfs/libxfs/xfs_format.h
> > a/fs/xfs/libxfs/xfs_ialloc.c
> > a/fs/xfs/libxfs/xfs_ialloc_btree.c
> > a/fs/xfs/libxfs/xfs_inode_buf.c
> > a/fs/xfs/libxfs/xfs_sb.c
> > a/fs/xfs/libxfs/xfs_symlink_remote.c
> > /mnt/test2/git/linux-xfs/ looks like a guilt directory.
> > Top patch is: percpu-2
> > Create new Guilt patch? (Enter patch name or return to skip) new-uuid
> > Applying patch..new-uuid
> > Patch applied.
> > Patch was applied in /mnt/test2/git/linux-xfs/; check for rejects, guilt push -f, etc
> > [root@bp-05 xfsprogs]#
> 
> Eric, can you add a sign-off on this? I'll add it to the xfsprogs
> repo under a tools/ directory and write some docco for it. No point
> in having someone write a script like this and then ignoring it...

Ok, I'm also going to modify it. It currently needs to be run in the
source repository, rather than in the destination repository. It's
not obvious, because the CLI interface is:

	"$prog <destination repo> <source repo commit id>"

I think it makes more sense to run from the destination repo, and
specify "source repo" "source repo commit id" as the paramters.

I'll also look to supporting a range of commit id's so that a series
can be pulled in with a single command....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Script to cross-apply libxfs changes
  2015-05-15 18:01 Script to cross-apply libxfs changes Eric Sandeen
  2015-06-15  0:01 ` Dave Chinner
@ 2015-06-15  3:40 ` Eric Sandeen
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Sandeen @ 2015-06-15  3:40 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs-oss

Btw you can add: 

Signed-off-by: Eric Sandeen <sandeen@redhat.com>

To this

> On May 15, 2015, at 1:01 PM, Eric Sandeen <sandeen@redhat.com> wrote:
> 
> I'm terrible at bash, so don't laugh.  But this more or less works for me ...
> 
> This script takes either a patch name or a commit ID in the current
> tree, and massages that change into a libxfs patch for the other tree;
> i.e. it applies a kernel libxfs patch to xfsprogs, or vice versa.
> It'll create a guilt patch if it looks like a guilt dir, or just smack
> it in with "patch" if not.
> 
> It can surely be improved, but it's a start.
> 
> Example below, and script at the end.  Requires filterdiff.
> 
> [root@bp-05 xfsprogs]# git log
> commit 9681b791929795cd7dc6c7a79c3a69354f34e0b0
> ...
> [root@bp-05 xfsprogs]# libxfs-apply /mnt/test2/git/linux-xfs/ 9681b791929795cd7dc6c7a79c3a69354f34e0b0
> Filtered patch for /mnt/test2/git/linux-xfs/ contains:
> a/fs/xfs/libxfs/xfs_alloc.c
> a/fs/xfs/libxfs/xfs_alloc_btree.c
> a/fs/xfs/libxfs/xfs_attr_leaf.c
> a/fs/xfs/libxfs/xfs_attr_remote.c
> a/fs/xfs/libxfs/xfs_bmap_btree.c
> a/fs/xfs/libxfs/xfs_btree.c
> a/fs/xfs/libxfs/xfs_da_btree.c
> a/fs/xfs/libxfs/xfs_dir2_block.c
> a/fs/xfs/libxfs/xfs_dir2_data.c
> a/fs/xfs/libxfs/xfs_dir2_leaf.c
> a/fs/xfs/libxfs/xfs_dir2_node.c
> a/fs/xfs/libxfs/xfs_dquot_buf.c
> a/fs/xfs/libxfs/xfs_format.h
> a/fs/xfs/libxfs/xfs_ialloc.c
> a/fs/xfs/libxfs/xfs_ialloc_btree.c
> a/fs/xfs/libxfs/xfs_inode_buf.c
> a/fs/xfs/libxfs/xfs_sb.c
> a/fs/xfs/libxfs/xfs_symlink_remote.c
> /mnt/test2/git/linux-xfs/ looks like a guilt directory.
> Top patch is: percpu-2
> Create new Guilt patch? (Enter patch name or return to skip) new-uuid
> Applying patch..new-uuid
> Patch applied.
> Patch was applied in /mnt/test2/git/linux-xfs/; check for rejects, guilt push -f, etc
> [root@bp-05 xfsprogs]#
> 
> ==========
> 
> #!/bin/bash
> 
> # 2 args:
> #    libxfs-apply <repo> <commit ID or patchfile>
> 
> usage()
> {
>    echo "libxfs-apply repodir [patchfile|commitid]"
>    exit
> }
> 
> cleanup()
> {
>    rm -f $PATCH $LIBXFS_FILES $NEWPATCH
> }
> 
> fail()
> {
>    cleanup
>    cd $ORIG_DIR
>    exit
> }
> 
> if [ "$#" -eq 2 -a -d "$1" -a -f "$2" ]; then
>    REPO=$1
>    PATCH=$2
> elif [ "$#" -eq 2 -a -d "$1" ]; then
>    REPO=$1
>    PATCH=`mktemp`
>    git show $2 > $PATCH || usage
> else
>    usage
> fi
> 
> 
> ORIG_DIR=`pwd`
> LIBXFS_FILES=`mktemp`
> NEWPATCH=`mktemp`
> 
> cd $REPO
> 
> # Are we using guilt? This works even if no patch is applied.
> guilt top &> /dev/null
> if [ $? -eq 0 ]; then
>    GUILT=1
> else
>    GUILT=0
> fi
> 
> # Filter the patch into the right format & files for the other tree
> 
> if   [ -d "fs/xfs/libxfs" ]; then    # We are applying a progs patch to the kernel tree
>    lsdiff $PATCH | grep -q "a/libxfs/"
>    if [ $? -ne 0 ]; then
>        echo "Doesn't look like an xfsprogs patch with libxfs changes"
>        fail
>    fi
> 
>    # The files we will try to apply to
>    ls -1 fs/xfs/libxfs/*.[ch] | sed -e "s%.*/\(.*\)%*\1%" > $LIBXFS_FILES
> 
>    # Create the new patch
>    filterdiff \
>        -I $LIBXFS_FILES \
>        --strip=1 \
>        --addoldprefix=a/fs/xfs/ \
>        --addnewprefix=b/fs/xfs/ \
>        $PATCH > $NEWPATCH 
> 
> elif [ -d "libxfs" -a -d "libxlog" ]; then    # We are applying a kernel patch to the xfsprogs tree
>    lsdiff $PATCH | grep -q "a/fs/xfs/libxfs/"
>    if [ $? -ne 0 ]; then
>        echo "Doesn't look like a kernel patch with libxfs changes"
>        fail
>    fi
> 
>    # The files we will try to apply to
>    ls -1 libxfs/*.[ch] | sed -e "s%.*/\(.*\)%*\1%" > $LIBXFS_FILES
> 
>    # Create the new patch
>    filterdiff \
>        -I $LIBXFS_FILES \
>        --strip=3 \
>        --addoldprefix=a/ \
>        --addnewprefix=b/ \
>        $PATCH > $NEWPATCH 
> else
>    echo "Sorry, I don't recognize repo $REPO"
>    fail
> fi
> 
> echo "Filtered patch for $REPO contains:"
> lsdiff $NEWPATCH
> 
> 
> # Ok, now apply with guilt or patch; either may fail and require a force
> # and/or a manual reject fixup
> if [ $GUILT -eq 1 ]; then
>    echo "$REPO looks like a guilt directory."
>    PATCHES=`guilt applied | wc -l`
>    if [ $PATCHES -gt 0 ]; then
>        echo -n "Top patch is: "
>        guilt top
>    fi
>    read -r -p "Create new Guilt patch? (Enter patch name or return to skip) " response
>    [ -z "$response" ] && guilt refresh; guilt import -P $response $NEWPATCH; guilt push
> else
>    echo "Applying with patch utility:"
>    patch -p1 < $NEWPATCH
> fi
> 
> echo "Patch was applied in $REPO; check for rejects, guilt push -f, etc"
> 
> cleanup
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-15  3:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-15 18:01 Script to cross-apply libxfs changes Eric Sandeen
2015-06-15  0:01 ` Dave Chinner
2015-06-15  0:13   ` Dave Chinner
2015-06-15  3:40 ` Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox