From: Petter Reinholdtsen Date: Sun, 8 Jul 2018 10:08:44 +0000 (+0200) Subject: Generated. X-Git-Url: http://pere.pagekite.me/gitweb/homepage.git/commitdiff_plain/9779451a105ea2be678348ea7cfd4c5830059d6f?hp=7c48aac064362b31fc0b093cf13a7841845a13af Generated. --- diff --git a/blog/Debian_APT_upgrade_without_enough_free_space_on_the_disk___.html b/blog/Debian_APT_upgrade_without_enough_free_space_on_the_disk___.html new file mode 100644 index 0000000000..402f508c37 --- /dev/null +++ b/blog/Debian_APT_upgrade_without_enough_free_space_on_the_disk___.html @@ -0,0 +1,527 @@ + + + + + Petter Reinholdtsen: Debian APT upgrade without enough free space on the disk... + + + + + + +
+

+ Petter Reinholdtsen + +

+ +
+ + +
+
Debian APT upgrade without enough free space on the disk...
+
8th July 2018
+

Quite regularly, I let my Debian Sid/Unstable chroot stay untouch +for a while, and when I need to update it there is not enough free +space on the disk for apt to do a normal 'apt upgrade'. I normally +would resolve the issue by doing 'apt install <somepackages>' to +upgrade only some of the packages in one batch, until the amount of +packages to download fall below the amount of free space available. +Today, I had about 500 packages to upgrade, and after a while I got +tired of trying to install chunks of packages manually. I concluded +that I did not have the spare hours required to complete the task, and +decided to see if I could automate it. I came up with this small +script which I call 'apt-in-chunks':

+ +

+#!/bin/sh
+#
+# Upgrade packages when the disk is too full to upgrade every
+# upgradable package in one lump.  Fetching packages to upgrade using
+# apt, and then installing using dpkg, to avoid changing the package
+# flag for manual/automatic.
+
+set -e
+
+ignore() {
+    if [ "$1" ]; then
+	grep -v "$1"
+    else
+	cat
+    fi
+}
+
+for p in $(apt list --upgradable | ignore "$@" |cut -d/ -f1 | grep -v '^Listing...'); do
+    echo "Upgrading $p"
+    apt clean
+    apt install --download-only -y $p
+    for f in /var/cache/apt/archives/*.deb; do
+	if [ -e "$f" ]; then
+	    dpkg -i /var/cache/apt/archives/*.deb
+	    break
+	fi
+    done
+done
+

+ +

The script will extract the list of packages to upgrade, try to +download the packages needed to upgrade one package, install the +downloaded packages using dpkg. The idea is to upgrade packages +without changing the APT mark for the package (ie the one recording of +the package was manually requested or pulled in as a dependency). To +use it, simply run it as root from the command line. If it fail, try +'apt install -f' to clean up the mess and run the script again. This +might happen if the new packages conflict with one of the old +packages. dpkg is unable to remove, while apt can do this.

+ +

It take one option, a package to ignore in the list of packages to +upgrade. The option to ignore a package is there to be able to skip +the packages that are simply too large to unpack. Today this was +'ghc', but I have run into other large packages causing similar +problems earlier (like TeX).

+ +

As usual, if you use Bitcoin and want to show your support of my +activities, please send Bitcoin donations to my address +15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b.

+
+ +
Tags: debian, english.
+ + +
+ + + + + +

+ Created by Chronicle v4.6 +

+ + + diff --git a/blog/archive/2018/07/07.rss b/blog/archive/2018/07/07.rss new file mode 100644 index 0000000000..d46bf7d70f --- /dev/null +++ b/blog/archive/2018/07/07.rss @@ -0,0 +1,80 @@ + + + + Petter Reinholdtsen - Entries from July 2018 + Entries from July 2018 + http://people.skolelinux.org/pere/blog/ + + + + Debian APT upgrade without enough free space on the disk... + http://people.skolelinux.org/pere/blog/Debian_APT_upgrade_without_enough_free_space_on_the_disk___.html + http://people.skolelinux.org/pere/blog/Debian_APT_upgrade_without_enough_free_space_on_the_disk___.html + Sun, 8 Jul 2018 12:10:00 +0200 + <p>Quite regularly, I let my Debian Sid/Unstable chroot stay untouch +for a while, and when I need to update it there is not enough free +space on the disk for apt to do a normal 'apt upgrade'. I normally +would resolve the issue by doing 'apt install &lt;somepackages&gt;' to +upgrade only some of the packages in one batch, until the amount of +packages to download fall below the amount of free space available. +Today, I had about 500 packages to upgrade, and after a while I got +tired of trying to install chunks of packages manually. I concluded +that I did not have the spare hours required to complete the task, and +decided to see if I could automate it. I came up with this small +script which I call 'apt-in-chunks':</p> + +<p><blockquote><pre> +#!/bin/sh +# +# Upgrade packages when the disk is too full to upgrade every +# upgradable package in one lump. Fetching packages to upgrade using +# apt, and then installing using dpkg, to avoid changing the package +# flag for manual/automatic. + +set -e + +ignore() { + if [ "$1" ]; then + grep -v "$1" + else + cat + fi +} + +for p in $(apt list --upgradable | ignore "$@" |cut -d/ -f1 | grep -v '^Listing...'); do + echo "Upgrading $p" + apt clean + apt install --download-only -y $p + for f in /var/cache/apt/archives/*.deb; do + if [ -e "$f" ]; then + dpkg -i /var/cache/apt/archives/*.deb + break + fi + done +done +</pre></blockquote></p> + +<p>The script will extract the list of packages to upgrade, try to +download the packages needed to upgrade one package, install the +downloaded packages using dpkg. The idea is to upgrade packages +without changing the APT mark for the package (ie the one recording of +the package was manually requested or pulled in as a dependency). To +use it, simply run it as root from the command line. If it fail, try +'apt install -f' to clean up the mess and run the script again. This +might happen if the new packages conflict with one of the old +packages. dpkg is unable to remove, while apt can do this.</p> + +<p>It take one option, a package to ignore in the list of packages to +upgrade. The option to ignore a package is there to be able to skip +the packages that are simply too large to unpack. Today this was +'ghc', but I have run into other large packages causing similar +problems earlier (like TeX).</p> + +<p>As usual, if you use Bitcoin and want to show your support of my +activities, please send Bitcoin donations to my address +<b><a href="bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b</a></b>.</p> + + + + + diff --git a/blog/archive/2018/07/index.html b/blog/archive/2018/07/index.html new file mode 100644 index 0000000000..9522c2890b --- /dev/null +++ b/blog/archive/2018/07/index.html @@ -0,0 +1,537 @@ + + + + + Petter Reinholdtsen: entries from July 2018 + + + + + + +
+

+ Petter Reinholdtsen + +

+ +
+ + +

Entries from July 2018.

+ +
+ +
+ 8th July 2018 +
+
+

Quite regularly, I let my Debian Sid/Unstable chroot stay untouch +for a while, and when I need to update it there is not enough free +space on the disk for apt to do a normal 'apt upgrade'. I normally +would resolve the issue by doing 'apt install <somepackages>' to +upgrade only some of the packages in one batch, until the amount of +packages to download fall below the amount of free space available. +Today, I had about 500 packages to upgrade, and after a while I got +tired of trying to install chunks of packages manually. I concluded +that I did not have the spare hours required to complete the task, and +decided to see if I could automate it. I came up with this small +script which I call 'apt-in-chunks':

+ +

+#!/bin/sh
+#
+# Upgrade packages when the disk is too full to upgrade every
+# upgradable package in one lump.  Fetching packages to upgrade using
+# apt, and then installing using dpkg, to avoid changing the package
+# flag for manual/automatic.
+
+set -e
+
+ignore() {
+    if [ "$1" ]; then
+	grep -v "$1"
+    else
+	cat
+    fi
+}
+
+for p in $(apt list --upgradable | ignore "$@" |cut -d/ -f1 | grep -v '^Listing...'); do
+    echo "Upgrading $p"
+    apt clean
+    apt install --download-only -y $p
+    for f in /var/cache/apt/archives/*.deb; do
+	if [ -e "$f" ]; then
+	    dpkg -i /var/cache/apt/archives/*.deb
+	    break
+	fi
+    done
+done
+

+ +

The script will extract the list of packages to upgrade, try to +download the packages needed to upgrade one package, install the +downloaded packages using dpkg. The idea is to upgrade packages +without changing the APT mark for the package (ie the one recording of +the package was manually requested or pulled in as a dependency). To +use it, simply run it as root from the command line. If it fail, try +'apt install -f' to clean up the mess and run the script again. This +might happen if the new packages conflict with one of the old +packages. dpkg is unable to remove, while apt can do this.

+ +

It take one option, a package to ignore in the list of packages to +upgrade. The option to ignore a package is there to be able to skip +the packages that are simply too large to unpack. Today this was +'ghc', but I have run into other large packages causing similar +problems earlier (like TeX).

+ +

As usual, if you use Bitcoin and want to show your support of my +activities, please send Bitcoin donations to my address +15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b.

+ +
+
+ + + Tags: debian, english. + + +
+
+
+ +

RSS Feed

+ +

+ Created by Chronicle v4.6 +

+ + +