我知道我该怎么做回滚 apt install <package> 并自动删除其所有依赖项,但这不是我的问题。
我的问题是脚本执行了大量的 apt install
命令(在 中找到/var/log/apt/history.log
),但我不能随意用 替换 来恢复它install
,purge
因为我担心列表中有一些我之前有的包,只是还脚本所需要的。
我如何卸载仅有的执行此命令之前我没有的包?
以下是日志中的整行内容(472 个包):
Commandline: apt-get install ant ant-optional apache2 apache2-bin apache2-data apache2-utils at autoconf automake autopoint autotools-dev binutils-aarch64-linux-gnu binutils-arm-linux-gnueabihf binutils-mingw-w64-i686 binutils-mips64el-linux-gnuabi64 binutils-mipsel-linux-gnu bzip2-doc cdbs cmake cmake-data comerr-dev cpp-5-arm-linux-gnueabihf cpp-7-arm-linux-gnueabihf cpp-arm-linux-gnueabihf curl dctrl-tools debhelper debugedit devscripts dh-autoreconf dh-strip-nondeterminism dh-translations dput elfutils fonts-lato g++-5-arm-linux-gnueabihf g++-5-multilib-arm-linux-gnueabihf g++-7-arm-linux-gnueabihf g++-7-multilib g++-arm-linux-gnueabihf g++-mingw-w64-i686 gcc-5-arm-linux-gnueabihf gcc-5-arm-linux-gnueabihf-base gcc-5-cross-base gcc-5-multilib-arm-linux-gnueabihf gcc-7-arm-linux-gnueabihf gcc-7-arm-linux-gnueabihf-base gcc-7-cross-base gcc-7-multilib gcc-8-cross-base gcc-arm-linux-gnueabihf gcc-mingw-w64-base gcc-mingw-w64-i686 gdal-data giblib1 gir1.2-appindicator3-0.1 gir1.2-gnomekeyring-1.0 gir1.2-harfbuzz-0.0 gnome-icon-theme gperf ibverbs-providers icu-devtools intltool jq krb5-multidev lib32asan4 lib32atomic1 lib32cilkrts5 lib32gcc-7-dev lib32gcc1 lib32gomp1 lib32itm1 lib32mpx2 lib32ncurses5 lib32ncurses5-dev lib32quadmath0 lib32stdc++-7-dev lib32stdc++6 lib32tinfo-dev lib32tinfo5 lib32ubsan0 lib32z1 lib32z1-dev libaec0 libapache2-mod-php7.2 libappindicator3-dev libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libarchive-cpio-perl libarmadillo8 libarpack2 libasan2-armhf-cross libasan4-armhf-cross libasm1 libasound2-dev libatk-bridge2.0-dev libatk1.0-dev libatomic1-armhf-cross libatspi2.0-dev libb-hooks-endofscope-perl libb-hooks-op-check-perl libbluetooth-dev libbrlapi-dev libbz2-dev libc6-armel-armhf-cross libc6-armel-cross libc6-armhf-cross libc6-dev:i386 libc6-dev-armel-armhf-cross libc6-dev-armel-cross libc6-dev-armhf-cross libc6-dev-i386 libc6-dev-x32 libc6-i386 libc6-x32 libcairo-script-interpreter2 libcairo2-dev libcap-dev libcharls1 libcilkrts5-armhf-cross libclass-method-modifiers-perl libclass-xsaccessor-perl libcups2-dev libcupsfilters-dev libcupsimage2-dev libcurl4-gnutls-dev libdap25 libdapclient6v5 libdata-optlist-perl libdatrie1:i386 libdbus-1-dev libdbus-glib-1-dev libdbusmenu-glib-dev libdc1394-22 libdevel-callchecker-perl libdevel-globaldestruction-perl libdistro-info-perl libdrm-dev libdynaloader-functions-perl libegl1-mesa-dev libelf-dev libelf-dev:i386 libepoxy-dev libepsilon1 libfabric1 libffi-dev libfile-chdir-perl libfile-homedir-perl libfile-stripnondeterminism-perl libfile-which-perl libfm-extra4 libfontconfig1-dev libfreetype6-dev libfreexl1 libfyba0 libgbm-dev libgcc-5-dev-armhf-cross libgcc-7-dev-armhf-cross libgcc1-armhf-cross libgdal20 libgdcm2.8 libgdk-pixbuf2.0-dev libgeos-3.6.2 libgeos-c1v5 libgeotiff2 libgetopt-long-descriptive-perl libgit-wrapper-perl libgl1-mesa-dev libgles1 libglib2.0-dev libglib2.0-dev-bin libglu1-mesa-dev libglvnd-core-dev libglvnd-dev libgnome-keyring-common libgnome-keyring-dev libgnome-keyring0 libgomp1-armhf-cross libgraphite2-3:i386 libgraphite2-dev libgssrpc4 libgtk-3-dev libharfbuzz-dev libharfbuzz-gobject0 libharfbuzz0b:i386 libhdf4-0-alt libhdf5-100 libhdf5-openmpi-100 libhwloc-plugins libhwloc5 libibverbs1 libicu-dev libicu-le-hb-dev libicu-le-hb0 libiculx60 libid3tag0 libimlib2 libimport-into-perl libio-stringy-perl libisl15 libjbig-dev libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev libjq1 libjsoncpp1 libkadm5clnt-mit11 libkadm5srv-mit11 libkdb5-9 libkmlbase1 libkmldom1 libkmlengine1 libkrb5-dev liblept5 liblist-compare-perl libltdl-dev liblzma-dev libmail-sendmail-perl libmenu-cache-bin libmenu-cache3 libminizip1 libmodule-implementation-perl libmodule-runtime-perl libmoo-perl libnamespace-clean-perl libnetcdf-c++4 libnetcdf13 libnl-route-3-200 libnspr4:i386 libnspr4-dev libnss3:i386 libnss3-dev libnumber-compare-perl libnumber-range-perl libobrender32v5 libobt2v5 libogdi3.2 libonig4 libopencv-calib3d3.2 libopencv-contrib3.2 libopencv-core3.2 libopencv-features2d3.2 libopencv-flann3.2 libopencv-highgui3.2 libopencv-imgcodecs3.2 libopencv-imgproc3.2 libopencv-ml3.2 libopencv-objdetect3.2 libopencv-photo3.2 libopencv-shape3.2 libopencv-stitching3.2 libopencv-superres3.2 libopencv-video3.2 libopencv-videoio3.2 libopencv-videostab3.2 libopencv-viz3.2 libopengl0 libopenmpi2 libpackage-stash-perl libpackage-stash-xs-perl libpam0g-dev libpango-1.0-0:i386 libpango1.0-0 libpango1.0-0:i386 libpango1.0-dev libpangocairo-1.0-0:i386 libpangoft2-1.0-0:i386 libpangox-1.0-0 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libparams-classify-perl libparams-util-perl libparams-validate-perl libpath-iterator-rule-perl libpath-tiny-perl libpci-dev libpci3:i386 libpcre16-3 libpcre3-dev libpcre32-3 libpixman-1-dev libpng-dev libpng-tools libpod-constants-perl libpq5 libproj12 libpsm-infinipath1 libpulse-dev libqhull7 librdmacm1 libregexp-pattern-license-perl librhash0 librole-tiny-perl librpm8 librpmbuild8 librpmio8 librpmsign8 libruby2.5 libsctp-dev libsctp1 libserf-1-1 libsfasan2-armhf-cross libsfatomic1-armhf-cross libsfgcc-5-dev-armhf-cross libsfgcc1-armhf-cross libsfgomp1-armhf-cross libsfstdc++-5-dev-armhf-cross libsfstdc++6-armhf-cross libsfubsan0-armhf-cross libsocket++1 libsort-key-perl libsort-versions-perl libspatialite7 libspeechd-dev libsqlite3-dev libssl-dev libssl-dev:i386 libstdc++-5-dev-armhf-cross libstdc++-7-dev-armhf-cross libstdc++6-armhf-cross libstrictures-perl libstring-copyright-perl libstring-escape-perl libsub-exporter-perl libsub-exporter-progressive-perl libsub-identify-perl libsub-install-perl libsub-quote-perl libsuperlu5 libsvn1 libsys-hostname-long-perl libsz2 libtbb2 libtesseract4 libtext-glob-perl libtext-unidecode-perl libthai0:i386 libtiff-dev libtiff5-dev libtiffxx5 libtinfo-dev:i386 libtool libubsan0-armhf-cross libudev-dev libunicode-utf8-perl liburiparser1 libuv1 libvariable-magic-perl libvtk6.3 libwayland-bin libwayland-dev libx11-xcb-dev libx32asan4 libx32atomic1 libx32cilkrts5 libx32gcc-7-dev libx32gcc1 libx32gomp1 libx32itm1 libx32quadmath0 libx32stdc++-7-dev libx32stdc++6 libx32ubsan0 libxcb-dri2-0-dev libxcb-dri3-dev libxcb-glx0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxext-dev libxfixes-dev libxft-dev libxft2:i386 libxi-dev libxinerama-dev libxkbcommon-dev libxml2-dev libxrandr-dev libxrender-dev libxshmfence-dev libxslt1-dev libxss-dev libxtst-dev libxtst6:i386 libxxf86vm-dev licensecheck linux-libc-dev:i386 linux-libc-dev-armel-cross linux-libc-dev-armhf-cross mesa-common-dev mingw-w64-common mingw-w64-i686-dev obconf obsession odbcinst odbcinst1debian2 openbox openbox-menu openmpi-bin openmpi-common php-common php7.2-cgi php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline pkg-config po-debconf proj-bin proj-data python-asn1crypto python-cffi-backend python-cherrypy3 python-cryptography python-enum34 python-idna python-ipaddress python-opencv python-openssl python-psutil python-repoze.lru python-routes python-simplejson python-webob python-yaml python3-gpg python3-magic python3-unidiff rake rpm rpm-common rpm2cpio ruby ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert ruby-test-unit ruby2.5 rubygems-integration scrot subversion tex-common texinfo uuid-dev wayland-protocols wdiff x11proto-composite-dev x11proto-damage-dev x11proto-fixes-dev x11proto-input-dev x11proto-randr-dev x11proto-record-dev x11proto-scrnsaver-dev x11proto-xext-dev x11proto-xf86vidmode-dev x11proto-xinerama-dev xcompmgr xutils-dev xvfb zlib1g-dev zlib1g-dev:i386
答案1
我最好的办法是检查 dpkg 日志以找出您安装了哪个包。
less /var/log/dpkg.log
答案2
问题是该脚本的作者似乎指定了每个依赖项……这违背了使用 apt 的目的。现在每个指定的软件包都被 apt 标记为“手动”,因此它们不符合自动删除的条件。
但你可以将这个独特的问题转化为解决方案。
查看列表。如果有任何您想保留的包,请记下它们。
将该软件包列表的 apt 标记从“manual”更改为“auto”。您可以简单地复制并粘贴该列表,只需更改前面的命令即可。
sudo apt-mark auto package1 package2 package3 ... packageN // Do NOT include any packages you want to keep.
为了安全检查,让我们确保您的桌面元包不是孤立的:
apt-mark showmanual | grep ubuntu-desktop // Should return one line that says "ubuntu-desktop" // If it returns NOTHING, then run "sudo apt-mark manual ubuntu-desktop"
从列表中删除新出现的孤立包。
sudo apt autoremove // Review the list of proposed removals carefully to ensure // that it's not removing packages you wish to keep.