[PATCH] makepkg: check for references to build root in package

View: New views
8 Messages — Rating Filter:   Alert me  

[PATCH] makepkg: check for references to build root in package

by Allan McRae-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Add a check that the package does not contain references to the
folder it was built in.

Fixes FS#14751

Signed-off-by: Allan McRae <allan@...>
---
 scripts/makepkg.sh.in |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 820d81f..a5b8f87 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -971,6 +971,12 @@ check_package() {
  warning "$(gettext "Invalid backup entry : %s")" "$file"
  fi
  done
+
+ # check for references to the build directory
+ grep -R "${srcdir}" "${pkgdir}" &>/dev/null
+ if [ $? -eq 0 ]; then
+ warning "$(gettext "Package contains reference to %s")" "\$srcdir"
+ fi
 }
 
 create_package() {
--
1.6.5.1



Re: [PATCH] makepkg: check for references to build root in package

by Cedric Staniewski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Allan McRae wrote:

> Add a check that the package does not contain references to the
> folder it was built in.
>
> Fixes FS#14751
>
> Signed-off-by: Allan McRae <allan@...>
> ---
>  scripts/makepkg.sh.in |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 820d81f..a5b8f87 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -971,6 +971,12 @@ check_package() {
>   warning "$(gettext "Invalid backup entry : %s")" "$file"
>   fi
>   done
> +
> + # check for references to the build directory
> + grep -R "${srcdir}" "${pkgdir}" &>/dev/null
> + if [ $? -eq 0 ]; then
> + warning "$(gettext "Package contains reference to %s")" "\$srcdir"
> + fi
>  }
>  
>  create_package() {


I wonder why you do not use

if grep -R "${srcdir}" "${pkgdir}" &>/dev/null; then

Is there a special cause for that or is it only for cosmetic reasons? Thanks.


Re: [PATCH] makepkg: check for references to build root in package

by Allan McRae-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Cedric Staniewski wrote:

> Allan McRae wrote:
>  
>> Add a check that the package does not contain references to the
>> folder it was built in.
>>
>> Fixes FS#14751
>>
>> Signed-off-by: Allan McRae <allan@...>
>> ---
>>  scripts/makepkg.sh.in |    6 ++++++
>>  1 files changed, 6 insertions(+), 0 deletions(-)
>>
>> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
>> index 820d81f..a5b8f87 100644
>> --- a/scripts/makepkg.sh.in
>> +++ b/scripts/makepkg.sh.in
>> @@ -971,6 +971,12 @@ check_package() {
>>   warning "$(gettext "Invalid backup entry : %s")" "$file"
>>   fi
>>   done
>> +
>> + # check for references to the build directory
>> + grep -R "${srcdir}" "${pkgdir}" &>/dev/null
>> + if [ $? -eq 0 ]; then
>> + warning "$(gettext "Package contains reference to %s")" "\$srcdir"
>> + fi
>>  }
>>  
>>  create_package() {
>>    
>
>
> I wonder why you do not use
>
> if grep -R "${srcdir}" "${pkgdir}" &>/dev/null; then
>
> Is there a special cause for that or is it only for cosmetic reasons? Thanks.
>  

No reason....   I was going to adjust my patch to this syntax.  
However, I have discovered, the patch causes makepkg to halt if there
are no files in ${pkgdir}.  This is entirely possible with something
like "meta-packages" which just contain a list of deps.  So I am going
to need to use some sort of "grep ... || ret=" syntax anyway.

Allan



[PATCH] makepkg: check for references to build root in package

by Allan McRae-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Add a check that the package does not contain references to the
folder it was built in.

Fixes FS#14751

Signed -off-by: Allan McRae <allan@...>
---
 scripts/makepkg.sh.in |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 66667f4..dd5f951 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -972,6 +972,13 @@ check_package() {
  warning "$(gettext "Invalid backup entry : %s")" "$file"
  fi
  done
+
+ # check for references to the build directory
+ local ret=0
+ grep -R "${srcdir}" "${pkgdir}" &>/dev/null || ret=1
+ if [ $ret -eq 0 ]; then
+ warning "$(gettext "Package contains reference to %s")" "\$srcdir"
+ fi
 }
 
 create_package() {
--
1.6.5.1



Re: [PATCH] makepkg: check for references to build root in package

by Cedric Staniewski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Allan McRae wrote:

> Cedric Staniewski wrote:
>> Allan McRae wrote:
>>  
>>> Add a check that the package does not contain references to the
>>> folder it was built in.
>>>
>>> Fixes FS#14751
>>>
>>> Signed-off-by: Allan McRae <allan@...>
>>> ---
>>>  scripts/makepkg.sh.in |    6 ++++++
>>>  1 files changed, 6 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
>>> index 820d81f..a5b8f87 100644
>>> --- a/scripts/makepkg.sh.in
>>> +++ b/scripts/makepkg.sh.in
>>> @@ -971,6 +971,12 @@ check_package() {
>>>              warning "$(gettext "Invalid backup entry : %s")" "$file"
>>>          fi
>>>      done
>>> +
>>> +    # check for references to the build directory
>>> +    grep -R "${srcdir}" "${pkgdir}" &>/dev/null
>>> +    if [ $? -eq 0 ]; then
>>> +        warning "$(gettext "Package contains reference to %s")"
>>> "\$srcdir"
>>> +    fi
>>>  }
>>>  
>>>  create_package() {
>>>    
>>
>>
>> I wonder why you do not use
>>
>> if grep -R "${srcdir}" "${pkgdir}" &>/dev/null; then
>>
>> Is there a special cause for that or is it only for cosmetic reasons?
>> Thanks.
>>  
>
> No reason....   I was going to adjust my patch to this syntax.  
> However, I have discovered, the patch causes makepkg to halt if there
> are no files in ${pkgdir}.  This is entirely possible with something
> like "meta-packages" which just contain a list of deps.  So I am going
> to need to use some sort of "grep ... || ret=" syntax anyway.
>
> Allan
>


I tried to reproduce this, but was not able to do so.

Patch:
-----------------
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 8812407..4bcb6b2 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -947,9 +947,7 @@ check_package() {
        done
 
        # check for references to the build directory
-       local ret=0
-       grep -R "${srcdir}" "${pkgdir}" &>/dev/null || ret=1
-       if [ $ret -eq 0 ]; then
+       if grep -R "${srcdir}" "${pkgdir}" &>/dev/null; then
                warning "$(gettext "Package contains reference to %s")" "\$srcdir"
        fi
 }
-----------------

PKGBUILD:
-----------------
pkgname=dummy
pkgver=1
pkgrel=1
pkgdesc="A dummy package"
arch=('any')
url="http://dummy.xyz"
license=('GPL')

build() {
  echo nothing to see here
  #echo "$srcdir" > "$pkgdir/bla"
}
------------------


Anyway... never mind.


Re: [PATCH] makepkg: check for references to build root in package

by Xavier Chantry-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Oct 25, 2009 at 7:26 PM, Cedric Staniewski <cedric@...> wrote:

>>
>> No reason....   I was going to adjust my patch to this syntax.
>> However, I have discovered, the patch causes makepkg to halt if there
>> are no files in ${pkgdir}.  This is entirely possible with something
>> like "meta-packages" which just contain a list of deps.  So I am going
>> to need to use some sort of "grep ... || ret=" syntax anyway.
>>
>> Allan
>>
>
>
> I tried to reproduce this, but was not able to do so.
>

Ah this is what I forgot to ask Allan today.

I wanted to tell him I didn't understand why grep would get stuck, and
why this other syntax would change anything about it.


Re: [PATCH] makepkg: check for references to build root in package

by Allan McRae-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Xavier wrote:

> On Sun, Oct 25, 2009 at 7:26 PM, Cedric Staniewski <cedric@...> wrote:
>  
>>> No reason....   I was going to adjust my patch to this syntax.
>>> However, I have discovered, the patch causes makepkg to halt if there
>>> are no files in ${pkgdir}.  This is entirely possible with something
>>> like "meta-packages" which just contain a list of deps.  So I am going
>>> to need to use some sort of "grep ... || ret=" syntax anyway.
>>>
>>> Allan
>>>
>>>      
>> I tried to reproduce this, but was not able to do so.
>>
>>    
>
> Ah this is what I forgot to ask Allan today.
>
> I wanted to tell him I didn't understand why grep would get stuck, and
> why this other syntax would change anything about it.
>  

I have no idea....   Yesterday when trying the "if grep" syntax, makepkg
would just stop directly before outputing "Creating package".  I assumed
it was something due to "set -e".   Strange thing is, I can not
replicate it today...   even after pulling the stashed changes I had
saved so I could go back and figure it out.  I might be going mad...

I have adjusted the patch to use Cedric's syntax now that it is working
for me.

Allan



Re: [PATCH] makepkg: check for references to build root in package

by Jeff-304 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Oct 26, 2009 at 09:08:21AM +1000, Allan McRae wrote:
>
> I have adjusted the patch to use Cedric's syntax now that it is working
> for me.

FWIW, you can also make the line a tad shorter by using grep's -q
instead of &>/dev/null.

--
Jeff

My other computer is an abacus.