Cleanup Strategies after Building Source Code using eg. Git

怎甘沉沦 提交于 2020-02-24 17:32:06

问题


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.

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.

To my understanding, make clean, make distclean and possibly also (?) ./configure clean are thinkable procedures in order to trash most leftover files. 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:

The building instructions for this project prompted me to use ./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?


回答1:


There is also git clean ("Remove untracked files from the working tree"). It's a simple command with relatively few command line options. See the git-clean man page.




回答2:


For an autotooled project (i.e., most of the ones that use ./configure && make && make install), make distclean will get you to the state of a pristine distribution 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). This still won't remove files like Makefile.in, which is needed to make Makefile. The idea here is that ./configure && make should still be enough to build everything (provided all of the dependencies are installed).

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.

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. SVN has the svn:ignore property, mercurial has the .hgignore file and git has the .gitignore file, for example.



来源:https://stackoverflow.com/questions/3830833/cleanup-strategies-after-building-source-code-using-eg-git

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!