Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   ArchLinux Pacman Development (http://www.linux-archive.org/archlinux-pacman-development/)
-   -   makepkg: allow specifying alternative build directory (http://www.linux-archive.org/archlinux-pacman-development/540127-makepkg-allow-specifying-alternative-build-directory.html)

Dan McGee 06-15-2011 02:31 PM

makepkg: allow specifying alternative build directory
 
On Wed, Jun 15, 2011 at 4:13 AM, Allan McRae <allan@archlinux.org> wrote:
> Add a BUILDDIR variable (which can be overridden in the environment)
> to specify an alternative location for building the package. This is
> useful for people who want to build on a different filesystem for
> improved performance (e.g. tmpfs).
>
> Signed-off-by: Allan McRae <allan@archlinux.org>
> ---
> *doc/makepkg.8.txt * * *| * *3 +++
> *doc/makepkg.conf.5.txt | * *5 +++++
> *etc/makepkg.conf.in * *| * *3 +++
> *scripts/makepkg.sh.in *| * 18 ++++++++++++++++--
> *4 files changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt
> index e61f7ab..f15226a 100644
> --- a/doc/makepkg.8.txt
> +++ b/doc/makepkg.8.txt
> @@ -206,6 +206,9 @@ Environment Variables
> * * * *Folder where the downloaded sources will be stored. Overrides the
> * * * *corresponding value defined in linkman:makepkg.conf[5].
>
> +**BUILDDIR=**"/path/to/folder"::
> + * * * Folder where the package will be built. Overrides the corresponding
> + * * * value defined in linkman:makepkg.conf[5].
>
> *Configuration
> *-------------
> diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt
> index fcd2f2a..4db8b92 100644
> --- a/doc/makepkg.conf.5.txt
> +++ b/doc/makepkg.conf.5.txt
> @@ -110,6 +110,11 @@ Options
> * * * *running in the DistCC cluster. In addition, you will want to modify your
> * * * *`MAKEFLAGS`.
>
> +**BUILDDIR=**"/path/to/folder"::
> + * * * If this value is not set, packages will by default be built in the
> + * * * subdirectories of the current directory. *This option allows setting
"current directory" seems half right (looks like we use "build
directory" below?), but it appears we only get this whole bit halfway
right anyway:

dmcgee@galway ~/projects/arch-repos/libfetch
$ makepkg -f -p trunk/PKGBUILD
==> Making package: libfetch 2.33-3 (Wed Jun 15 09:26:08 CDT 2011)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving Sources...
==> ERROR: Makefile was not found in the build directory and is not a URL.

Also wondering if it is worth a word of warning here in the manpage
stating something like if the package builds without this option but
not with this option, the package build script is broken and makes
invalid assumptions?

> + * * * the build location to another folder.
> +
> ***GPGKEY=**""::
> * * * *Specify a key to use for gpg signing instead of the default key in the
> * * * *keyring. Can be overridden with makepkg's `--key` option.
> diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in
> index 42ae940..d3b7d3d 100644
> --- a/etc/makepkg.conf.in
> +++ b/etc/makepkg.conf.in
> @@ -54,6 +54,9 @@ BUILDENV=(fakeroot !distcc color !ccache check !sign)
> *#-- If using DistCC, your MAKEFLAGS will also need modification. In addition,
> *#-- specify a space-delimited list of hosts running in the DistCC cluster.
> *#DISTCC_HOSTS=""
> +#
> +#-- Specify a directory for package building.
> +#BUILDDIR=/tmp/makepkg
>
> *################################################# ########################
> *# GLOBAL PACKAGE OPTIONS
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 18df00f..ce8f008 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -41,8 +41,6 @@ myver='@PACKAGE_VERSION@'
> *confdir='@sysconfdir@'
> *BUILDSCRIPT='@BUILDSCRIPT@'
> *startdir="$PWD"
> -srcdir="$startdir/src"
> -pkgdir="$startdir/pkg"
>
> *packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx')
> *other_options=('ccache' 'distcc' 'buildflags' 'makeflags')
> @@ -1653,6 +1651,7 @@ done
> *[[ -n ${PKGDEST} ]] && _PKGDEST=$(canonicalize_path ${PKGDEST})
> *[[ -n ${SRCDEST} ]] && _SRCDEST=$(canonicalize_path ${SRCDEST})
> *[[ -n ${SRCPKGDEST} ]] && _SRCPKGDEST=$(canonicalize_path ${SRCPKGDEST})
> +[[ -n ${BUILDDIR} ]] && _BUILDDIR=$(canonicalize_path ${BUILDDIR})
> *[[ -n ${PKGEXT} ]] && _PKGEXT=${PKGEXT}
> *[[ -n ${SRCEXT} ]] && _SRCEXT=${SRCEXT}
> *[[ -n ${GPGKEY} ]] && _GPGKEY=${GPGKEY}
> @@ -1700,6 +1699,21 @@ fi
> *readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
>
> *# override settings with an environment variable for batch processing
> +BUILDDIR=${_BUILDDIR:-$BUILDDIR}
> +BUILDDIR=${BUILDDIR:-$startdir} #default to $startdir if undefined
> +if [[ ! -d $BUILDDIR ]]; then
> + * * * mkdir -p "$BUILDDIR" ||
> + * * * * * * * * * * * error "$(gettext "You do not have write permission to create packages in %s.")" "$BUILDDIR"
I suppose the bright side here is the message reuse, but could this
ever be misleading? Can mkdir fail otherwise?

> + * * * chmod a-s "$BUILDDIR"
> +fi
> +if [[ ! -w $BUILDDIR ]]; then
> + * * * error "$(gettext "You do not have write permission to create packages in %s.")" "$BUILDDIR"
> + * * * plain "$(gettext "Aborting...")"
> + * * * exit 1
> +fi
> +srcdir="$BUILDDIR/src"
> +pkgdir="$BUILDDIR/pkg"
> +
> *PKGDEST=${_PKGDEST:-$PKGDEST}
> *PKGDEST=${PKGDEST:-$startdir} #default to $startdir if undefined
> *if [[ ! -w $PKGDEST ]]; then
> --
> 1.7.5.4

Allan McRae 06-16-2011 10:12 AM

makepkg: allow specifying alternative build directory
 
On 16/06/11 00:31, Dan McGee wrote:

On Wed, Jun 15, 2011 at 4:13 AM, Allan McRae<allan@archlinux.org> wrote:

Add a BUILDDIR variable (which can be overridden in the environment)
to specify an alternative location for building the package. This is
useful for people who want to build on a different filesystem for
improved performance (e.g. tmpfs).

Signed-off-by: Allan McRae<allan@archlinux.org>
---
doc/makepkg.8.txt | 3 +++
doc/makepkg.conf.5.txt | 5 +++++
etc/makepkg.conf.in | 3 +++
scripts/makepkg.sh.in | 18 ++++++++++++++++--
4 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt
index e61f7ab..f15226a 100644
--- a/doc/makepkg.8.txt
+++ b/doc/makepkg.8.txt
@@ -206,6 +206,9 @@ Environment Variables
Folder where the downloaded sources will be stored. Overrides the
corresponding value defined in linkman:makepkg.conf[5].

+**BUILDDIR=**"/path/to/folder"::
+ Folder where the package will be built. Overrides the corresponding
+ value defined in linkman:makepkg.conf[5].

Configuration
-------------
diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt
index fcd2f2a..4db8b92 100644
--- a/doc/makepkg.conf.5.txt
+++ b/doc/makepkg.conf.5.txt
@@ -110,6 +110,11 @@ Options
running in the DistCC cluster. In addition, you will want to modify your
`MAKEFLAGS`.

+**BUILDDIR=**"/path/to/folder"::
+ If this value is not set, packages will by default be built in the
+ subdirectories of the current directory. This option allows setting

"current directory" seems half right (looks like we use "build
directory" below?), but it appears we only get this whole bit halfway
right anyway:

dmcgee@galway ~/projects/arch-repos/libfetch
$ makepkg -f -p trunk/PKGBUILD
==> Making package: libfetch 2.33-3 (Wed Jun 15 09:26:08 CDT 2011)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving Sources...
==> ERROR: Makefile was not found in the build directory and is not a URL.


That is a different issue. The -p options has always been a bit weird
with alternative builscripts outside the current path and local source
files... I have previously considered restricting this to files in the
current directory but have never been sure.



Also wondering if it is worth a word of warning here in the manpage
stating something like if the package builds without this option but
not with this option, the package build script is broken and makes
invalid assumptions?


Yes... This is the first real breakage of $startdir/pkg != $pkgdir (and
similar for $srcdir), although only in the case where this option is
used. I'm not sure how much that needs documented given we have not
equated those values in the man pages for a couple of releases now so
something like this could happen.


Although...
> for i in core extra community; do
grep -R "$startdir" /var/abs/$i | cut -f1 -d":" | sort | uniq | wc -l
done
2
48
221

So not everyone listens...

Dan McGee 06-20-2011 05:38 AM

makepkg: allow specifying alternative build directory
 
On Thu, Jun 16, 2011 at 5:12 AM, Allan McRae <allan@archlinux.org> wrote:
> On 16/06/11 00:31, Dan McGee wrote:
>>
>> On Wed, Jun 15, 2011 at 4:13 AM, Allan McRae<allan@archlinux.org> *wrote:
>>>
>>> Add a BUILDDIR variable (which can be overridden in the environment)
>>> to specify an alternative location for building the package. This is
>>> useful for people who want to build on a different filesystem for
>>> improved performance (e.g. tmpfs).
>>>
>>> Signed-off-by: Allan McRae<allan@archlinux.org>
>>> ---
>>> *doc/makepkg.8.txt * * *| * *3 +++
>>> *doc/makepkg.conf.5.txt | * *5 +++++
>>> *etc/makepkg.conf.in * *| * *3 +++
>>> *scripts/makepkg.sh.in *| * 18 ++++++++++++++++--
>>> *4 files changed, 27 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt
>>> index e61f7ab..f15226a 100644
>>> --- a/doc/makepkg.8.txt
>>> +++ b/doc/makepkg.8.txt
>>> @@ -206,6 +206,9 @@ Environment Variables
>>> * * * *Folder where the downloaded sources will be stored. Overrides the
>>> * * * *corresponding value defined in linkman:makepkg.conf[5].
>>>
>>> +**BUILDDIR=**"/path/to/folder"::
>>> + * * * Folder where the package will be built. Overrides the
>>> corresponding
>>> + * * * value defined in linkman:makepkg.conf[5].
>>>
>>> *Configuration
>>> *-------------
>>> diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt
>>> index fcd2f2a..4db8b92 100644
>>> --- a/doc/makepkg.conf.5.txt
>>> +++ b/doc/makepkg.conf.5.txt
>>> @@ -110,6 +110,11 @@ Options
>>> * * * *running in the DistCC cluster. In addition, you will want to
>>> modify your
>>> * * * *`MAKEFLAGS`.
>>>
>>> +**BUILDDIR=**"/path/to/folder"::
>>> + * * * If this value is not set, packages will by default be built in
>>> the
>>> + * * * subdirectories of the current directory. *This option allows
>>> setting
>>
>> "current directory" seems half right (looks like we use "build
>> directory" below?), but it appears we only get this whole bit halfway
>> right anyway:
>>
>> dmcgee@galway ~/projects/arch-repos/libfetch
>> $ makepkg -f -p trunk/PKGBUILD
>> ==> *Making package: libfetch 2.33-3 (Wed Jun 15 09:26:08 CDT 2011)
>> ==> *Checking runtime dependencies...
>> ==> *Checking buildtime dependencies...
>> ==> *Retrieving Sources...
>> ==> *ERROR: Makefile was not found in the build directory and is not a
>> URL.
>
> That is a different issue. *The -p options has always been a bit weird with
> alternative builscripts outside the current path and local source files...
> *I have previously considered restricting this to files in the current
> directory but have never been sure.
Yeah, sorry- I didn't mean to imply it was the same issue, only
pointing out the ambiguity of current vs. build directory.

>> Also wondering if it is worth a word of warning here in the manpage
>> stating something like if the package builds without this option but
>> not with this option, the package build script is broken and makes
>> invalid assumptions?
>
> Yes... *This is the first real breakage of $startdir/pkg != $pkgdir (and
> similar for $srcdir), although only in the case where this option is used.
> *I'm not sure how much that needs documented given we have not equated those
> values in the man pages for a couple of releases now so something like this
> could happen.
>
> Although...
>> for i in core extra community; do
> grep *-R "$startdir" /var/abs/$i | cut -f1 -d":" | sort | uniq | *wc -l
> done
> 2
> 48
> 221
>
> So not everyone listens...
Exactly what I was worried about, wow.

-Dan

Allan McRae 06-21-2011 08:31 AM

makepkg: allow specifying alternative build directory
 
On 20/06/11 15:38, Dan McGee wrote:

On Thu, Jun 16, 2011 at 5:12 AM, Allan McRae<allan@archlinux.org> wrote:

On 16/06/11 00:31, Dan McGee wrote:


On Wed, Jun 15, 2011 at 4:13 AM, Allan McRae<allan@archlinux.org> wrote:


Add a BUILDDIR variable (which can be overridden in the environment)
to specify an alternative location for building the package. This is
useful for people who want to build on a different filesystem for
improved performance (e.g. tmpfs).

Signed-off-by: Allan McRae<allan@archlinux.org>
---
doc/makepkg.8.txt | 3 +++
doc/makepkg.conf.5.txt | 5 +++++
etc/makepkg.conf.in | 3 +++
scripts/makepkg.sh.in | 18 ++++++++++++++++--
4 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt
index e61f7ab..f15226a 100644
--- a/doc/makepkg.8.txt
+++ b/doc/makepkg.8.txt
@@ -206,6 +206,9 @@ Environment Variables
Folder where the downloaded sources will be stored. Overrides the
corresponding value defined in linkman:makepkg.conf[5].

+**BUILDDIR=**"/path/to/folder"::
+ Folder where the package will be built. Overrides the
corresponding
+ value defined in linkman:makepkg.conf[5].

Configuration
-------------
diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt
index fcd2f2a..4db8b92 100644
--- a/doc/makepkg.conf.5.txt
+++ b/doc/makepkg.conf.5.txt
@@ -110,6 +110,11 @@ Options
running in the DistCC cluster. In addition, you will want to
modify your
`MAKEFLAGS`.

+**BUILDDIR=**"/path/to/folder"::
+ If this value is not set, packages will by default be built in
the
+ subdirectories of the current directory. This option allows
setting


"current directory" seems half right (looks like we use "build
directory" below?), but it appears we only get this whole bit halfway
right anyway:

dmcgee@galway ~/projects/arch-repos/libfetch
$ makepkg -f -p trunk/PKGBUILD
==> Making package: libfetch 2.33-3 (Wed Jun 15 09:26:08 CDT 2011)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving Sources...
==> ERROR: Makefile was not found in the build directory and is not a
URL.


That is a different issue. The -p options has always been a bit weird with
alternative builscripts outside the current path and local source files...
I have previously considered restricting this to files in the current
directory but have never been sure.

Yeah, sorry- I didn't mean to imply it was the same issue, only
pointing out the ambiguity of current vs. build directory.


Also wondering if it is worth a word of warning here in the manpage
stating something like if the package builds without this option but
not with this option, the package build script is broken and makes
invalid assumptions?


Yes... This is the first real breakage of $startdir/pkg != $pkgdir (and
similar for $srcdir), although only in the case where this option is used.
I'm not sure how much that needs documented given we have not equated those
values in the man pages for a couple of releases now so something like this
could happen.

Although...

for i in core extra community; do

grep -R "$startdir" /var/abs/$i | cut -f1 -d":" | sort | uniq | wc -l
done
2
48
221

So not everyone listens...

Exactly what I was worried about, wow.




Improved wording:

**BUILDDIR=**"/path/to/folder"::
If this value is not set, packages will by default be built in
subdirectories of the directory that makepkg is called from. This
option allows setting the build location to another folder.
Incorrect use of `$startdir` in a PKGBUILD may cause building with
this option to fail.

Allan

Dan McGee 06-21-2011 04:31 PM

makepkg: allow specifying alternative build directory
 
On Tue, Jun 21, 2011 at 3:31 AM, Allan McRae <allan@archlinux.org> wrote:
> On 20/06/11 15:38, Dan McGee wrote:
>>
>> On Thu, Jun 16, 2011 at 5:12 AM, Allan McRae<allan@archlinux.org> *wrote:
>>>
>>> On 16/06/11 00:31, Dan McGee wrote:
>>>>
>>>> On Wed, Jun 15, 2011 at 4:13 AM, Allan McRae<allan@archlinux.org>
>>>> *wrote:
>>>>>
>>>>> Add a BUILDDIR variable (which can be overridden in the environment)
>>>>> to specify an alternative location for building the package. This is
>>>>> useful for people who want to build on a different filesystem for
>>>>> improved performance (e.g. tmpfs).
>>>>>
>>>>> Signed-off-by: Allan McRae<allan@archlinux.org>
>>>>> ---
>>>>> *doc/makepkg.8.txt * * *| * *3 +++
>>>>> *doc/makepkg.conf.5.txt | * *5 +++++
>>>>> *etc/makepkg.conf.in * *| * *3 +++
>>>>> *scripts/makepkg.sh.in *| * 18 ++++++++++++++++--
>>>>> *4 files changed, 27 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt
>>>>> index e61f7ab..f15226a 100644
>>>>> --- a/doc/makepkg.8.txt
>>>>> +++ b/doc/makepkg.8.txt
>>>>> @@ -206,6 +206,9 @@ Environment Variables
>>>>> * * * *Folder where the downloaded sources will be stored. Overrides
>>>>> the
>>>>> * * * *corresponding value defined in linkman:makepkg.conf[5].
>>>>>
>>>>> +**BUILDDIR=**"/path/to/folder"::
>>>>> + * * * Folder where the package will be built. Overrides the
>>>>> corresponding
>>>>> + * * * value defined in linkman:makepkg.conf[5].
>>>>>
>>>>> *Configuration
>>>>> *-------------
>>>>> diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt
>>>>> index fcd2f2a..4db8b92 100644
>>>>> --- a/doc/makepkg.conf.5.txt
>>>>> +++ b/doc/makepkg.conf.5.txt
>>>>> @@ -110,6 +110,11 @@ Options
>>>>> * * * *running in the DistCC cluster. In addition, you will want to
>>>>> modify your
>>>>> * * * *`MAKEFLAGS`.
>>>>>
>>>>> +**BUILDDIR=**"/path/to/folder"::
>>>>> + * * * If this value is not set, packages will by default be built in
>>>>> the
>>>>> + * * * subdirectories of the current directory. *This option allows
>>>>> setting
>>>>
>>>> "current directory" seems half right (looks like we use "build
>>>> directory" below?), but it appears we only get this whole bit halfway
>>>> right anyway:
>>>>
>>>> dmcgee@galway ~/projects/arch-repos/libfetch
>>>> $ makepkg -f -p trunk/PKGBUILD
>>>> ==> * *Making package: libfetch 2.33-3 (Wed Jun 15 09:26:08 CDT 2011)
>>>> ==> * *Checking runtime dependencies...
>>>> ==> * *Checking buildtime dependencies...
>>>> ==> * *Retrieving Sources...
>>>> ==> * *ERROR: Makefile was not found in the build directory and is not a
>>>> URL.
>>>
>>> That is a different issue. *The -p options has always been a bit weird
>>> with
>>> alternative builscripts outside the current path and local source
>>> files...
>>> *I have previously considered restricting this to files in the current
>>> directory but have never been sure.
>>
>> Yeah, sorry- I didn't mean to imply it was the same issue, only
>> pointing out the ambiguity of current vs. build directory.
>>
>>>> Also wondering if it is worth a word of warning here in the manpage
>>>> stating something like if the package builds without this option but
>>>> not with this option, the package build script is broken and makes
>>>> invalid assumptions?
>>>
>>> Yes... *This is the first real breakage of $startdir/pkg != $pkgdir (and
>>> similar for $srcdir), although only in the case where this option is
>>> used.
>>> *I'm not sure how much that needs documented given we have not equated
>>> those
>>> values in the man pages for a couple of releases now so something like
>>> this
>>> could happen.
>>>
>>> Although...
>>>>
>>>> for i in core extra community; do
>>>
>>> grep *-R "$startdir" /var/abs/$i | cut -f1 -d":" | sort | uniq | *wc
>>> -l
>>> done
>>> 2
>>> 48
>>> 221
>>>
>>> So not everyone listens...
>>
>> Exactly what I was worried about, wow.
>>
>
>
> Improved wording:
>
> **BUILDDIR=**"/path/to/folder"::
> * * * *If this value is not set, packages will by default be built in
> * * * *subdirectories of the directory that makepkg is called from. *This
> * * * *option allows setting the build location to another folder.
> * * * *Incorrect use of `$startdir` in a PKGBUILD may cause building with
> * * * *this option to fail.

+1 from me.

-Dan


All times are GMT. The time now is 05:02 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.