]> git.proxmox.com Git - vzctl.git/blame - debian/patches/allow-abs-ostemplate-path.diff
update to vzctl-3.0.30.2
[vzctl.git] / debian / patches / allow-abs-ostemplate-path.diff
CommitLineData
49ee0bad
DM
1Index: new/src/lib/create.c
2===================================================================
211c83e2
DM
3--- new.orig/src/lib/create.c 2012-02-10 06:33:24.000000000 +0100
4+++ new/src/lib/create.c 2012-02-10 07:09:43.000000000 +0100
5@@ -102,20 +102,25 @@
49ee0bad
DM
6 const char *ext[] = { "", ".gz", ".bz2", ".xz", NULL };
7 const char *errmsg_ext = "[.gz|.bz2|.xz]";
8
211c83e2 9-find:
49ee0bad 10- for (i = 0; ext[i] != NULL; i++) {
211c83e2
DM
11- snprintf(tarball, sizeof(tarball), "%s/cache/%s.tar%s",
12- fs->tmpl, tmpl->ostmpl, ext[i]);
49ee0bad
DM
13- logger(1, 0, "Looking for %s", tarball);
14- if (stat_file(tarball))
15- break;
16- }
17- if (ext[i] == NULL) {
211c83e2
DM
18- if (download_template(tmpl->ostmpl) == 0)
19- goto find;
20- logger(-1, 0, "Cached OS template %s/cache/%s.tar%s not found",
21- fs->tmpl, tmpl->ostmpl, errmsg_ext);
49ee0bad 22- return VZ_OSTEMPLATE_NOT_FOUND;
211c83e2
DM
23+ if (tmpl->ostmpl[0] == '/' && stat_file(tmpl->ostmpl)) {
24+ snprintf(tarball, sizeof(tarball), "%s", tmpl->ostmpl);
49ee0bad 25+ } else {
211c83e2
DM
26+
27+ find:
49ee0bad 28+ for (i = 0; ext[i] != NULL; i++) {
211c83e2
DM
29+ snprintf(tarball, sizeof(tarball), "%s/cache/%s.tar%s",
30+ fs->tmpl, tmpl->ostmpl, ext[i]);
49ee0bad
DM
31+ logger(1, 0, "Looking for %s", tarball);
32+ if (stat_file(tarball))
33+ break;
34+ }
35+ if (ext[i] == NULL) {
211c83e2
DM
36+ if (download_template(tmpl->ostmpl) == 0)
37+ goto find;
38+ logger(-1, 0, "Cached OS template %s/cache/%s.tar%s not found",
39+ fs->tmpl, tmpl->ostmpl, errmsg_ext);
49ee0bad
DM
40+ return VZ_OSTEMPLATE_NOT_FOUND;
41+ }
42 }
43 /* Lock CT area */
44 if (make_dir(fs->private, 0))
211c83e2
DM
45@@ -190,6 +195,7 @@
46 int ret = 0;
49ee0bad
DM
47 char src[STR_SIZE];
48 char dst[STR_SIZE];
49+ char *p;
50 const char *sample_config;
51 fs_param *fs = &vps_p->res.fs;
52 tmpl_param *tmpl = &vps_p->res.tmpl;
211c83e2 53@@ -312,6 +318,12 @@
49ee0bad 54 }
211c83e2
DM
55 if ((ret = fs_create(veid, fs, tmpl, &vps_p->res.dq)))
56 goto err_private;
49ee0bad 57+
211c83e2
DM
58+ if ((p = strrchr(tmpl->ostmpl, '/'))) {
59+ p = strdup(p + 1);
60+ free(tmpl->ostmpl);
61+ tmpl->ostmpl = p;
62+ }
63 }
64
65 if ((ret = vps_postcreate(veid, &vps_p->res)))