在运行

./configure --prefix=/mingw 

在我之前运行的一个库的MinGW/MSYS系统上

'./configure --prefix=/mingw && make && make install' 

我看到了这条信息:

警告:Vamp插件SDK的一个版本已经安装。如果您安装了新版本而没有先删除旧版本,那么您将会感到担忧和痛苦。(继续)

这让我很担心。“make install”的反义词是什么,即如何在Linux中卸载库?“清洁”能起作用吗,或者还有其他步骤吗?


当前回答

不幸的是,没有标准,这是从源代码安装的危险之一。一些makefile文件将包含“卸载”,因此

make uninstall

从源目录可以工作。否则,可能需要手动撤销make install所做的一切。

Make clean通常只是清理源目录-删除生成/编译的文件之类的,可能不是你想要的。

其他回答

Make可以告诉你它知道什么,它会做什么。 假设你有一个“install”目标,它执行如下命令:

cp <filelist> <destdir>/

在你的通用规则中,添加:

uninstall :; MAKEFLAGS= ${MAKE} -j1 -spinf $(word 1,${MAKEFILE_LIST}) install \
              | awk '/^cp /{dest=$NF; for (i=NF; --i>0;) {print dest"/"$i}}' \
              | xargs rm -f

一个类似的技巧可以做一个通用的使干净。

我知道很少有包支持“make uninstall”,但更多的包支持“make install DESTDIR=xxx”进行分期安装。

您可以使用它来创建一个包来安装,而不是直接从源代码安装。我没有运气与checkinstall,但fpm工作得很好。

这还可以帮助您删除之前使用make install安装的包。您只需强制在make installed的包上安装您构建的包,然后卸载它。

例如,我最近使用它来处理protobuf-3.3.0。 RHEL7:

make install DESTDIR=dest
cd dest
fpm -f -s dir -t rpm -n protobuf -v 3.3.0 \
 --vendor "You Not RedHat" \
 --license "Google?" \
 --description "protocol buffers" \
 --rpm-dist el7 \
 -m you@youraddress.com \
 --url "http:/somewhere/where/you/get/the/package/oritssource" \
 --rpm-autoreqprov \
 usr

 sudo rpm -i -f protobuf-3.3.0-1.el7.x86_64.rpm
 sudo rpm -e protobuf-3.3.0      

如果可以的话,你更喜欢yum而不是rpm。

Debian9:

make install DESTDIR=dest
cd dest
fpm -f -s dir -t deb -n protobuf -v 3.3.0 \
-C `pwd` \
--prefix / \
--vendor "You Not Debian" \
--license "$(grep Copyright ../../LICENSE)" \
--description "$(cat README.adoc)" \
--deb-upstream-changelog ../../CHANGES.txt \
 --url "http:/somewhere/where/you/get/the/package/oritssource" \
 usr/local/bin \
 usr/local/lib \
 usr/local/include

 sudo apt install -f *.deb
 sudo apt-get remove protobuf

在你能做到的地方,你更喜欢倾向于dpkg。

我也把答案贴在这里了

根据makefile/configure脚本/autofoo魔法的问题,下面可能会解决你的问题:

make uninstall

问题是,您应该在已安装版本的源树上执行此操作,并使用与安装时完全相同的配置。

如何在“make install”后卸载

方法#1(制作卸载)

第1步:如果您以任何方式删除/更改了构建目录,则只需要遵循此步骤:下载和制作/制作安装,使用与前面完全相同的过程。

步骤2:尝试使卸载。

cd $SOURCE_DIR 
sudo make uninstall

如果成功,您就完成了。如果你是偏执狂,你也可以尝试“方法#3”的步骤,以确保使卸载没有遗漏任何文件。

方法2 (checkinstall—仅适用于基于debian的系统)

流程概述

在基于debian的系统中(例如Ubuntu),你可以通过使用名为checkinstall的工具很容易地创建.deb包。然后安装.deb包(这将使debian系统意识到包的所有部分确实已经安装),最后卸载它,让包管理器正确地清理系统。

一步一步

sudo apt-get -y install checkinstall
cd $SOURCE_DIR 
sudo checkinstall

此时checkinstall将提示输入包名。输入一些描述性的内容并记录下来,因为您马上就会用到它。它还会提示输入一些您可以忽略的数据。如果它抱怨版本不能被接受,那就输入一个合理的版本,比如1.0。当它完成时,你可以安装和卸载:

sudo dpkg -i $PACKAGE_NAME_YOU_ENTERED 
sudo dpkg -r $PACKAGE_NAME_YOU_ENTERED

方法#3 (install_manifest.txt)

如果源目录中存在一个文件install_manifest.txt,它应该包含安装创建的每个文件的文件名。

所以首先检查文件列表和它们的mod-time:

cd $SOURCE_DIR 
sudo xargs -I{} stat -c "%z %n" "{}" < install_manifest.txt

您应该得到零错误,所列文件的mod-times应该在安装时间或安装时间之后。如果一切正常,你可以一次性删除它们:

cd $SOURCE_DIR 
mkdir deleted-by-uninstall
sudo xargs -I{} mv -t deleted-by-uninstall "{}" < install_manifest.txt

然而,用户Merlyn Morgan-Graham对于这种方法有一个你应该记住的严肃注意事项(在这里逐字复制):“小心那些可能也被其他包安装的文件。只需删除这些文件[…]可能会破坏其他的包裹。”这就是为什么我们创建了delete -by-uninstall目录,并将文件移动到那里,而不是删除它们。


这篇文章99%的内容都存在于其他答案中。我只是将所有有用的东西收集在一个(希望)易于遵循的操作指南中,并试图对重要的细节给予额外的关注(比如引用xarg参数和备份已删除的文件)。

序言

下面可能会工作,也可能不会,这都是按原样给出的,你,只有你是负责任的人,以防一些损坏,数据丢失等。但我希望一切顺利!

要撤消make install,我将这样做(我确实这样做了):

想法:检查任何脚本安装和撤销这与简单的bash脚本。

Reconfigure your build dir to install to some custom dir. I usually do this: --prefix=$PWD/install. For CMake, you can go to your build dir, open CMakeCache.txt, and fix CMAKE_INSTALL_PREFIX value. Install project to custom directory (just run make install again). Now we push from assumption, that make install script installs into custom dir just same contents you want to remove from somewhere else (usually /usr/local). So, we need a script. 3.1. Script should compare custom dir, with dir you want clean. I use this:

anti-install.sh

RM_DIR=$1
PRESENT_DIR=$2

echo "Remove files from $RM_DIR, which are present in $PRESENT_DIR"

pushd $RM_DIR

for fn in `find . -iname '*'`; do
#  echo "Checking $PRESENT_DIR/$fn..."
  if test -f "$PRESENT_DIR/$fn"; then
    # First try this, and check whether things go plain
    echo "rm $RM_DIR/$fn"

    # Then uncomment this, (but, check twice it works good to you).
    # rm $RM_DIR/$fn
  fi
done

popd

3.2. 现在只需运行这个脚本(它将进行试运行)

bash anti-install.sh <dir you want to clean> <custom installation dir>

例如,你不想清理/usr/local,而你的自定义安装目录是/user/me/llvm。构建/安装,然后就是

bash anti-install.sh /usr/local /user/me/llvm.build/install

3.3. 仔细检查日志,如果命令对你来说是好的,取消注释rm $RM_DIR/$fn并重新运行它。但是停止!你真的仔细检查过吗?可以再检查一下吗?

指令来源: https://dyatkovskiy.com/2019/11/26/anti-make-install/

好运!