简体   繁体   English

使用例如构建源代码后的清理策略。 混帐

[英]Cleanup Strategies after Building Source Code using eg. Git

I (mostly) use git to download and compile various projects from their source code, keeping my source in /usr/local/src and installing the binaries in /usr/local/bin . 我(大多数情况下)使用git从源代码下载和编译各种项目,将我的源代码保存在/usr/local/src并在/usr/local/bin安装二进制文件。

Following the building procedure, usually with ./configure && make && make install , I'm left with a lot of cruft that ends up as 'new' files in my local git repository. 在构建过程之后,通常使用./configure && make && make install ,我留下了很多内容,最终在我的本地git存储库中作为“新”文件。

To my understanding, make clean , make distclean and possibly also (?) ./configure clean are thinkable procedures in order to trash most leftover files. 根据我的理解, make cleanmake distclean以及可能的(?) ./configure clean是可以想到的程序,以便丢弃大多数剩余的文件。 But in specific scenarios (see example below) I'm left clueless what thing to do in order to "stay clean", such as I was prior to the installation... 但是在特定的情况下(见下面的例子)我不知道为了“保持干净”要做什么,比如我在安装之前......

A recent example – installing jscoverage (via git svn ) from http://svn.siliconforks.com/jscoverage/trunk jscoverage: 最近的一个例子 - 从http://svn.siliconforks.com/jscoverage/trunk jscoverage安装jscoverage(通过git svn ):

The building instructions for this project prompted me to use ./bootstrap.sh && make && make install . 该项目的构建说明促使我使用./bootstrap.sh && make && make install In this case, after compiling and installing was finished, I tried all of the aforementioned cleanup commands (by random), but didn't manage to get rid of everything. 在这种情况下,在编译和安装完成后,我尝试了所有上述清理命令(随机),但没有设法摆脱一切。

To wrap my question up: Is there any all-mighty, superior cleaning strategy that I haven't grasped? 提出我的问题:我还没有掌握任何强大,优越的清洁策略吗? How do you approach this cleanup issue when using a VCS such as git, in a typical workflow where you 1.) download – 2.) build – 3.) pull updates from upstream repository – 4.) build once again – and so forth? 如何在典型的工作流程中使用VCS(例如git)时如何处理此清理问题,其中1.)下载 - 2.)构建 - 3.)从上游存储库中提取更新 - 4.)再次构建 - 依此类推?

For an autotooled project (ie, most of the ones that use ./configure && make && make install ), make distclean will get you to the state of a pristine distribution tarball. 对于自动化项目(即大多数使用./configure && make && make install )的项目, make distclean将使您进入原始分发tarball的状态。 They won't remove everything autogenerated because that would introduce dependencies on additional tools for the end user. 它们不会删除所有自动生成的内容,因为这会为最终用户引入附加工具的依赖性。

Many packages will provide a make maintainer-clean that removes as much as possible, but will still keep around enough to build the project (if you have the correct developer tools). 许多软件包将提供尽可能删除的make maintainer-clean ,但仍然可以保留足够的内容来构建项目(如果你有正确的开发人员工具)。 This still won't remove files like Makefile.in , which is needed to make Makefile . 这仍然不会删除Makefile.in所需的Makefile The idea here is that ./configure && make should still be enough to build everything (provided all of the dependencies are installed). 这里的想法是./configure && make应该足以构建所有东西(假设安装了所有依赖项)。

That said, I think you're potentially asking the wrong question here. 那就是说,我认为你可能会在这里提出错误的问题。 If I'm not going to keep the source around for anything, I'd just delete the source directory after installing. 如果我不打算保留源代码,我只需在安装后删除源目录。 If I'm planning on pulling updates and rebuilding, I'd not even bother with a make clean : the whole point of tools like make is that they rebuild only the changed parts of a project and obsessive cleaning defeats that. 如果我打算提取更新和重建,我甚至不打算使用make clean :像make这样的工具的全部意义在于它们只重建了项目中已更改的部分,并且强调清理失败了。

When I develop my own projects, I mark any autogenerated file as ignored by the VCS, so it doesn't show up all the time. 当我开发自己的项目时,我将任何自动生成的文件标记为VCS忽略,因此它不会一直显示。 SVN has the svn:ignore property, mercurial has the .hgignore file and git has the .gitignore file, for example. 例如,SVN具有svn:ignore属性,mercurial具有.hgignore文件,git具有.gitignore文件。

There is also git clean ("Remove untracked files from the working tree"). 还有git clean (“从工作树中删除未跟踪的文件”)。 It's a simple command with relatively few command line options. 这是一个命令行选项相对较少的简单命令。 See the git-clean man page . 请参阅git-clean手册页

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM