Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
8863ae95
Commit
8863ae95
authored
Jun 11, 2013
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add API for apt using libapt-pkg-perl
parent
6c5441ad
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
149 additions
and
1 deletion
+149
-1
APT.pm
PVE/API2/APT.pm
+140
-0
Makefile
PVE/API2/Makefile
+1
-0
Nodes.pm
PVE/API2/Nodes.pm
+7
-0
control.in
debian/control.in
+1
-1
No files found.
PVE/API2/APT.pm
0 → 100644
View file @
8863ae95
package
PVE::API2::
APT
;
use
strict
;
use
warnings
;
use
PVE::
Tools
qw(extract_param)
;
use
PVE::
SafeSyslog
;
use
PVE::
INotify
;
use
PVE::
Exception
qw(raise_param_exc)
;
use
PVE::
RESTHandler
;
use
PVE::
RPCEnvironment
;
use
PVE::
JSONSchema
qw(get_standard_option)
;
use
AptPkg::
Cache
;
use
AptPkg::
Version
;
use
AptPkg::
PkgRecords
;
my
$apt_cache
;
my
$get_apt_cache
=
sub
{
return
$apt_cache
if
$apt_cache
;
$apt_cache
=
AptPkg::
Cache
->
new
()
||
die
"
unable to initialize AptPkg::Cache
\n
";
return
$apt_cache
;
};
use
base
qw(PVE::RESTHandler)
;
__PACKAGE__
->
register_method
({
name
=>
'
index
',
path
=>
'',
method
=>
'
GET
',
description
=>
"
Directory index for apt (Advanced Package Tool).
",
permissions
=>
{
user
=>
'
all
',
},
parameters
=>
{
additionalProperties
=>
0
,
properties
=>
{
node
=>
get_standard_option
('
pve-node
'),
},
},
returns
=>
{
type
=>
"
array
",
items
=>
{
type
=>
"
object
",
properties
=>
{
id
=>
{
type
=>
'
string
'
},
},
},
links
=>
[
{
rel
=>
'
child
',
href
=>
"
{id}
"
}
],
},
code
=>
sub
{
my
(
$param
)
=
@_
;
my
$res
=
[
{
id
=>
'
update
'
},
{
id
=>
'
upgrade
'
},
{
id
=>
'
changelog
'
},
];
return
$res
;
}});
my
$assemble_pkginfo
=
sub
{
my
(
$pkgname
,
$info
,
$current_ver
,
$candidate_ver
)
=
@_
;
my
$data
=
{
Package
=>
$info
->
{
Name
},
Title
=>
$info
->
{
ShortDesc
},
};
if
(
my
$desc
=
$info
->
{
LongDesc
})
{
$desc
=~
s/^.*\n\s?//
;
# remove first line
$desc
=~
s/\n / /g
;
$data
->
{
Description
}
=
$desc
;
}
foreach
my
$k
(
qw(Section Arch Priority)
)
{
$data
->
{
$k
}
=
$candidate_ver
->
{
$k
};
}
$data
->
{
Version
}
=
$candidate_ver
->
{
VerStr
};
$data
->
{
OldVersion
}
=
$current_ver
->
{
VerStr
};
return
$data
;
};
__PACKAGE__
->
register_method
({
name
=>
'
list_updates
',
path
=>
'
update
',
method
=>
'
GET
',
description
=>
"
List available updates.
",
permissions
=>
{
check
=>
['
perm
',
'
/nodes/{node}
',
[
'
Sys.Modify
'
]],
},
protected
=>
1
,
proxyto
=>
'
node
',
parameters
=>
{
additionalProperties
=>
0
,
properties
=>
{
node
=>
get_standard_option
('
pve-node
'),
},
},
returns
=>
{
type
=>
"
array
",
items
=>
{
type
=>
"
object
",
properties
=>
{},
},
},
code
=>
sub
{
my
(
$param
)
=
@_
;
my
$pkglist
=
[]
;
my
$cache
=
&
$get_apt_cache
();
my
$policy
=
$cache
->
policy
;
my
$pkgrecords
=
$cache
->
packages
();
foreach
my
$pkgname
(
keys
%
$cache
)
{
my
$p
=
$cache
->
{
$pkgname
};
next
if
$p
->
{
SelectedState
}
ne
'
Install
';
my
$current_ver
=
$p
->
{
CurrentVer
};
my
$candidate_ver
=
$policy
->
candidate
(
$p
);
if
(
$current_ver
->
{
VerStr
}
ne
$candidate_ver
->
{
VerStr
})
{
my
$info
=
$pkgrecords
->
lookup
(
$pkgname
);
my
$res
=
&
$assemble_pkginfo
(
$pkgname
,
$info
,
$current_ver
,
$candidate_ver
);
push
@$pkglist
,
$res
;
}
}
return
$pkglist
;
}});
1
;
PVE/API2/Makefile
View file @
8863ae95
include
../../defines.mk
PERLSOURCE
=
\
APT.pm
\
Subscription.pm
\
VZDump.pm
\
Backup.pm
\
...
...
PVE/API2/Nodes.pm
View file @
8863ae95
...
...
@@ -29,6 +29,7 @@ use PVE::API2::Storage::Status;
use
PVE::API2::
Qemu
;
use
PVE::API2::
OpenVZ
;
use
PVE::API2::
VZDump
;
use
PVE::API2::
APT
;
use
JSON
;
use
base
qw(PVE::RESTHandler)
;
...
...
@@ -78,6 +79,11 @@ __PACKAGE__->register_method ({
path
=>
'
storage
',
});
__PACKAGE__
->
register_method
({
subclass
=>
"
PVE::API2::APT
",
path
=>
'
apt
',
});
__PACKAGE__
->
register_method
({
name
=>
'
index
',
path
=>
'',
...
...
@@ -102,6 +108,7 @@ __PACKAGE__->register_method ({
my
(
$param
)
=
@_
;
my
$result
=
[
{
name
=>
'
apt
'
},
{
name
=>
'
version
'
},
{
name
=>
'
syslog
'
},
{
name
=>
'
bootlog
'
},
...
...
debian/control.in
View file @
8863ae95
...
...
@@ -3,7 +3,7 @@ Version: @VERSION@-@PACKAGERELEASE@
Section: admin
Priority: optional
Architecture: amd64
Depends: perl5, libtimedate-perl, libauthen-pam-perl, libintl-perl, rsync, libjson-perl, liblockfile-simple-perl, vncterm, qemu-server (>= 1.1-1), libwww-perl (>= 6.04-1), libnet-http-perl (>= 6.06-1), libhttp-daemon-perl, wget, libnet-dns-perl, vlan, ifenslave-2.6 (>= 1.1.0-10), liblinux-inotify2-perl, debconf (>= 0.5) | debconf-2.0, netcat-traditional, pve-cluster (>= 1.0-29), libpve-common-perl, libpve-storage-perl, libterm-readline-gnu-perl, libpve-access-control (>= 3.0-2), libio-socket-ssl-perl, libfilesys-df-perl, libfile-readbackwards-perl, libfile-sync-perl, redhat-cluster-pve, resource-agents-pve, fence-agents-pve, cstream, postfix | mail-transport-agent, libxml-parser-perl, lzop, dtach, libanyevent-perl, libio-compress-perl, liburi-perl, logrotate, libanyevent-http-perl, apt-transport-https
Depends: perl5, libtimedate-perl, libauthen-pam-perl, libintl-perl, rsync, libjson-perl, liblockfile-simple-perl, vncterm, qemu-server (>= 1.1-1), libwww-perl (>= 6.04-1), libnet-http-perl (>= 6.06-1), libhttp-daemon-perl, wget, libnet-dns-perl, vlan, ifenslave-2.6 (>= 1.1.0-10), liblinux-inotify2-perl, debconf (>= 0.5) | debconf-2.0, netcat-traditional, pve-cluster (>= 1.0-29), libpve-common-perl, libpve-storage-perl, libterm-readline-gnu-perl, libpve-access-control (>= 3.0-2), libio-socket-ssl-perl, libfilesys-df-perl, libfile-readbackwards-perl, libfile-sync-perl, redhat-cluster-pve, resource-agents-pve, fence-agents-pve, cstream, postfix | mail-transport-agent, libxml-parser-perl, lzop, dtach, libanyevent-perl, libio-compress-perl, liburi-perl, logrotate, libanyevent-http-perl, apt-transport-https
, libapt-pkg-perl
Conflicts: netcat-openbsd, vzdump
Replaces: vzdump
Provides: vzdump
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment