Gentoo Wiki




While deltup has saved many dialup users hours of downloading packages, it sadly lacks the ability to resume interrupted downloads automatically. With some foresight however, this is possible. While these methods would normally be too cumbersome to use, when donwloading a 30MB .dtu file on dialup and having to cancel it when 29MB is already downloaded, it's worth it. At the very latest, you must apply the second method before canceling a download, or kill the process with SIGQUIT (Ctrl-\) or SIGKILL.

First method

With this method, you can cancel any download at will and continue it afterwards, but for abandoned partial getdelta downloads, the temporary .dtu file and its directory will remain in /usr/portage/distfiles until you manually delete it.

Things to backup before beginning

Modifying /usr/bin/

Do this before the next time you emerge a package with deltup. Open /usr/bin/ in a text editor, search for the following line or a similar one to it (searching for the word "trap" should find it quickly), and comment it out by adding a # at the very beginning of it:

File: /usr/bin/
trap "rm -r ${tmp_dwn_dest}; trap 2; kill -2 $$" 2

How it works

That line traps signal 2 (SIGINT) being sent to (usually by the user pressing Ctrl-C with emerge) to make it delete the partial .dtu file on user interrupt. This change will prevent that partial .dtu file from being deleted.

After canceling a partial deltup download

Locate partially downloaded .dtu file

Find the partial .dtu file in a getdelta temp directory in /usr/portage/distfiles. Getdelta's temp directories are named in the form .getdelta-NNNNNNNNN-tmp, where each N is a digit. Either leave it where it is (remember the exact dir, hereafter referred to as the old temp dir) or move it to a safe place.

Locate, delete, and copy over the new .dtu file

Start the .dtu download again from scratch (by emerging the same package you canceled). Once wget starts downloading the new .dtu, find that .dtu (also in a getdelta temp dir within /usr/portage/distfiles, hereafter referred to as the new temp dir). To automate finding it, execute in a shell as root: lsof -nP | grep wget | grep getdelta. Once found, delete it (wget will still be writing to its inode until wget closes the file, which is when it will actually get deleted). Copy (to be safe) or move (if you think or know it will work) the old temp dir's .dtu file to the new temp dir (as the same filename).

Find wget's port number

Find which TCP port wget is using on your computer to connect to the deltup server by executing as root: netstat -ntp|grep wget. The output should look similar this:

Code: netstat output
tcp     1448      0          ESTABLISHED 26404/wget

The port number (48367), which is vital to the next step, is after the colon after (placeholder for your computer's IP address) in this example. Of course, your IP address and port number will differ from this.

Add firewall rule

In the following command, replace "1234" with the port number you discovered previously: iptables -I INPUT 1 -p tcp --dport 1234 -j DROP. This will cause wget to timeout on read and to retry the download. Once wget retries, remove the firewall rule with iptables -D INPUT 1. At this point wget should be resuming the download where it left off when was canceled initially.

Note: If wget does not retry, but instead exits, causing emerge to start another instance of, then add "--tries=5" as a parameter to wget in the FETCH variable line in /etc/deltup/getdelta.rc. Also, if the wait for the read timeout is too long, add "--read-timeout=30" to that line.

Second Method

This method requires preemptive action on your part every time you want to cancel a download, but doesn't require modifying /usr/bin/, hence can be done if you want to cancel a .dtu you're currently downloading.

What to do

This is almost exactly like the first method. Backup your firewall rules, but there's no need to backup /usr/bin/ since you won't be modifying it. Before canceling the download, you must copy the .dtu file (which is currently being written to by wget, located in /usr/portage/distfiles/.getdelta-NNNNNNNNN-tmp, where each N is a digit) to a safe location. After that is done, cancel the emerge fetch and follow the directions for the first method from the subsection Locate, delete, and copy over the new .dtu file.

See also

Retrieved from ""

Last modified: Wed, 01 Oct 2008 19:29:00 +0000 Hits: 3,582