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

查看:37
本文介绍了使用 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.

我也需要保留目录结构.我应该注意到,这些数据根本不是由构建过程生成的,实际上是很短的录音.所以我不想让 automake检查"我想安装的每个文件是否已经实际创建,因为它们要么在那里,要么在那里,无论文件在那里,我知道我想要它被安装,无论文件不是,不应该安装.我知道这是其他地方使用的不进行通配符安装的理由,但所有可能的原因都不适用于此处.

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 存档,并制定了这样的 automake 规则:

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天全站免登陆