[PATCH] makepkg --packagelist: just list the built package files we will build

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] makepkg --packagelist: just list the built package files we will build

Eli Schwartz-2
Currently this seems to be only theoretically useful. The most likely
reason for wanting a packagelist is in order to script makepkg and
derive the filenames for the packages we want to install or repo-add,
but in the current implementation this requires a lot of additional
post-processing which must be duplicated in every utility to wrap
makepkg.

- It is of minimal use to know what packages might get created on some
  other device utilizing a different CPU/OS architecture, so don't list
  them.
- It is non-trivial to reimplement makepkg's logic for sourcing any of
  several makepkg.conf configuration files, then applying environment
  overrides in order to get the PKGDEST and PKGEXT, so include them
  directly in the returned filenames.

Signed-off-by: Eli Schwartz <[hidden email]>
---
 scripts/libmakepkg/util/pkgbuild.sh.in | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in
index 2a4bd3af..6cfda0b3 100644
--- a/scripts/libmakepkg/util/pkgbuild.sh.in
+++ b/scripts/libmakepkg/util/pkgbuild.sh.in
@@ -149,14 +149,12 @@ print_all_package_names() {
  local version=$(get_full_version)
  local architecture pkg opts a
  for pkg in ${pkgname[@]}; do
- get_pkgbuild_attribute "$pkg" 'arch' 1 architecture
+ architecture=$(get_pkg_arch $pkg)
  get_pkgbuild_attribute "$pkg" 'options' 1 opts
- for a in ${architecture[@]}; do
- printf "%s-%s-%s\n" "$pkg" "$version" "$a"
- if in_opt_array "debug" ${opts[@]} && in_opt_array "strip" ${opts[@]}; then
- printf "%s-%s-%s-%s\n" "$pkg" "@DEBUGSUFFIX@" "$version" "$a"
- fi
- done
+ printf "%s/%s-%s-%s%s\n" "$PKGDEST" "$pkg" "$version" "$architecture" "$PKGEXT"
+ if in_opt_array "debug" ${opts[@]} && in_opt_array "strip" ${opts[@]}; then
+ printf "%s/%s-%s-%s-%s%s\n" "$PKGDEST" "$pkg" "@DEBUGSUFFIX@" "$version" "$architecture" "$PKGEXT"
+ fi
  done
 }
 
--
2.15.0
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] makepkg --packagelist: just list the built package files we will build

Allan McRae
On 31/10/17 04:37, Eli Schwartz wrote:

> Currently this seems to be only theoretically useful. The most likely
> reason for wanting a packagelist is in order to script makepkg and
> derive the filenames for the packages we want to install or repo-add,
> but in the current implementation this requires a lot of additional
> post-processing which must be duplicated in every utility to wrap
> makepkg.
>
> - It is of minimal use to know what packages might get created on some
>   other device utilizing a different CPU/OS architecture, so don't list
>   them.
> - It is non-trivial to reimplement makepkg's logic for sourcing any of
>   several makepkg.conf configuration files, then applying environment
>   overrides in order to get the PKGDEST and PKGEXT, so include them
>   directly in the returned filenames.
>
> Signed-off-by: Eli Schwartz <[hidden email]>

Needs makepkg man page update too.

> ---
>  scripts/libmakepkg/util/pkgbuild.sh.in | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in
> index 2a4bd3af..6cfda0b3 100644
> --- a/scripts/libmakepkg/util/pkgbuild.sh.in
> +++ b/scripts/libmakepkg/util/pkgbuild.sh.in
> @@ -149,14 +149,12 @@ print_all_package_names() {
>   local version=$(get_full_version)
>   local architecture pkg opts a
>   for pkg in ${pkgname[@]}; do
> - get_pkgbuild_attribute "$pkg" 'arch' 1 architecture
> + architecture=$(get_pkg_arch $pkg)
>   get_pkgbuild_attribute "$pkg" 'options' 1 opts
> - for a in ${architecture[@]}; do
> - printf "%s-%s-%s\n" "$pkg" "$version" "$a"
> - if in_opt_array "debug" ${opts[@]} && in_opt_array "strip" ${opts[@]}; then
> - printf "%s-%s-%s-%s\n" "$pkg" "@DEBUGSUFFIX@" "$version" "$a"
> - fi
> - done
> + printf "%s/%s-%s-%s%s\n" "$PKGDEST" "$pkg" "$version" "$architecture" "$PKGEXT"
> + if in_opt_array "debug" ${opts[@]} && in_opt_array "strip" ${opts[@]}; then
> + printf "%s/%s-%s-%s-%s%s\n" "$PKGDEST" "$pkg" "@DEBUGSUFFIX@" "$version" "$architecture" "$PKGEXT"
> + fi
>   done
>  }
>  
>
Reply | Threaded
Open this post in threaded view
|

[PATCH v2] makepkg --packagelist: just list the built package files we will build

Eli Schwartz-2
Currently this seems to be only theoretically useful. The most likely
reason for wanting a packagelist is in order to script makepkg and
derive the filenames for the packages we want to install or repo-add,
but in the current implementation this requires a lot of additional
post-processing which must be duplicated in every utility to wrap
makepkg.

- It is of minimal use to know what packages might get created on some
  other device utilizing a different CPU/OS architecture, so don't list
  them.
- It is non-trivial to reimplement makepkg's logic for sourcing any of
  several makepkg.conf configuration files, then applying environment
  overrides in order to get the PKGDEST and PKGEXT, so include them
  directly in the returned filenames.
- Output is null-delimited, in order that the filenames can be reliably
  parsed.

Signed-off-by: Eli Schwartz <[hidden email]>
---

v2: use null delimited text, update manpage with the effects of the
patch.

 doc/makepkg.8.txt                      |  4 ++--
 scripts/libmakepkg/util/pkgbuild.sh.in | 13 ++++++-------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt
index 460c4e26..aed46eb2 100644
--- a/doc/makepkg.8.txt
+++ b/doc/makepkg.8.txt
@@ -200,8 +200,8 @@ Options
  useful if you are redirecting makepkg output to file.
 
 *\--packagelist*::
- List the packages that would be produced without building. Listed
- package names do not include PKGEXT.
+ List the package filenames that would be produced without building. Listed
+ package filenames are null-delimited and include PKGDEST and PKGEXT.
 
 *\--printsrcinfo*::
  Generate and print the SRCINFO file to stdout.
diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in
index 2a4bd3af..58e67380 100644
--- a/scripts/libmakepkg/util/pkgbuild.sh.in
+++ b/scripts/libmakepkg/util/pkgbuild.sh.in
@@ -149,15 +149,14 @@ print_all_package_names() {
  local version=$(get_full_version)
  local architecture pkg opts a
  for pkg in ${pkgname[@]}; do
- get_pkgbuild_attribute "$pkg" 'arch' 1 architecture
+ architecture=$(get_pkg_arch $pkg)
  get_pkgbuild_attribute "$pkg" 'options' 1 opts
- for a in ${architecture[@]}; do
- printf "%s-%s-%s\n" "$pkg" "$version" "$a"
- if in_opt_array "debug" ${opts[@]} && in_opt_array "strip" ${opts[@]}; then
- printf "%s-%s-%s-%s\n" "$pkg" "@DEBUGSUFFIX@" "$version" "$a"
- fi
- done
+ printf "%s/%s-%s-%s%s\0" "$PKGDEST" "$pkg" "$version" "$architecture" "$PKGEXT"
+ if in_opt_array "debug" ${opts[@]} && in_opt_array "strip" ${opts[@]}; then
+ printf "%s/%s-%s-%s-%s%s\0" "$PKGDEST" "$pkg" "@DEBUGSUFFIX@" "$version" "$architecture" "$PKGEXT"
+ fi
  done
+ printf '\n'
 }
 
 get_all_sources() {
--
2.16.1
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2] makepkg --packagelist: just list the built package files we will build

Allan McRae
On 06/02/18 12:47, Eli Schwartz wrote:

> Currently this seems to be only theoretically useful. The most likely
> reason for wanting a packagelist is in order to script makepkg and
> derive the filenames for the packages we want to install or repo-add,
> but in the current implementation this requires a lot of additional
> post-processing which must be duplicated in every utility to wrap
> makepkg.
>
> - It is of minimal use to know what packages might get created on some
>   other device utilizing a different CPU/OS architecture, so don't list
>   them.
> - It is non-trivial to reimplement makepkg's logic for sourcing any of
>   several makepkg.conf configuration files, then applying environment
>   overrides in order to get the PKGDEST and PKGEXT, so include them
>   directly in the returned filenames.
> - Output is null-delimited, in order that the filenames can be reliably
>   parsed.
>
> Signed-off-by: Eli Schwartz <[hidden email]>
> ---
>
> v2: use null delimited text, update manpage with the effects of the
> patch.

Newline separation should be fine.  makepkg ensures most (all?) of the
fields are not allowed to have newlines in them.  If any can, we need to
catch that in out PKGBUILD linting and error out.  Probably need to add
a check that the fields from makepkg.conf don't have newlines either.

A
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2] makepkg --packagelist: just list the built package files we will build

Eli Schwartz-2
On 02/07/2018 07:24 PM, Allan McRae wrote:
> Newline separation should be fine.  makepkg ensures most (all?) of the
> fields are not allowed to have newlines in them.  If any can, we need to
> catch that in out PKGBUILD linting and error out.  Probably need to add
> a check that the fields from makepkg.conf don't have newlines either.

I was thinking primarily of the fields in makepkg.conf, since AFAICT no
PKGBUILD fields used in assembling the filename can contain newlines.

OTOH, both PKGDEST and PKGEXT currently allow this, as do all the other
directory variables in makepkg.conf

Should we add a lint_pkgbuild check for all the makepkg.conf variables?

--
Eli Schwartz
Bug Wrangler and Trusted User


signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2] makepkg --packagelist: just list the built package files we will build

Allan McRae
On 08/02/18 11:22, Eli Schwartz wrote:

> On 02/07/2018 07:24 PM, Allan McRae wrote:
>> Newline separation should be fine.  makepkg ensures most (all?) of the
>> fields are not allowed to have newlines in them.  If any can, we need to
>> catch that in out PKGBUILD linting and error out.  Probably need to add
>> a check that the fields from makepkg.conf don't have newlines either.
>
> I was thinking primarily of the fields in makepkg.conf, since AFAICT no
> PKGBUILD fields used in assembling the filename can contain newlines.
>
> OTOH, both PKGDEST and PKGEXT currently allow this, as do all the other
> directory variables in makepkg.conf
>
> Should we add a lint_pkgbuild check for all the makepkg.conf variables?
>

Yes please.   Although, lint_config.sh might be a better place to put
it, as it is not really part of pkgbuild linting.

Allan
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2] makepkg --packagelist: just list the built package files we will build

Eli Schwartz-2
On 02/07/2018 10:37 PM, Allan McRae wrote:

> On 08/02/18 11:22, Eli Schwartz wrote:
>> On 02/07/2018 07:24 PM, Allan McRae wrote:
>>> Newline separation should be fine.  makepkg ensures most (all?) of the
>>> fields are not allowed to have newlines in them.  If any can, we need to
>>> catch that in out PKGBUILD linting and error out.  Probably need to add
>>> a check that the fields from makepkg.conf don't have newlines either.
>>
>> I was thinking primarily of the fields in makepkg.conf, since AFAICT no
>> PKGBUILD fields used in assembling the filename can contain newlines.
>>
>> OTOH, both PKGDEST and PKGEXT currently allow this, as do all the other
>> directory variables in makepkg.conf
>>
>> Should we add a lint_pkgbuild check for all the makepkg.conf variables?
>>
>
> Yes please.   Although, lint_config.sh might be a better place to put
> it, as it is not really part of pkgbuild linting.
Sure, anything else that we should lint while we are at it? I think
mostly the only things to check are variable types, which we could
probably crib from lint_pkgbuild/variable.sh

--
Eli Schwartz
Bug Wrangler and Trusted User


signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2] makepkg --packagelist: just list the built package files we will build

Allan McRae
On 08/02/18 13:44, Eli Schwartz wrote:

> On 02/07/2018 10:37 PM, Allan McRae wrote:
>> On 08/02/18 11:22, Eli Schwartz wrote:
>>> On 02/07/2018 07:24 PM, Allan McRae wrote:
>>>> Newline separation should be fine.  makepkg ensures most (all?) of the
>>>> fields are not allowed to have newlines in them.  If any can, we need to
>>>> catch that in out PKGBUILD linting and error out.  Probably need to add
>>>> a check that the fields from makepkg.conf don't have newlines either.
>>>
>>> I was thinking primarily of the fields in makepkg.conf, since AFAICT no
>>> PKGBUILD fields used in assembling the filename can contain newlines.
>>>
>>> OTOH, both PKGDEST and PKGEXT currently allow this, as do all the other
>>> directory variables in makepkg.conf
>>>
>>> Should we add a lint_pkgbuild check for all the makepkg.conf variables?
>>>
>>
>> Yes please.   Although, lint_config.sh might be a better place to put
>> it, as it is not really part of pkgbuild linting.
>
> Sure, anything else that we should lint while we are at it? I think
> mostly the only things to check are variable types, which we could
> probably crib from lint_pkgbuild/variable.sh
>

We should only lint things that we want to ensure match assumptions.
For this patch, checking CARCH and PKGEXT are strings and don't contain
newlines is enough.

A
Reply | Threaded
Open this post in threaded view
|

[PATCH v3] makepkg --packagelist: just list the built package files we will build

Eli Schwartz-2
In reply to this post by Allan McRae
Currently this seems to be only theoretically useful. The most likely
reason for wanting a packagelist is in order to script makepkg and
derive the filenames for the packages we want to install or repo-add,
but in the current implementation this requires a lot of additional
post-processing which must be duplicated in every utility to wrap
makepkg.

- It is of minimal use to know what packages might get created on some
  other device utilizing a different CPU/OS architecture, so don't list
  them.
- It is non-trivial to reimplement makepkg's logic for sourcing any of
  several makepkg.conf configuration files, then applying environment
  overrides in order to get the PKGDEST and PKGEXT, so include them
  directly in the returned filenames.
- Output is delimited by newlines, for readability. For maximum
  parsing reliability, libmakepkg needs to learn how to lint the PKGDEST
  and PKGEXT variables to ensure they do not contain newlines, which
  will be submitted in a separate patch.

Signed-off-by: Eli Schwartz <[hidden email]>
---

v3: revert the null-delimited text change

 doc/makepkg.8.txt                      |  4 ++--
 scripts/libmakepkg/util/pkgbuild.sh.in | 12 +++++-------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt
index 460c4e26..a065b795 100644
--- a/doc/makepkg.8.txt
+++ b/doc/makepkg.8.txt
@@ -200,8 +200,8 @@ Options
  useful if you are redirecting makepkg output to file.
 
 *\--packagelist*::
- List the packages that would be produced without building. Listed
- package names do not include PKGEXT.
+ List the package filenames that would be produced without building. Listed
+ package filenames include PKGDEST and PKGEXT.
 
 *\--printsrcinfo*::
  Generate and print the SRCINFO file to stdout.
diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in
index 2a4bd3af..6cfda0b3 100644
--- a/scripts/libmakepkg/util/pkgbuild.sh.in
+++ b/scripts/libmakepkg/util/pkgbuild.sh.in
@@ -149,14 +149,12 @@ print_all_package_names() {
  local version=$(get_full_version)
  local architecture pkg opts a
  for pkg in ${pkgname[@]}; do
- get_pkgbuild_attribute "$pkg" 'arch' 1 architecture
+ architecture=$(get_pkg_arch $pkg)
  get_pkgbuild_attribute "$pkg" 'options' 1 opts
- for a in ${architecture[@]}; do
- printf "%s-%s-%s\n" "$pkg" "$version" "$a"
- if in_opt_array "debug" ${opts[@]} && in_opt_array "strip" ${opts[@]}; then
- printf "%s-%s-%s-%s\n" "$pkg" "@DEBUGSUFFIX@" "$version" "$a"
- fi
- done
+ printf "%s/%s-%s-%s%s\n" "$PKGDEST" "$pkg" "$version" "$architecture" "$PKGEXT"
+ if in_opt_array "debug" ${opts[@]} && in_opt_array "strip" ${opts[@]}; then
+ printf "%s/%s-%s-%s-%s%s\n" "$PKGDEST" "$pkg" "@DEBUGSUFFIX@" "$version" "$architecture" "$PKGEXT"
+ fi
  done
 }
 
--
2.16.1