aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-04 00:35:32 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-04 00:35:32 +0000
commit226857009465e12f1c944f5cafab7eb8bd5075d1 (patch)
treef09b94d496250f328df3722cfc388dd2fd24f63e
parent8c8a26a0e7a1df047cd8a6515a98e72fe4a95a3b (diff)
downloadpaludis-226857009465e12f1c944f5cafab7eb8bd5075d1.tar.gz
paludis-226857009465e12f1c944f5cafab7eb8bd5075d1.tar.xz
Implement --safe-resume
-rw-r--r--doc/faq.html.skel28
-rwxr-xr-xebuild/fetchers/dowget.in54
-rw-r--r--paludis/ebuild.cc1
-rw-r--r--paludis/ebuild.sr1
-rw-r--r--paludis/repositories/portage/ebuild_entries.cc3
-rw-r--r--paludis/repository.sr1
-rw-r--r--paludis/tasks/install_task.cc8
-rw-r--r--paludis/tasks/install_task.hh1
-rw-r--r--paludis/tasks/uninstall_task.cc2
-rw-r--r--src/clients/paludis/command_line.cc1
-rw-r--r--src/clients/paludis/command_line.hh3
-rw-r--r--src/clients/paludis/install.cc1
12 files changed, 93 insertions, 11 deletions
diff --git a/doc/faq.html.skel b/doc/faq.html.skel
index f0e9811..9ed0853 100644
--- a/doc/faq.html.skel
+++ b/doc/faq.html.skel
@@ -67,6 +67,8 @@ export CXX="/usr/lib/ccache/bin/g++"
<li><code>--resume-command-template ~/.paludis-resume-XXXXXX</code></li>
<li><code>--dl-reinstall-scm weekly</code></li>
+
+ <li><code>--safe-resume</code></li>
</ul>
<p>You can either use a shell alias, or <code>export
@@ -219,7 +221,7 @@ there so you will have to create it.</p>
<h3 id="wgetresume">wget Resume Support</h3>
<p>Non-Problem: With Portage, <code>wget -c</code> is used to attempt to resume
-downloads of partial files. With Paludis, resumes are not allowed.</p>
+downloads of partial files. With Paludis, this is not done by default.</p>
<p>Rationale: This leads to corruption and wasted bandwidth far too frequently.
In particular, if an error page that isn't recognised as a 404 is fetched from
@@ -228,8 +230,28 @@ support means <code>wget</code> would then download all but the first few
hundred bytes of the file from somewhere else, leading to a corrupt distfile
notice only after lots of bandwidth has been wasted.</p>
-<p>Having said that, if you really want this functionality, you can implement it
-using a custom fetcher.</p>
+<p>Paludis provides a <code>--safe-resume</code> option. When enabled, the download
+logic is as follows:</p>
+
+<ul>
+ <li>If <code>output_file.-PARTIAL-</code> exists and is below a certain
+ arbitrary threshold (currently somewhere in the 100KBytes region), delete it.</li>
+
+ <li>Rather than downloading straight to <code>output_file</code>, download to
+ <code>output_file.-PARTIAL-</code>. If this file already exists, resume rather than
+ starting from scratch.</li>
+
+ <li>If <code>wget</code> exits with success, move <code>output_file.-PARTIAL-</code>
+ to <code>output_file</code>.</li>
+</ul>
+
+<p>Note that you mush <strong>always</strong> specify this option,
+not just after a download has already been interrupted. See <a href="#defaultoptions">the
+ discussion on default options</a> for how to do this easily.</a>.</p>
+
+<p>This logic is handled by the default fetcher for <code>http://</code>, <code>https://</code>
+and <code>ftp://</code>. This can be overridden by a custom fetcher if finer grained control
+is required.</p>
<h3 id="skipfirst">Build Resume / Skip First Support</h3>
diff --git a/ebuild/fetchers/dowget.in b/ebuild/fetchers/dowget.in
index a6d8007..41e645a 100755
--- a/ebuild/fetchers/dowget.in
+++ b/ebuild/fetchers/dowget.in
@@ -1,10 +1,54 @@
#!/bin/bash
+# vim: set sw=4 sts=4 et :
+
+# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+#
+# This file is part of the Paludis package manager. Paludis is free software;
+# you can redistribute it and/or modify it under the terms of the GNU General
+# Public License, version 2, as published by the Free Software Foundation.
+#
+# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA
+
+export PATH="$(${PALUDIS_EBUILD_DIR}/utils/canonicalise ${PALUDIS_EBUILD_DIR}/utils/ ):${PATH}"
+source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
+
+if [[ -n "${PALUDIS_USE_SAFE_RESUME}" ]] ; then
+
+ if [[ -f "${2}.-PARTIAL-" ]] ; then
+ if [[ $(getfsize "${2}".-PARTIAL- ) -ge 123456 ]] ; then
+ einfo_unhooked "Attempting resume using ${2}.-PARTIAL-"
+ else
+ einfo_unhooked "Not attempting resume using ${2}.-PARTIAL- (too small)"
+ echo rm -f "${2}".-PARTIAL-
+ rm -f "${2}".-PARTIAL-
+ fi
+ fi
+
+ echo ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 --continue -O "${2}".-PARTIAL- "${1}" 1>&2
+ if ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 --continue -O "${2}".-PARTIAL- "${1}" ; then
+ echo mv -f "${2}".-PARTIAL- "${2}"
+ mv -f "${2}".-PARTIAL- "${2}"
+ exit 0
+ else
+ rm -f "${2}"
+ exit 1
+ fi
-echo ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 -O "${2}" "${1}" 1>&2
-if ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 -O "${2}" "${1}" ; then
- exit 0
else
- rm -f "${2}"
- exit 1
+ echo ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 -O "${2}" "${1}" 1>&2
+ if ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 -O "${2}" "${1}" ; then
+ exit 0
+ else
+ rm -f "${2}"
+ exit 1
+ fi
+
fi
diff --git a/paludis/ebuild.cc b/paludis/ebuild.cc
index 0b23d5d..5b6a8d1 100644
--- a/paludis/ebuild.cc
+++ b/paludis/ebuild.cc
@@ -279,6 +279,7 @@ EbuildFetchCommand::extend_command(const MakeEnvCommand & cmd)
("USE_EXPAND", fetch_params.use_expand)
("FLAT_SRC_URI", fetch_params.flat_src_uri)
("ROOT", fetch_params.root)
+ ("PALUDIS_USE_SAFE_RESUME", fetch_params.safe_resume ? "oohyesplease" : "")
("PALUDIS_PROFILE_DIR", stringify(*fetch_params.profiles->begin()))
("PALUDIS_PROFILE_DIRS", join(fetch_params.profiles->begin(),
fetch_params.profiles->end(), " ")));
diff --git a/paludis/ebuild.sr b/paludis/ebuild.sr
index 24f85a6..380e24c 100644
--- a/paludis/ebuild.sr
+++ b/paludis/ebuild.sr
@@ -36,6 +36,7 @@ make_class_EbuildFetchCommandParams()
key profiles FSEntryCollection::ConstPointer
key expand_vars "AssociativeCollection<std::string, std::string>::ConstPointer"
key no_fetch bool
+ key safe_resume bool
doxygen_comment << "END"
/**
diff --git a/paludis/repositories/portage/ebuild_entries.cc b/paludis/repositories/portage/ebuild_entries.cc
index 0d7cfb1..0c2c2b0 100644
--- a/paludis/repositories/portage/ebuild_entries.cc
+++ b/paludis/repositories/portage/ebuild_entries.cc
@@ -455,7 +455,8 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
.flat_src_uri(flat_src_uri)
.root(stringify(_imp->params.root) + "/")
.profiles(_imp->params.profiles)
- .no_fetch(fetch_restrict));
+ .no_fetch(fetch_restrict)
+ .safe_resume(o.safe_resume));
fetch_cmd();
diff --git a/paludis/repository.sr b/paludis/repository.sr
index 6480aaf..a44df98 100644
--- a/paludis/repository.sr
+++ b/paludis/repository.sr
@@ -6,6 +6,7 @@ make_class_InstallOptions()
key no_config_protect bool
key fetch_only bool
key debug_build InstallDebugOption
+ key safe_resume bool
doxygen_comment << "END"
/**
diff --git a/paludis/tasks/install_task.cc b/paludis/tasks/install_task.cc
index a8322f6..d13b9ea 100644
--- a/paludis/tasks/install_task.cc
+++ b/paludis/tasks/install_task.cc
@@ -50,7 +50,7 @@ namespace paludis
env(e),
dep_list(e, o),
current_dep_list_entry(dep_list.begin()),
- install_options(false, false, ido_none),
+ install_options(false, false, ido_none, false),
targets(new AllDepAtom),
add_to_world_atom(0),
pretend(false),
@@ -493,3 +493,9 @@ InstallTask::had_package_targets() const
return _imp->had_package_targets;
}
+void
+InstallTask::set_safe_resume(const bool value)
+{
+ _imp->install_options.safe_resume = value;
+}
+
diff --git a/paludis/tasks/install_task.hh b/paludis/tasks/install_task.hh
index fec2f47..ed446b3 100644
--- a/paludis/tasks/install_task.hh
+++ b/paludis/tasks/install_task.hh
@@ -88,6 +88,7 @@ namespace paludis
void set_preserve_world(const bool value);
void set_debug_mode(const InstallDebugOption value);
void set_add_to_world_atom(const std::string &);
+ void set_safe_resume(const bool);
///\}
diff --git a/paludis/tasks/uninstall_task.cc b/paludis/tasks/uninstall_task.cc
index ca834cd..5d5e948 100644
--- a/paludis/tasks/uninstall_task.cc
+++ b/paludis/tasks/uninstall_task.cc
@@ -46,7 +46,7 @@ namespace paludis
Implementation<UninstallTask>(Environment * const e) :
env(e),
- install_options(false, false, ido_none),
+ install_options(false, false, ido_none, false),
pretend(false),
preserve_world(false),
all_versions(false),
diff --git a/src/clients/paludis/command_line.cc b/src/clients/paludis/command_line.cc
index 98dcf6d..a478c46 100644
--- a/src/clients/paludis/command_line.cc
+++ b/src/clients/paludis/command_line.cc
@@ -83,6 +83,7 @@ CommandLine::CommandLine() :
a_no_config_protection(&install_args, "no-config-protection", '\0', "Disable config file protection (dangerous)"),
a_debug_build(&install_args, "debug-build", '\0'),
a_fetch(&install_args, "fetch", 'f', "Only fetch sources; don't install anything"),
+ a_safe_resume(&install_args, "safe-resume", '\0', "Allow interrupted downloads to be resumed safely"),
a_show_install_reasons(&install_args, "show-install-reasons", '\0', "Show why packages are being installed",
args::EnumArg::EnumArgOptions
("none", "Don't show any information")
diff --git a/src/clients/paludis/command_line.hh b/src/clients/paludis/command_line.hh
index d70437b..c02efa0 100644
--- a/src/clients/paludis/command_line.hh
+++ b/src/clients/paludis/command_line.hh
@@ -203,6 +203,9 @@ class CommandLine :
/// --fetch
paludis::args::SwitchArg a_fetch;
+ /// --safe-resume
+ paludis::args::SwitchArg a_safe_resume;
+
/// --show-install-reasons
paludis::args::EnumArg a_show_install_reasons;
diff --git a/src/clients/paludis/install.cc b/src/clients/paludis/install.cc
index c43e0db..0fcab32 100644
--- a/src/clients/paludis/install.cc
+++ b/src/clients/paludis/install.cc
@@ -387,6 +387,7 @@ do_install()
task.set_fetch_only(CommandLine::get_instance()->a_fetch.specified());
task.set_pretend(CommandLine::get_instance()->a_pretend.specified());
task.set_preserve_world(CommandLine::get_instance()->a_preserve_world.specified());
+ task.set_safe_resume(CommandLine::get_instance()->a_safe_resume.specified());
if (CommandLine::get_instance()->a_add_to_world_atom.specified())
task.set_add_to_world_atom(CommandLine::get_instance()->a_add_to_world_atom.argument());