~ubuntu-branches/ubuntu/wily/steam/wily

« back to all changes in this revision

Viewing changes to services/spm.pike

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2013-10-29 19:51:18 UTC
  • mfrom: (1.1.4) (0.1.4 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131029195118-b9bxciz5hwx5z459
Tags: 1:1.0.0.39-2ubuntu1
Add an epoch to the version number as there was an unrelated steam package
in the archive with a higher version number.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
inherit Service.Service;
2
 
 
3
 
void call_service(object user, mixed args, void|int id)
4
 
{
5
 
  
6
 
}
7
 
 
8
 
void install_spm(object spmModule, string pname) 
9
 
{
10
 
  object fp = connection->send_cmd(0, "get_module", "filepath:tree");
11
 
  object packages = fp->path_to_object("/packages");
12
 
  werror("Updating %O\n", pname);
13
 
  if ( objectp(packages) ) {
14
 
    // tarfs
15
 
    object tfs = Filesystem.Tar("spms/"+pname);
16
 
    if ( !objectp(tfs) ) {
17
 
      werror(": " + pname + " not a valid SPM !\n");
18
 
      return;
19
 
    }
20
 
    mixed xml = tfs->open("package.xml", "r");
21
 
    string packageXML = xml->read();
22
 
    xml->close();
23
 
    mapping config =spmModule->spm_check_configuration(packageXML);
24
 
    werror("CONFIG = %O\n", config);
25
 
    mapping pmod = connection->send_cmd(0, "get_module", config->name);
26
 
    if ( !objectp(pmod) )
27
 
      pmod = connection->send_cmd(0, "get_module", "package:"+config->name);
28
 
    if ( objectp(pmod) ) {
29
 
      if ( spmModule->spm_version_value(config->version) <= spmModule->spm_version_value(pmod->get_version()) ) {
30
 
        werror("Found installed module with version %O, skipping installation !\n", pmod->get_version());
31
 
        return;
32
 
      }
33
 
      else {
34
 
        werror("Found installed module - updating to %O (previous version %O)\n",
35
 
               config->version, pmod->get_version());
36
 
      }
37
 
    }
38
 
      
39
 
    Stdio.File file = Stdio.File("spms/"+pname, "r");
40
 
    object package = packages->get_object_byname(pname);
41
 
    if ( !objectp(package) ) {
42
 
      object docfactory = connection->get_variable("Document.factory");
43
 
      package = docfactory->execute( (["name": pname, ]));
44
 
      package->move(packages);
45
 
    }
46
 
    package->set_content(file->read());
47
 
    spmModule->install_spm(package, fp->path_to_object("/"));
48
 
    return;
49
 
  }
50
 
  error("Failed to install - no /packages found on server");
51
 
}
52
 
 
53
 
static void check_spms()
54
 
{
55
 
  object _spm = connection->send_cmd( 0, "get_module", "SPM" );
56
 
  if ( !objectp(_spm) )
57
 
    werror("Failed to find SPM Module !\n");
58
 
  array directory = get_dir("spms");
59
 
  foreach ( directory, string file ) {
60
 
    werror("file = %O\n", file);
61
 
    if ( sscanf(file, "%*s.spm") ) {
62
 
      install_spm(_spm, file);
63
 
    }
64
 
  }
65
 
  call_out(check_spms, 30);
66
 
}
67
 
 
68
 
static void run()
69
 
{
70
 
  werror("cwd = " + getcwd() + "\n");
71
 
  check_spms();
72
 
}
73
 
 
74
 
static private void got_kill(int sig) {
75
 
        _exit(1);
76
 
}
77
 
 
78
 
int main(int argc, array argv)
79
 
{
80
 
  signal(signum("QUIT"), got_kill);
81
 
  init( "spm", argv );
82
 
  start();
83
 
  return -17;
84
 
}