php - Copying inherited directories containing symlinks -
this similar questions have been asked before, promise different.
i have site involves inheritance parent child site. part of media. make media serve faster, creating symlink-ed copy of parent directory in child, override files child defines. allows apache serve statically media (which may come parent) while inheriting html form parent.
example after build inheritance common->maps->cars :
/some/directory/common/ images/ cats.png muffins.png css/ styles.css /some/directory/maps/ images/ cats.png -> /some/directory/common/images/cats.png muffins.png (overridden child) css/ styles.css -> /some/directory/common/css/styles.css mapsstyles.css (child only) /some/directory/cars/ images/ cats.png -> /some/directory/common/images/cats.png muffins.png -> /some/directory/maps/images/muffins.png css/ styles.css -> /some/directory/common/css/styles.css carsstyles.css (child only)
so symlink /images/muffins.png
, receive correct media based on site i'm on. site-specific media stored in same directory structure, in different location containing media specific site.
the issue no matter how try it, second child ends symlink parent, not originator. in example above, cannot /some/direcory/cars/images/cats.png
point common media programatically, maps media.
currently using command cp -sr /some/directory/maps/* /some/directory/cars/
i'm running on php, using cp
, ln
commands in php exec()
function build these structures.
it seems should use tar
, not cp
: please try (i can't test right now; watch out your versino of tar default symlinks. should save them symlinks, not follow them... ymmv) :
#step 1: create archive of 1 of directories_using_common_symlinks: cd /some/directory/maps/ tar cvf /somewhere/wholeshebang.tar images/ css/ #ie, tar (directories, symlinks, etc). #please add whatever missing #note: contain (specific) stuff, rid of below #step 2: create real archive of common stuff cd /some/temporary_dir/ tar xvf /somewhere/wholeshebang.tar #regurgitate content. rm /somewhere/wholeshebang.tar #we won't need 1 anymore, contains rm images/muffins.png css/mapstyles.css #delete stuff tar cvf /somewhere/just_commons.tar #recreate tar, time common stuff. #step 3: use new archive "kickstart" other directories cd /the/destination tar xvf /somewhere/just_commons.tar #regurgitte common stuff (dirs, symlinks) #then add whatever specific /the/destination
Comments
Post a Comment