Implementing a workaround for a problem found by darkside:
authorFabian Groffen <grobian@gentoo.org>
Sat, 6 Dec 2008 20:52:14 +0000 (20:52 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sat, 6 Dec 2008 20:52:14 +0000 (20:52 -0000)
http://archives.gentoo.org/gentoo-alt/msg_fdb765f2e49f7bcad828a06b994f15be.xml

Just temporarily make to be stripped objects writable, if they are not,
to have strip succeed in doing its job.

svn path=/main/branches/prefix/; revision=12170

bin/prepstrip

index 8ab6b37cd473203463a960e55a3e2be6c84a1a4f..a312397458f23d3950313f022eb4229b87d28710 100755 (executable)
@@ -116,6 +116,15 @@ do
                strip_this=false
        fi
 
+       # In Prefix we are usually an unprivileged user, so we can't strip
+       # unwritable objects.  Make them temporarily writable for the
+       # stripping.
+       was_not_writable=false
+       if [[ ! -w ${x} ]] ; then
+               was_not_writable=true
+               chmod u+w "${x}"
+       fi
+
        # only split debug info for final linked objects
        # or kernel modules as debuginfo for intermediatary
        # files (think crt*.o from gcc/glibc) is useless and
@@ -143,4 +152,8 @@ do
                        ${STRIP} ${SAFE_STRIP_FLAGS} "${x}"
                fi
        fi
+
+       if [[ ${was_not_writable} == "true" ]] ; then
+               chmod u-w "${x}"
+       fi
 done