Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 May 2012 21:29:21 +0100
From:      Chris Rees <crees@FreeBSD.org>
To:        =?ISO-8859-1?Q?Fernando_Apestegu=EDa?= <fernando.apesteguia@gmail.com>
Cc:        freebsd-ports@freebsd.org
Subject:   Re: On file installation
Message-ID:  <CADLo839TqgiNC46mxWWJ4XR_1dT6mV_SrFdjaqv-coApyyT19w@mail.gmail.com>
In-Reply-To: <CAGwOe2Y6Y0m%2B8evsLUfxaB8euPVgvrfgJ5%2B03N3Uv=cTBjqXWQ@mail.gmail.com>
References:  <CAGwOe2YwpBw_i6O6Q1qa9fn=W-qtJBiY0JkKaSQKbuJR=Q-_ew@mail.gmail.com> <CADLo83952A1O3ckX%2B9v7XOakd56S8ss9fU3zOar5h3o-JMvhSw@mail.gmail.com> <CAGwOe2ZrV=O_30N1%2BTRf7RyxqaR1F=dHeSY%2Be7n=DEGbFGWGcw@mail.gmail.com> <CAGwOe2Y2zPAdpsWesJ5ZDU4XOP1sjx9iQBVtCuFR0nzjHyWvVQ@mail.gmail.com> <CADLo83-1dys7ST0gk8Z0c5fj7QSxWAO94H%2BiBFtptx%2B5g1Z0VQ@mail.gmail.com> <CAGwOe2Yt2YjwyEE1QaNQKiUDNzmqhTNf7AY_JXkP0DNqufXLvA@mail.gmail.com> <CAGwOe2Y6Y0m%2B8evsLUfxaB8euPVgvrfgJ5%2B03N3Uv=cTBjqXWQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 17 May 2012 20:58, Fernando Apestegu=EDa <fernando.apesteguia@gmail.com>=
 wrote:
> On Tue, May 15, 2012 at 9:11 PM, Fernando Apestegu=EDa
> <fernando.apesteguia@gmail.com> wrote:
>> On Tue, May 15, 2012 at 7:29 PM, Chris Rees <crees@freebsd.org> wrote:
>>> On 15 May 2012 18:14, Fernando Apestegu=EDa <fernando.apesteguia@gmail.=
com> wrote:
>>>> On Mon, May 14, 2012 at 7:40 PM, Fernando Apestegu=EDa
>>>> <fernando.apesteguia@gmail.com> wrote:
>>>>> On Mon, May 14, 2012 at 7:31 PM, Chris Rees <crees@freebsd.org> wrote=
:
>>>>>> On 14 May 2012 18:23, Fernando Apestegu=EDa <fernando.apesteguia@gma=
il.com> wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I'm working on a port for an application written in Java and I'm
>>>>>>> having some problems deciding how to install the application.
>>>>>>> Previous to the installation, the WRKSRC directory contains some .j=
ar
>>>>>>> files and some directories along with some .txt files for
>>>>>>> licenses, but also some .exe and .bat files _which I don't want to
>>>>>>> install_. It is basically a package that contains both files for
>>>>>>> windows and non-windows systems.
>>>>>>>
>>>>>>> I was thinking on using COPYTREE_SHARE to install everything and th=
en
>>>>>>> remove the non necessary files, but doesn't look like
>>>>>>> an elegant solution. Also, I wouldn't like to explicitly specify ev=
ery
>>>>>>> one of the files I want to copy. Is there a way of using something
>>>>>>> similar to bash's extglob so I can copy !(*.exe|*bat)? If not, how =
to proceed?
>>>>>>>
>>>>>>> I already looked at the existent ports to find something similar bu=
t
>>>>>>> it seems hard to find. I also had a look at bsd.port.mk but
>>>>>>> I couldn't find what I'm looking for.
>>>>>>
>>>>>> You can use find primaries with COPYTREE_SHARE such as;
>>>>>>
>>>>>> (cd ${WRKSRC}/wherever && ${COPYTREE_SHARE} \*
>>>>>> ${JAVALIBDIR}/${PORTNAME}/wherever "-not -name \*.exe -and -not -nam=
e
>>>>>> \*.bat"
>>>>>
>>>>> Thanks! I think that is what I was looking for :)
>>>>
>>>> Sorry guys, but I think I need more help :). I tried with the followin=
g line:
>>>>
>>>> ( cd ${WRKSRC}/JDownloader && ${COPYTREE_SHARE} \*
>>>> ${PREFIX}/${PORTNAME}/ "! -name \*.exe" )
>>>>
>>>> but it doesn't seem to follow primaries and it still installs the .exe
>>>> files. I just tried with:
>>>>
>>>> ( cd ${WRKSRC}/JDownloader && ${COPYTREE_SHARE} \*
>>>> ${PREFIX}/${PORTNAME}/ "! -name JDownloader.exe" )
>>>>
>>>> and check that effectively the file is not installed so I suppose this
>>>> has something to do with quoting and escaping special characters (the
>>>> asterisk). I found the following line in audio/xmp/Makefile:
>>>>
>>>> ( cd ${WRKSRC}/docs && ${COPYTREE_SHARE} \* \
>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0${DOCSDIR} '! ( -name Makefile -or -nam=
e xmp.1 \
>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-or -name *.bak -or -name *.orig )' )
>>>>
>>>> that seems pretty close to what I'm trying to do, so I tried with this=
:
>>>>
>>>> ( cd ${WRKSRC}/JDownloader && ${COPYTREE_SHARE} \*
>>>> ${PREFIX}/${PORTNAME}/ '! ( -name *.exe )' )
>>>>
>>>> but then, the asterisk is expanded and find fails:
>>>>
>>>> find: JDownloader.exe: unknown primary or operator
>>>>
>>>> what am I doing wrong?
>>>
>>> Escape the *;
>>>
>>> (cd ${WRKSRC}/JDownloader && ${COPYTREE_SHARE} \* ${PREFIX}/${PORTNAME}=
/
>>> =A0'! ( -name \*.exe )' )
>>
>> That executes the following:
>>
>> (cd /usr/home/fernape/porting/jdownloader/port/work/JDownloader &&
>> /bin/sh -c '(/usr/bin/find -d $0 $2 | /usr/bin/cpio -dumpl $1
>>>/dev/null =A02>&1) && =A0/usr/sbin/chown -R root:wheel $1 &&
>> /usr/bin/find -d $0 $2 -type d -exec chmod 755 $1/{} \; &&
>> /usr/bin/find -d $0 $2 -type f -exec chmod 444 $1/{} \;' -- \*
>> /usr/local/jdownloader/ '! ( -name \*.exe )' )
>>
>> which results in:
>>
>> $ ls /usr/local/jdownloader
>>
>> JDUpdate.exe =A0 =A0 =A0 =A0 =A0 JDownloaderBETA.exe =A0 =A0jd/
>> license.txt =A0 =A0 =A0 =A0 =A0 =A0outdated.dat =A0 =A0 =A0 =A0 =A0 tool=
s/
>> windows_restore.bat
>> JDownloader.exe =A0 =A0 =A0 =A0JDownloaderD3D.exe =A0 =A0 jdupdate.jar
>> license_german.txt =A0 =A0 plugins/ =A0 =A0 =A0 =A0 =A0 =A0 =A0 version.=
txt
>> JDownloader.jar =A0 =A0 =A0 =A0java/ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
libs/
>> licenses/ =A0 =A0 =A0 =A0 =A0 =A0 =A0tmp/ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 windows_createlog.bat
>>
>> The .exe files are still there.
>
> Sorry or my insistence :)
>
> This is what I have in my Makefile:
>
> =A0 =A0 =A0 =A0( cd ${WRKSRC}/JDownloader && ${COPYTREE_SHARE} \* \
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0${PREFIX}/${PORTNAME} =
'! ( -name *.exe -or -name *.dll \
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0-or -name *.bat )' )
>
> what I've observed is that 'make install' fails with this message:
>
> find: JDownloader.exe: unknown primary or operator
> find: JDownloader.exe: unknown primary or operator
>
> However, if I replace the expression so I filter with something like
> *.txt and there is only
> one file in the directory, it works. I checked this with audio/xmp
>
> $cat Makefile
> ...
> .if !defined(NOPORTDOCS)
> =A0 =A0 =A0 =A0${ECHO_MSG} Installing documentation in ${DOCSDIR}
> =A0 =A0 =A0 =A0( cd ${WRKSRC}/docs && ${COPYTREE_SHARE} \* \
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0${DOCSDIR} '! ( -name Makefile -or -name x=
mp.1 \
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-or -name *.bak -or -name *.orig )' )
> .endif
>
> ...
>
> $ make
>
> $ ls work/xmp-3.5.0/docs/*.bak
> work/xmp-3.5.0/docs/xmp.1.bak
>
> Only one file (make install works fine).
>
> $ touch work/xmp-3.5.0/docs/test.bak
>
> $make install
>
> =3D=3D=3D> =A0Installing for xmp-3.5.0,1
> =3D=3D=3D> =A0 xmp-3.5.0,1 depends on file: /usr/local/bin/unzip - found
> =3D=3D=3D> =A0 Generating temporary packing list
> =3D=3D=3D> =A0Checking if audio/xmp already installed
> Installing xmp in /usr/local/bin
> Installing xmp.conf in /usr/local/etc/xmp
> Installing modules.conf in /usr/local/etc/xmp
> Installing manpages in /usr/local/man/man1
>
> =A0Installation complete. To customize, copy /usr/local/etc/xmp/xmp.conf
> =A0and /usr/local/etc/xmp/modules.conf to $HOME/.xmp/
>
> Installing documentation in /usr/local/share/doc/xmp
> find: xmp.1.bak: unknown primary or operator
> chown: /usr/local/share/doc/xmp: No such file or directory
> *** Error code 1
>
> Stop in /usr/ports/audio/xmp.
> *** Error code 1
>
> Stop in /usr/ports/audio/xmp.
>
>
> Why is this?
>
> Thanks in advances

OK, you got me curious enough to get testing.

The problem is that the -name *.bak expands to -name test.bak
xmp1.bak, which fails.  Escaping for the shell without upsetting find
also appears non-trivial, due to the multiple levels of escaping
(Make, then sh, then sh again, then find)

You should instead use -regex:

(cd ${WRKSRC}/JDownloader && ${COPYTREE_SHARE} \* \
${PREFIX}/${PORTNAME}/=A0'! ( -regex .*.exe )' )

Hideous, but it works.  (If you're unfamiliar with REs, I might point
out that you shouldn't forget the leading dot ;))

Chris



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CADLo839TqgiNC46mxWWJ4XR_1dT6mV_SrFdjaqv-coApyyT19w>