+# Inspired(tm) by http://www.zopelabs.com/cookbook/1022242603
+
+def wrap(paragraph, max_length, prefix=""):
+ line = "";
+ s = "";
+ have_started = 0;
+ words = paragraph.split();
+
+ for word in words:
+ word_size = len(word);
+ if word_size > max_length:
+ if have_started:
+ s += line + '\n' + prefix;
+ s += word + '\n' + prefix;
+ else:
+ if have_started:
+ new_length = len(line) + word_size + 1;
+ if new_length > max_length:
+ s += line + '\n' + prefix;
+ line = word;
+ else:
+ line += ' ' + word;
+ else:
+ line = word;
+ have_started = 1;
+
+ if have_started:
+ s += line;
+
+ return s;
+
+################################################################################
+
+# Relativize an absolute symlink from 'src' -> 'dest' relative to 'root'.
+# Returns fixed 'src'
+def clean_symlink (src, dest, root):
+ src = src.replace(root, '', 1);
+ dest = dest.replace(root, '', 1);
+ dest = os.path.dirname(dest);
+ new_src = '../' * len(dest.split('/'));
+ return new_src + src;
+
+################################################################################
+
+apt_pkg.init();