Как мне отменить или откатить команду «apt-get upgrade» в Ubuntu?
Есть ли способ в Ubuntu откатить или отменить последнее обновление после обновления apt-get upgrade если вам не нравятся результаты?
11 ответов 11
Я должен был сделать это сегодня в моей системе Debian. Сначала я определил временной диапазон, когда произошло ошибочное обновление, и извлек записи журнала, в которых указаны старые и новые номера версий обновленных пакетов:
$ awk '$1=="2016-03-20" && $3=="upgrade"' /var/log/dpkg.log 2016-03-20 16:58:22 upgrade libwebkitgtk-3.0-0:amd64 2.4.9-3 2.4.10-1 2016-03-20 16:58:24 upgrade libjavascriptcoregtk-3.0-0:amd64 2.4.9-3 2.4.10-1 2016-03-20 16:58:26 upgrade traceroute:amd64 1:2.0.22-1 1:2.1.0-1 2016-03-20 16:58:33 upgrade ethtool:amd64 1:4.2-1 1:4.5-1 2016-03-20 16:58:34 upgrade libsdl1.2debian:amd64 1.2.15+dfsg1-3 1.2.15+dfsg1-4 2016-03-20 16:58:34 upgrade subversion:amd64 1.9.3-2+b1 1.9.3-3 2016-03-20 16:58:36 upgrade libsvn1:amd64 1.9.3-2+b1 1.9.3-3 2016-03-20 16:58:56 upgrade linux-image-amd64:amd64 4.3+70 4.4+71 2016-03-20 16:58:56 upgrade linux-libc-dev:amd64 4.3.5-1 4.4.6-1 2016-03-20 16:59:03 upgrade amd64-microcode:amd64 2.20141028.1 2.20160316.1
Затем я попытался найти все еще кэшированные файлы пакетов на диске (к счастью, я не запустил autoclean):
$ awk '$1=="2016-03-20" && $3=="upgrade" ' /var/log/dpkg.log | xargs -r ls -ld ls: cannot access '/var/cache/apt/archives/ethtool_1%3a4.2-1_amd64.deb': No such file or directory -rw-r--r-- 1 root root 28820 Dec 18 2014 /var/cache/apt/archives/amd64-microcode_2.20141028.1_amd64.deb -rw-r--r-- 1 root root 1978874 Dec 10 18:22 /var/cache/apt/archives/libjavascriptcoregtk-3.0-0_2.4.9-3_amd64.deb -rw-r--r-- 1 root root 185006 Mar 12 00:41 /var/cache/apt/archives/libsdl1.2debian_1.2.15+dfsg1-3_amd64.deb -rw-r--r-- 1 root root 1317644 Mar 3 11:30 /var/cache/apt/archives/libsvn1_1.9.3-2+b1_amd64.deb -rw-r--r-- 1 root root 7679400 Dec 10 18:22 /var/cache/apt/archives/libwebkitgtk-3.0-0_2.4.9-3_amd64.deb -rw-r--r-- 1 root root 6108 Dec 14 06:59 /var/cache/apt/archives/linux-image-amd64_4.3+70_amd64.deb -rw-r--r-- 1 root root 1075506 Feb 7 21:36 /var/cache/apt/archives/linux-libc-dev_4.3.5-1_amd64.deb -rw-r--r-- 1 root root 983174 Mar 3 11:30 /var/cache/apt/archives/subversion_1.9.3-2+b1_amd64.deb -rw-r--r-- 1 root root 53376 Feb 28 18:35 /var/cache/apt/archives/traceroute_1%3a2.0.22-1_amd64.deb
Похоже, у меня по какой-то причине нет более старого пакета ethtool. Тем не менее, давайте продолжим принудительную установку старых пакетов:
$ sudo dpkg -i /var/cache/apt/archives/amd64-microcode_2.20141028.1_amd64.deb /var/cache/apt/archives/libjavascriptcoregtk-3.0-0_2.4.9-3_amd64.deb /var/cache/apt/archives/libsdl1.2debian_1.2.15+dfsg1-3_amd64.deb /var/cache/apt/archives/libsvn1_1.9.3-2+b1_amd64.deb /var/cache/apt/archives/libwebkitgtk-3.0-0_2.4.9-3_amd64.deb /var/cache/apt/archives/linux-image-amd64_4.3+70_amd64.deb /var/cache/apt/archives/linux-libc-dev_4.3.5-1_amd64.deb /var/cache/apt/archives/subversion_1.9.3-2+b1_amd64.deb /var/cache/apt/archives/traceroute_1%3a2.0.22-1_amd64.deb dpkg: warning: downgrading amd64-microcode from 2.20160316.1 to 2.20141028.1 (Reading database . 139632 files and directories currently installed.) Preparing to unpack . /amd64-microcode_2.20141028.1_amd64.deb . Unpacking amd64-microcode (2.20141028.1) over (2.20160316.1) . dpkg: warning: downgrading libjavascriptcoregtk-3.0-0:amd64 from 2.4.10-1 to 2.4.9-3 Preparing to unpack . /libjavascriptcoregtk-3.0-0_2.4.9-3_amd64.deb . Unpacking libjavascriptcoregtk-3.0-0:amd64 (2.4.9-3) over (2.4.10-1) . dpkg: warning: downgrading libsdl1.2debian:amd64 from 1.2.15+dfsg1-4 to 1.2.15+dfsg1-3 Preparing to unpack . /libsdl1.2debian_1.2.15+dfsg1-3_amd64.deb . Unpacking libsdl1.2debian:amd64 (1.2.15+dfsg1-3) over (1.2.15+dfsg1-4) . dpkg: warning: downgrading libsvn1:amd64 from 1.9.3-3 to 1.9.3-2+b1 Preparing to unpack . /libsvn1_1.9.3-2+b1_amd64.deb . Unpacking libsvn1:amd64 (1.9.3-2+b1) over (1.9.3-3) . Preparing to unpack . /libwebkitgtk-3.0-0_2.4.9-3_amd64.deb . Unpacking libwebkitgtk-3.0-0:amd64 (2.4.9-3) over (2.4.9-3) . dpkg: warning: downgrading linux-image-amd64 from 4.4+71 to 4.3+70 Preparing to unpack . /linux-image-amd64_4.3+70_amd64.deb . Unpacking linux-image-amd64 (4.3+70) over (4.4+71) . dpkg: warning: downgrading linux-libc-dev:amd64 from 4.4.6-1 to 4.3.5-1 Preparing to unpack . /linux-libc-dev_4.3.5-1_amd64.deb . Unpacking linux-libc-dev:amd64 (4.3.5-1) over (4.4.6-1) . dpkg: warning: downgrading subversion from 1.9.3-3 to 1.9.3-2+b1 Preparing to unpack . /subversion_1.9.3-2+b1_amd64.deb . Unpacking subversion (1.9.3-2+b1) over (1.9.3-3) . dpkg: warning: downgrading traceroute from 1:2.1.0-1 to 1:2.0.22-1 Preparing to unpack . /traceroute_1%3a2.0.22-1_amd64.deb . Unpacking traceroute (1:2.0.22-1) over (1:2.1.0-1) . Setting up amd64-microcode (2.20141028.1) . update-initramfs: deferring update (trigger activated) amd64-microcode: microcode will be updated at next boot Setting up libjavascriptcoregtk-3.0-0:amd64 (2.4.9-3) . Setting up libsdl1.2debian:amd64 (1.2.15+dfsg1-3) . Setting up libsvn1:amd64 (1.9.3-2+b1) . dpkg: dependency problems prevent configuration of libwebkitgtk-3.0-0:amd64: libwebkitgtk-3.0-0:amd64 depends on libwebkitgtk-3.0-common (>= 2.4.9); however: Package libwebkitgtk-3.0-common is not installed. dpkg: error processing package libwebkitgtk-3.0-0:amd64 (--install): dependency problems - leaving unconfigured Setting up linux-image-amd64 (4.3+70) . Setting up linux-libc-dev:amd64 (4.3.5-1) . Setting up subversion (1.9.3-2+b1) . Setting up traceroute (1:2.0.22-1) . update-alternatives: using /usr/bin/traceroute.db to provide /usr/bin/traceroute (traceroute) in auto mode update-alternatives: using /usr/bin/lft.db to provide /usr/bin/lft (lft) in auto mode update-alternatives: using /usr/bin/traceproto.db to provide /usr/bin/traceproto (traceproto) in auto mode update-alternatives: using /usr/sbin/tcptraceroute.db to provide /usr/sbin/tcptraceroute (tcptraceroute) in auto mode Processing triggers for libc-bin (2.22-3) . Processing triggers for man-db (2.7.5-1) . Processing triggers for initramfs-tools (0.123) . update-initramfs: Generating /boot/initrd.img-4.4.0-1-amd64 Errors were encountered while processing: libwebkitgtk-3.0-0:amd64
Как говорится в сообщении об ошибке, один из моих пакетов зависел от пакета -common непосредственно перед обновлением, но обновление удалило его (и apt-get больше не может его найти). К счастью, его файл пакета все еще находится в /var /cache /apt, поэтому я могу просто добавить его в список и попробовать еще раз:
$ ls -ld /var/cache/apt/archives/libwebkitgtk-3.0-common* -rw-r--r-- 1 root root 452278 Dec 10 18:22 /var/cache/apt/archives/libwebkitgtk-3.0-common_2.4.9-3_all.deb $ sudo dpkg -i /var/cache/apt/archives/amd64-microcode_2.20141028.1_amd64.deb /var/cache/apt/archives/libjavascriptcoregtk-3.0-0_2.4.9-3_amd64.deb /var/cache/apt/archives/libsdl1.2debian_1.2.15+dfsg1-3_amd64.deb /var/cache/apt/archives/libsvn1_1.9.3-2+b1_amd64.deb /var/cache/apt/archives/libwebkitgtk-3.0-0_2.4.9-3_amd64.deb /var/cache/apt/archives/linux-image-amd64_4.3+70_amd64.deb /var/cache/apt/archives/linux-libc-dev_4.3.5-1_amd64.deb /var/cache/apt/archives/subversion_1.9.3-2+b1_amd64.deb /var/cache/apt/archives/traceroute_1%3a2.0.22-1_amd64.deb /var/cache/apt/archives/libwebkitgtk-3.0-common_2.4.9-3_all.deb (Reading database . 139632 files and directories currently installed.) Preparing to unpack . /amd64-microcode_2.20141028.1_amd64.deb . Unpacking amd64-microcode (2.20141028.1) over (2.20141028.1) . Preparing to unpack . /libjavascriptcoregtk-3.0-0_2.4.9-3_amd64.deb . Unpacking libjavascriptcoregtk-3.0-0:amd64 (2.4.9-3) over (2.4.9-3) . Preparing to unpack . /libsdl1.2debian_1.2.15+dfsg1-3_amd64.deb . Unpacking libsdl1.2debian:amd64 (1.2.15+dfsg1-3) over (1.2.15+dfsg1-3) . Preparing to unpack . /libsvn1_1.9.3-2+b1_amd64.deb . Unpacking libsvn1:amd64 (1.9.3-2+b1) over (1.9.3-2+b1) . Preparing to unpack . /libwebkitgtk-3.0-0_2.4.9-3_amd64.deb . Unpacking libwebkitgtk-3.0-0:amd64 (2.4.9-3) over (2.4.9-3) . Preparing to unpack . /linux-image-amd64_4.3+70_amd64.deb . Unpacking linux-image-amd64 (4.3+70) over (4.3+70) . Preparing to unpack . /linux-libc-dev_4.3.5-1_amd64.deb . Unpacking linux-libc-dev:amd64 (4.3.5-1) over (4.3.5-1) . Preparing to unpack . /subversion_1.9.3-2+b1_amd64.deb . Unpacking subversion (1.9.3-2+b1) over (1.9.3-2+b1) . Preparing to unpack . /traceroute_1%3a2.0.22-1_amd64.deb . Unpacking traceroute (1:2.0.22-1) over (1:2.0.22-1) . Selecting previously unselected package libwebkitgtk-3.0-common. Preparing to unpack . /libwebkitgtk-3.0-common_2.4.9-3_all.deb . Unpacking libwebkitgtk-3.0-common (2.4.9-3) . Setting up amd64-microcode (2.20141028.1) . update-initramfs: deferring update (trigger activated) amd64-microcode: microcode will be updated at next boot Setting up libjavascriptcoregtk-3.0-0:amd64 (2.4.9-3) . Setting up libsdl1.2debian:amd64 (1.2.15+dfsg1-3) . Setting up libsvn1:amd64 (1.9.3-2+b1) . Setting up linux-image-amd64 (4.3+70) . Setting up linux-libc-dev:amd64 (4.3.5-1) . Setting up subversion (1.9.3-2+b1) . Setting up traceroute (1:2.0.22-1) . update-alternatives: using /usr/bin/traceroute.db to provide /usr/bin/traceroute (traceroute) in auto mode update-alternatives: using /usr/bin/lft.db to provide /usr/bin/lft (lft) in auto mode update-alternatives: using /usr/bin/traceproto.db to provide /usr/bin/traceproto (traceproto) in auto mode update-alternatives: using /usr/sbin/tcptraceroute.db to provide /usr/sbin/tcptraceroute (tcptraceroute) in auto mode Setting up libwebkitgtk-3.0-common (2.4.9-3) . Setting up libwebkitgtk-3.0-0:amd64 (2.4.9-3) . Processing triggers for libc-bin (2.22-3) . Processing triggers for man-db (2.7.5-1) . Processing triggers for initramfs-tools (0.123) . update-initramfs: Generating /boot/initrd.img-4.4.0-1-amd64