summaryrefslogtreecommitdiffstats
path: root/mgaapplet_urpm.pm
diff options
context:
space:
mode:
authorMageia SVN-Git Migration <svn-git-migration@mageia.org>2011-05-14 01:22:07 +0100
committerMageia SVN-Git Migration <svn-git-migration@mageia.org>2011-05-14 01:22:07 +0100
commite0ada251ac68dc91192c7ec7d10f3a1d7784916a (patch)
tree225ed465e93c82ad37c2794144850635b395d594 /mgaapplet_urpm.pm
parent5d4a18c95ac1ef5a657b5dcefd8a47e429d74058 (diff)
downloadmgaonline-e0ada251ac68dc91192c7ec7d10f3a1d7784916a.tar
mgaonline-e0ada251ac68dc91192c7ec7d10f3a1d7784916a.tar.gz
mgaonline-e0ada251ac68dc91192c7ec7d10f3a1d7784916a.tar.bz2
mgaonline-e0ada251ac68dc91192c7ec7d10f3a1d7784916a.tar.xz
mgaonline-e0ada251ac68dc91192c7ec7d10f3a1d7784916a.zip
Synthesized commit during git-svn import combining previous Mandriva history with Mageia.2.77.22
This commit consitsts of the following subversion commits: ------------------------------------------------------------------------ r1310 | dmorgan | 2011-05-14 01:22:07 +0100 (Sat, 14 May 2011) | 1 line Import cleaned mgaonline ------------------------------------------------------------------------
Diffstat (limited to 'mgaapplet_urpm.pm')
-rw-r--r--mgaapplet_urpm.pm55
1 files changed, 55 insertions, 0 deletions
diff --git a/mgaapplet_urpm.pm b/mgaapplet_urpm.pm
new file mode 100644
index 00000000..304f3352
--- /dev/null
+++ b/mgaapplet_urpm.pm
@@ -0,0 +1,55 @@
+package mgaapplet_urpm;
+
+# taken from urpmi:
+
+use MDK::Common;
+use urpm::download;
+
+sub userdir_prefix {
+ my ($_urpm) = @_;
+ '/tmp/.urpmi-';
+}
+sub userdir {
+ my ($urpm) = @_;
+ $< or return;
+
+ my $dir = ($urpm->{urpmi_root} || '') . userdir_prefix($urpm) . $<;
+ mkdir $dir, 0755; # try to create it
+
+ -d $dir && ! -l $dir or $urpm->{fatal}(1, sprintf("fail to create directory %s", $dir));
+ -o $dir && -w $dir or $urpm->{fatal}(1, sprintf("invalid owner for directory %s", $dir));
+
+ mkdir "$dir/partial";
+ mkdir "$dir/rpms";
+
+ $dir;
+}
+sub ensure_valid_cachedir {
+ my ($urpm) = @_;
+ if (my $dir = userdir($urpm)) {
+ $urpm->{cachedir} = $dir;
+ }
+ -w "$urpm->{cachedir}/partial" or $urpm->{fatal}(1, "Can not download packages into %s", "$urpm->{cachedir}/partial");
+}
+sub valid_cachedir {
+ my ($urpm) = @_;
+ userdir($urpm) || $urpm->{cachedir};
+}
+
+sub get_content {
+ my ($urpm, $url) = @_;
+
+ my $download_dir = valid_cachedir($urpm) . '/partial/';
+ my $file = $download_dir . basename($url);
+
+ unlink $file; # prevent "partial file" errors
+ eval { urpm::download::sync($urpm, undef, [ $url ], quiet => 1, dir => $download_dir) };
+ #sync_url($urpm, $url, dir => $download_dir, quiet => 1) or return;
+
+ my @l = cat_($file);
+ unlink $file;
+
+ wantarray() ? @l : join('', @l);
+}
+
+1;