Bug 100996 - bsd.port.mk: add macro to copy with right permissions directory trees
Summary: bsd.port.mk: add macro to copy with right permissions directory trees
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Port Management Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-28 19:40 UTC by Stanislav Sedov
Modified: 2007-03-24 15:44 UTC (History)
1 user (show)

See Also:


Attachments
portmk.diff (973 bytes, patch)
2006-07-28 19:40 UTC, Stanislav Sedov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stanislav Sedov 2006-07-28 19:40:14 UTC
        We have a lot of ports (thousands, actually), that need
        to copy entire directory trees to specific location,
        e.g. when installing examples for port one could issue:

        @${TAR} -cf - -C ${WRKSRC} copyfs cryptfs gzipfs uuencodefs tests | \
                       ${TAR} -xf - -C ${EXAMPLESDIR}
        @${FIND} ${EXAMPLESDIR} -type f -exec ${CHMOD} ${SHAREMODE} {} \;
        @${FIND} ${EXAMPLESDIR} -exec ${CHOWN} ${SHAREOWN} {} \;

        There are many other solutions (e.g. using PAX, FIND, CPIO combinations)
        , buth every require one important step - set up permissions for
        installed files, since this files are not processed by INSTALL_XXX
        program.

        A lot of ports usually forget to do this - I began to fix some
        of them - but it's tedios and giant work...

        The macros introduced allows to dial with such tree ierarchies
        in handy and efficient way. For previos example one can use:

        cd ${WRKSRC} && ${COPYTREE_SHARE} "copyfs cryptfs gzipfs uuencodefs test
        s" "${EXAMPLESDIR}"

        and that's all.

        I decided to use CPIO (though I don't like it)  since it can be used
        with find program, that allows to manipulate on file sets with a great
        power. Additional commands to FIND program might be passed by third
        argument to macro, e.g. to eclude 'Makefile" file we can use:
        cd ${WRKSRC} && ${COPYTREE_BIN} docs "${DOCSDIR}" "! -name Makefile"
	
        Thus, this macro allows to use the whole power of FIND program.

	Also, I've used "-l" swith in CPIO to speed-up copies in some
	cases. That's why I've redirected cpio output to /dev/null ;-)

        It would be nice to have you comments/suggestions here. Thanks!
Comment 1 Ion-Mihai "IOnut" Tetcu freebsd_committer freebsd_triage 2006-07-28 19:48:57 UTC
Responsible Changed
From-To: freebsd-ports-bugs->portmgr

Fix Synopsis and assign.
Comment 2 Stanislav Sedov 2006-07-28 20:31:46 UTC
Oh, and FIND arguments should be $$1/ for safety.

--------------------------------------------------------------------------------
--- bsd.port.mk.orig	Fri Jul 28 22:09:42 2006
+++ bsd.port.mk	Fri Jul 28 22:13:32 2006
@@ -1970,6 +1970,18 @@
 REINPLACE_ARGS?=	-i.bak
 REINPLACE_CMD?=	${SED} ${REINPLACE_ARGS}
 
+# Macro for coping entire directory tree with correct permissions
+COPYTREE_BIN=	${SH} -c '(${FIND} -d $$0 $$2 | ${CPIO} -dumpl $$1 >/dev/null \
+					2>&1) && \
+					${CHOWN} -R ${BINOWN}:${BINGRP} $$1 && \
+					${FIND} $$1/ -type d -exec chmod 755 {} \; && \
+					${FIND} $$1/ -type f -exec chmod ${BINMODE} {} \;' --
+COPYTREE_SHARE=	${SH} -c '(${FIND} -d $$0 $$2 | ${CPIO} -dumpl $$1 >/dev/null \
+					2>&1) && \
+					${CHOWN} -R ${SHAREOWN}:${SHAREGRP} $$1 && \
+					${FIND} $$1/ -type d -exec chmod 755 {} \; && \
+					${FIND} $$1/ -type f -exec chmod ${SHAREMODE} {} \;' --
+
 # Names of cookies used to skip already completed stages
 EXTRACT_COOKIE?=	${WRKDIR}/.extract_done.${PORTNAME}.${PREFIX:S/\//_/g}
 CONFIGURE_COOKIE?=	${WRKDIR}/.configure_done.${PORTNAME}.${PREFIX:S/\//_/g}
--------------------------------------------------------------------------------
Comment 3 Kris Kennaway freebsd_committer freebsd_triage 2006-11-19 21:04:05 UTC
State Changed
From-To: open->feedback

In such cases we like to also see a patch converting a representative 
sample of ports to use the new features, as a proving ground that a) 
the new feature works and b) the new feature is general enough to 
handle any permutations that may arise in the ports tree usage.
Comment 4 Stanislav Sedov freebsd_committer freebsd_triage 2007-01-02 22:53:42 UTC
You can grep the entire ports by COPYTREE_SHARE to find ports that uses
it. These examples cover almost all cases, how this macros can be used.

Try `find ports/ -name Makefile| xargs grep COPYTREE_SHARE`

--
Stanislav Sedov
Against HTML mail and Flash
PGP: http://people.FreeBSD.org/~stas/stas.key.asc
Comment 5 Pav Lucistnik freebsd_committer freebsd_triage 2007-02-05 23:16:14 UTC
State Changed
From-To: feedback->open

Feedback received, sort of. The patch file to convert all these ports will be 
required just before the experimental package run
Comment 6 Pav Lucistnik freebsd_committer freebsd_triage 2007-03-14 23:10:55 UTC
The time has come, can we please get a patch that converts a
representative sample of existing ports to this new infrastructure?
Let's say 10 to 20 ports.

-- 
Pav Lucistnik <pav@oook.cz>
              <pav@FreeBSD.org>

Oh, no! Aaargh! It is the most unnatural, most disgusting
creature imaginable: a two-eyed cyclops!
Comment 7 Pav Lucistnik freebsd_committer freebsd_triage 2007-03-17 23:48:03 UTC
State Changed
From-To: open->analyzed

This patch is being tested in exprun
Comment 8 dfilter service freebsd_committer freebsd_triage 2007-03-24 14:02:12 UTC
pav         2007-03-24 14:02:06 UTC

  FreeBSD ports repository

  Modified files:
    .                    CHANGES 
    Mk                   bsd.autotools.mk bsd.port.mk 
                         bsd.port.subdir.mk 
  Added files:
    Mk                   bsd.efl.mk 
  Log:
  [1] Introduce COPYTREE_BIN and COPYTREE_SHARE macros
  [2] Fix ECHO_CMD/ECHO_MSG usage in bsd.port.mk
  [3] Move bsd.efl.mk to ports/Mk
  [4] Change LIBTOOLFILES default to ${CONFIGURE_SCRIPT}
  [5] Whitespace sweep
  [6] Add WWWDIR variable with default value of ${PREFIX}/www/${PORTNAME}
  
  PR:             ports/100996 [1], ports/100556 [2], ports/100497 [3],
                  ports/104009 and ports/104018 [5], ports/105529 [6]
  Submitted by:   stass [1] [3], gabor [2], pav [4], edwin [5], laszlof [6]
  Approved by:    ade [4]
  
  Revision  Changes    Path
  1.67      +22 -1     ports/CHANGES
  1.26      +4 -3      ports/Mk/bsd.autotools.mk
  1.1       +307 -0    ports/Mk/bsd.efl.mk (new)
  1.557     +99 -61    ports/Mk/bsd.port.mk
  1.69      +17 -14    ports/Mk/bsd.port.subdir.mk
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 9 dfilter service freebsd_committer freebsd_triage 2007-03-24 14:03:08 UTC
pav         2007-03-24 14:03:04 UTC

  FreeBSD ports repository

  Modified files:
    archivers/ruby-bz2   Makefile 
    audio/ruby-freedb    Makefile 
    audio/ruby-mp3info   Makefile 
    audio/ruby-musicbrainz Makefile 
    cad/gspiceui         Makefile 
    databases/ruby-cdb   Makefile 
    devel/cc65           Makefile 
    devel/ocaml-cfg      Makefile 
    devel/ocaml-lacaml   Makefile 
    devel/ocaml-pcre     Makefile 
    devel/ocaml-pomap    Makefile 
    devel/ocaml-res      Makefile 
    devel/ruby-fam       Makefile 
    devel/ruby-robjectteam Makefile 
    devel/sdl12          Makefile 
    games/cube           Makefile 
    games/frozenbubble   Makefile 
    graphics/ocaml-lablgl Makefile 
    graphics/ruby-imlib2 Makefile 
    lang/Sather          Makefile 
    lang/newlisp         Makefile 
    lang/ocaml           Makefile 
    lang/ruby18          Makefile 
    math/fxt             Makefile 
    net/ocaml-netclient  Makefile 
    net/ruby-ldap        Makefile 
  Log:
  - COPYTREE_* are now part of bsd.port.mk
  
  PR:             ports/100996
  Submitted by:   stass
  
  Revision  Changes    Path
  1.18      +0 -7      ports/archivers/ruby-bz2/Makefile
  1.16      +0 -7      ports/audio/ruby-freedb/Makefile
  1.14      +0 -7      ports/audio/ruby-mp3info/Makefile
  1.11      +0 -7      ports/audio/ruby-musicbrainz/Makefile
  1.4       +0 -7      ports/cad/gspiceui/Makefile
  1.10      +0 -7      ports/databases/ruby-cdb/Makefile
  1.24      +0 -7      ports/devel/cc65/Makefile
  1.4       +0 -7      ports/devel/ocaml-cfg/Makefile
  1.6       +0 -7      ports/devel/ocaml-lacaml/Makefile
  1.27      +0 -7      ports/devel/ocaml-pcre/Makefile
  1.4       +0 -7      ports/devel/ocaml-pomap/Makefile
  1.4       +0 -7      ports/devel/ocaml-res/Makefile
  1.10      +0 -7      ports/devel/ruby-fam/Makefile
  1.6       +0 -7      ports/devel/ruby-robjectteam/Makefile
  1.105     +0 -7      ports/devel/sdl12/Makefile
  1.19      +0 -7      ports/games/cube/Makefile
  1.27      +0 -7      ports/games/frozenbubble/Makefile
  1.17      +0 -7      ports/graphics/ocaml-lablgl/Makefile
  1.15      +0 -7      ports/graphics/ruby-imlib2/Makefile
  1.40      +0 -7      ports/lang/Sather/Makefile
  1.6       +0 -7      ports/lang/newlisp/Makefile
  1.58      +0 -7      ports/lang/ocaml/Makefile
  1.125     +0 -7      ports/lang/ruby18/Makefile
  1.23      +0 -7      ports/math/fxt/Makefile
  1.4       +0 -7      ports/net/ocaml-netclient/Makefile
  1.36      +0 -7      ports/net/ruby-ldap/Makefile
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 10 Pav Lucistnik freebsd_committer freebsd_triage 2007-03-24 15:44:17 UTC
State Changed
From-To: analyzed->closed

Committed, thanks!