使用automake安装具有大量文件的数据目录树 [英] Install data directory tree with massive number of files using automake

查看:89
本文介绍了使用automake安装具有大量文件的数据目录树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据目录,我希望automake为其生成安装和卸载目标.本质上,我只想将此目录原样复制到DATA目录,通常,我可能会单独列出所有文件,例如

I have a data directory which I would like automake to generate install and uninstall targets for. Essentially, I just want to copy this directory verbatim to the DATA directory, Normally, I might list all the files individually, like

dist_whatever_DATA=dir/subdir/filea ...

但是当我的目录结构看起来像这样

But the problem arises when my directory structure looks like this

*root
 *subdir
  *~10 files
 *subdir
  *~10 files
 *subdir
  *~700 files
 *subdir
 ...
 ~20 subdirs

我只是不能列出我的Makefile.am中包含的所有1000多个文件.那太荒谬了.

I just cannot list all 1000+ files included as part of my Makefile.am. That would be ridiculous.

我还需要保留目录结构.我应该注意,这些数据完全不是在构建过程中生成的,实际上是很短的录音.因此,这并不是像我希望自动制作检查"要安装的每个文件实际上已经创建,因为它们是否存在以及是否存在任何文件,我都知道我希望安装该文件,以及执行任何操作文件不是,不应安装.我知道这是在其他地方不执行通配符安装的理由,但是所有可能的原因在这里都不适用.

I need to preserve the directory structure as well. I should note that this data is not generated at all by the build process, and is actually largely short audio recordings. So it's not like I would want automake to "check" that every file I want to install has actually been created, as they're either there or not, and whatever file is there, I know I want it to be installed, and whatever file is not, should not be installed. I know that this is the justification used in other places to not do wildcard instsalls, but all the possible reasons don't apply here.

推荐答案

我发现单独安装数百个文件会导致对make install的长时间调用.我有一个类似的案例,我想安装数百个文件,保留目录结构,并且我不想每次将文件添加到集合中或从集合中删除文件时都更改我的Makefile.am.

I've found that installing hundreds of files separately makes for a tormentingly long invocation of make install. I had a similar case where I wanted to install hundreds of files, preserving the directory structure, and I did not want to change my Makefile.am every time a file was added to or removed from the collection.

我在分发中包含了文件的LZMA存档,并制定了如下自动制作规则:

I included a LZMA archive of the files in my distribution, and made automake rules like so:

GIANTARCHIVE = My_big_archive.tar.lz

dist_pkgdata_DATA = $(GIANTARCHIVE)

install-data-hook:
    cd $(DESTDIR)$(pkgdatadir); \
    cat $(GIANTARCHIVE) | unlzma | $(TAR) --list > uninstall_manifest.txt; \
    cat $(GIANTARCHIVE) | unlzma | $(TAR) --no-same-owner --extract; \
    rm --force $(GIANTARCHIVE); \
    cat uninstall_manifest.txt | sed --expression='s/^\|$$/"/g' | xargs chmod a=rX,u+w

uninstall-local:
    cd $(DESTDIR)$(pkgdatadir); \
    cat uninstall_manifest.txt | sed --expression='s/ /\\ /g' | xargs rm --force; \
    rm --force uninstall_manifest.txt

通过这种方式,automake将My_big_archive.tar.lz安装在$(pkgdata)目录中,并将其解压缩到其中,并列出其中的所有文件,以便以后可以卸载它们.即使您要自动生成该列表,它的运行也比将每个文件都列为安装目标要快得多.

This way, automake installs My_big_archive.tar.lz in the $(pkgdata) directory, and extracts it there, making a list of all the files that were in it, so it can uninstall them later. This also runs much faster than listing each file as an install target, even if you were to autogenerate that list.

这篇关于使用automake安装具有大量文件的数据目录树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆