Proper syntax for recursive copying during destroot

Mojca Miklavec mojca at macports.org
Mon Jan 30 14:39:12 UTC 2017


Hi,

What's the proper syntax to copy from a bunch of files recursively
during installation?
I like "xinstall" because it's safe to call "port destroot" twice. If
I use "move", this is probably not the case.

I have something like the following structure (three folders, two of
them contain plain files, the third one contains arbitrary folders and
arbitrary files inside those folders). I would like to copy these to
destroot.

foo/A/fileA_1
     /...
     /fileA_N
foo/B/fileB_1
     /...
     /fileB_N
foo/C/dirC_1/fileC1_1
            /...
            /fileC1_N
     /dirC_2/fileC2_1
            /...
            /fileC1_N
     /...
     /dirC_N/fileCN_1
            /...
            /fileCN_N

The following code worked as long as C contained just files, but
stopped working when subfolders were introduced:

    set foo_share ${prefix}/share/foo
    set src       ${workpath}/.home/foo

    foreach d {A B C} {
        xinstall -d -m 0755 ${destroot}/${foo_share}/${d}
        foreach f [glob -type f ${src}/${d}/*] {
            xinstall -W ${src}/${d} ${f} ${destroot}/${foo_share}/${d}
        }
    }

I was playing a bit with various options and ended up with two nested
glob-s plus some super ugly code to remove the prefix etc. The code
doesn't quite work yet, but it's already so super ugly that I bet
there must be a better solution. (I can probably always fall back to
using "move".)

Any suggestions?

Thank you,
    Mojca

(PS: It's not really relevant, but the port in question is "panda" & #53397.)


More information about the macports-dev mailing list