| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package local | 5 package local |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "encoding/json" | 8 "encoding/json" |
| 9 "fmt" | 9 "fmt" |
| 10 "io" | 10 "io" |
| 11 "io/ioutil" | 11 "io/ioutil" |
| 12 ) | 12 ) |
| 13 | 13 |
| 14 // SiteServiceDir is a name of the directory inside an installation root |
| 15 // reserved for cipd stuff. |
| 16 const SiteServiceDir = ".cipd" |
| 17 |
| 14 const ( | 18 const ( |
| 15 » // Name of the directory inside an installation root reserved for cipd s
tuff. | 19 » // packageServiceDir is a name of the directory inside the package |
| 16 » siteServiceDir = ".cipd" | 20 » // reserved for cipd stuff. |
| 17 » // Name of the directory inside the package reserved for cipd stuff. | |
| 18 packageServiceDir = ".cipdpkg" | 21 packageServiceDir = ".cipdpkg" |
| 19 » // Name of the manifest file inside the package. | 22 |
| 23 » // manifestName is a name of the manifest file inside the package. |
| 20 manifestName = packageServiceDir + "/manifest.json" | 24 manifestName = packageServiceDir + "/manifest.json" |
| 21 » // Format version to write to the manifest file. | 25 |
| 26 » // manifestFormatVersion is a version to write to the manifest file. |
| 22 manifestFormatVersion = "1" | 27 manifestFormatVersion = "1" |
| 23 ) | 28 ) |
| 24 | 29 |
| 25 // InstallMode defines how to install a package. | 30 // InstallMode defines how to install a package. |
| 26 type InstallMode string | 31 type InstallMode string |
| 27 | 32 |
| 28 const ( | 33 const ( |
| 29 // InstallModeSymlink is default (for backward compatibility). In this m
ode | 34 // InstallModeSymlink is default (for backward compatibility). In this m
ode |
| 30 // all files are extracted to .cipd/*/... and then symlinked to the site
root | 35 // all files are extracted to .cipd/*/... and then symlinked to the site
root |
| 31 // directory. Version switch happens atomically. | 36 // directory. Version switch happens atomically. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 106 |
| 102 // writeManifest encodes and writes manifest JSON to io.Writer. | 107 // writeManifest encodes and writes manifest JSON to io.Writer. |
| 103 func writeManifest(m *Manifest, w io.Writer) error { | 108 func writeManifest(m *Manifest, w io.Writer) error { |
| 104 data, err := json.MarshalIndent(m, "", " ") | 109 data, err := json.MarshalIndent(m, "", " ") |
| 105 if err != nil { | 110 if err != nil { |
| 106 return err | 111 return err |
| 107 } | 112 } |
| 108 _, err = w.Write(data) | 113 _, err = w.Write(data) |
| 109 return err | 114 return err |
| 110 } | 115 } |
| OLD | NEW |