quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [PATCH] Preserving file permissions with quilt


From: Tim Bird
Subject: [Quilt-dev] [PATCH] Preserving file permissions with quilt
Date: Thu, 24 Jan 2008 13:34:55 -0800
User-agent: Thunderbird 1.5.0.4 (X11/20060614)

Hi all,

I have a problem with preserving file permissions using quilt.
Basically, the execute bit is lost on new files when patches are
popped and pushed.  Here is a sequence of commands showing the
problem:

------------------------
[]# ls -l
total 4
-rw-r--r-- 1 root root 24 Jan 24 11:22 foo
[]# quilt new permtest.patch
Patch permtest.patch is now on top
[]# quilt add testscript
File work/test/qtest/files/testscript added to patch permtest.patch
[]# vi testscript
[]# chmod a+x testscript
[]# ls -l
total 8
-rw-r--r-- 1 root root 24 Jan 24 11:22 foo
-rwxr-xr-x 1 root root 30 Jan 24 13:00 testscript

[]# ./testscript
hello world
[]# quilt refresh
Refreshed patch permtest.patch
[]# quilt pop
Removing patch permtest.patch
Removing work/test/qtest/files/testscript

No patches applied
[]# quilt push
Applying patch permtest.patch
patching file work/test/qtest/files/testscript

Now at patch permtest.patch
[]# ls -l
total 8
-rw-r--r-- 1 root  root    24 Jan 24 11:22 foo
-rw-r--r-- 1 root  root    30 Jan 24 11:23 testscript
^^^^^^^^^^ ---> Look ma, no x's
[]# ./testscript
bash: ./testscript: Permission denied
--------------------

Some time ago I added a feature to quilt to fix this, but
I've never published it.  I'm doing that now.  The feature
looks for a file with the same name as a patch, and with the
extension '.qsh', in the patches directory.  If it is found
and executable, it is executed after the push operation for
the associated patch.  You can use this to perform any
'fixup' operation you want, but I just use it to assign
the correct permissions to the file.

Here is the patch:
---
 quilt/push.in |    8   8 +     0 -     0 !
 1 file changed, 8 insertions(+)

Index: quilt-0.46/quilt/push.in
===================================================================
--- quilt-0.46.orig/quilt/push.in
+++ quilt-0.46/quilt/push.in
@@ -206,6 +206,14 @@ add_patch()
                        mkdir "$QUILT_PC/$patch"
                fi

+               # run a "quilt-sh" hook, if present, after applying the patch
+               # can be used to set file perms
+               local patch_file=$(patch_file_name $patch)
+               if [ -x "${patch_file}.qsh" ]
+               then
+                       ${patch_file}.qsh
+               fi
+
                if ! [ -e $patch_file ]
                then
                        printf $"Patch %s does not exist; applied empty 
patch\n" \


If I then create an executable file: patches/permtest.patch.qsh
with the contents:
--------
#!/bin/sh

chmod a+x testscript

Then the permissions get set properly on testscript
when I do a push of permtest.patch.

This seems like a kludge.  But it's a simple and effective one.

Another alternative would be to encode the permissions in the
patch ('git show' does this for new files), and modify push
to parse those and do the necessary chmods.  That would be
a lot more work, and it would be less flexible than this, but
it might be easier to teach people to use.

Feedback is welcome.  (Even if it consists of "quilt already
does this another way, you knucklehead!")

Thanks,
 -- Tim

=============================
Tim Bird
Architecture Group Chair, CE Linux Forum
Senior Staff Engineer, Sony Corporation of America
=============================





reply via email to

[Prev in Thread] Current Thread [Next in Thread]