├── .dockerignore ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── Cargo.lock ├── Cargo.toml ├── Dockerfile ├── README.md ├── appveyor.yml ├── ci ├── before_deploy.ps1 ├── before_deploy.sh ├── install.sh └── script.sh ├── rustfmt.toml └── src ├── docker.rs ├── lib.rs └── main.rs /.dockerignore: -------------------------------------------------------------------------------- 1 | * -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Based on the "trust" template v0.1.2 2 | # https://github.com/japaric/trust/tree/v0.1.2 3 | 4 | dist: trusty 5 | language: rust 6 | services: docker 7 | sudo: required 8 | 9 | # TODO Rust builds on stable by default, this can be 10 | # overridden on a case by case basis down below. 11 | 12 | env: 13 | global: 14 | - CRATE_NAME=cargo-pack-docker 15 | 16 | matrix: 17 | include: 18 | # Android 19 | # - env: TARGET=aarch64-linux-android DISABLE_TESTS=1 20 | # - env: TARGET=arm-linux-androideabi DISABLE_TESTS=1 21 | # - env: TARGET=armv7-linux-androideabi DISABLE_TESTS=1 22 | # - env: TARGET=i686-linux-android DISABLE_TESTS=1 23 | # - env: TARGET=x86_64-linux-android DISABLE_TESTS=1 24 | 25 | # iOS 26 | # - env: TARGET=aarch64-apple-ios DISABLE_TESTS=1 27 | # os: osx 28 | # - env: TARGET=armv7-apple-ios DISABLE_TESTS=1 29 | # os: osx 30 | # - env: TARGET=armv7s-apple-ios DISABLE_TESTS=1 31 | # os: osx 32 | # - env: TARGET=i386-apple-ios DISABLE_TESTS=1 33 | # os: osx 34 | # - env: TARGET=x86_64-apple-ios DISABLE_TESTS=1 35 | # os: osx 36 | 37 | # Linux 38 | - env: TARGET=aarch64-unknown-linux-gnu 39 | - env: TARGET=arm-unknown-linux-gnueabi 40 | - env: TARGET=armv7-unknown-linux-gnueabihf 41 | - env: TARGET=i686-unknown-linux-gnu 42 | - env: TARGET=i686-unknown-linux-musl 43 | # - env: TARGET=mips-unknown-linux-gnu 44 | # - env: TARGET=mips64-unknown-linux-gnuabi64 45 | # - env: TARGET=mips64el-unknown-linux-gnuabi64 46 | # - env: TARGET=mipsel-unknown-linux-gnu 47 | # - env: TARGET=powerpc-unknown-linux-gnu 48 | # - env: TARGET=powerpc64-unknown-linux-gnu 49 | # - env: TARGET=powerpc64le-unknown-linux-gnu 50 | # - env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1 51 | - env: TARGET=x86_64-unknown-linux-gnu 52 | - env: TARGET=x86_64-unknown-linux-musl 53 | 54 | # OSX 55 | # - env: TARGET=i686-apple-darwin 56 | # os: osx 57 | - env: TARGET=x86_64-apple-darwin 58 | os: osx 59 | 60 | # *BSD 61 | # - env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1 62 | # - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1 63 | # - env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1 64 | 65 | # Windows 66 | - env: TARGET=x86_64-pc-windows-gnu 67 | 68 | # Bare metal 69 | # These targets don't support std and as such are likely not suitable for 70 | # most crates. 71 | # - env: TARGET=thumbv6m-none-eabi 72 | # - env: TARGET=thumbv7em-none-eabi 73 | # - env: TARGET=thumbv7em-none-eabihf 74 | # - env: TARGET=thumbv7m-none-eabi 75 | 76 | # Testing other channels 77 | - env: TARGET=x86_64-unknown-linux-gnu 78 | rust: beta 79 | - env: TARGET=x86_64-apple-darwin 80 | os: osx 81 | rust: beta 82 | - env: TARGET=x86_64-unknown-linux-gnu 83 | rust: nightly 84 | - env: TARGET=x86_64-apple-darwin 85 | os: osx 86 | rust: nightly 87 | 88 | before_install: 89 | - set -e 90 | - rustup self update 91 | 92 | install: 93 | - sh ci/install.sh 94 | - source ~/.cargo/env || true 95 | 96 | script: 97 | - bash ci/script.sh 98 | 99 | after_script: set +e 100 | 101 | before_deploy: 102 | - sh ci/before_deploy.sh 103 | 104 | deploy: 105 | api_key: 106 | secure: "my+wVyidabjaA7CESiLt6T99eEu3jfwdNEwmraz4kkcE2bDJLdD3ur7gxoHfL9cWG1ZKMbPVcF5YA9WO6rNmUghzFXmv6Toy5BQ0mKgffbJxkNGOkOW1eeMFhRgf9rbI404ylVuUFqBxHHpMBpcrg9Xk1Futv1e7WzgkZ45dgtAlFHAPbyiOQ9Zy13LI6Gk+VYPyxko+3C0s6Sq8OE2tCvNgjb0rlvNUR87kX5pZWkiixJQM1goGMsZ77NCNnMrDiaenv3+UbY4ponWXf7gvEffnCpn9DJqOGVWXQc622e2LGZB6JNCMigElNDWBD6yYKhaTBWeOJeOfb5h6kVJNMl3Ps9ublInuFjGs1RtwXqLVylrdGu0X02MrmWNq3PUdt+0V0kZd/BPJerEl/hkgZDIVNXOJ+FIS8ggVCU3zTQ4HmSghi2sGkQWmmS3DYlWT2JECKoaUsDWEF4J64bl+iCBrZd4LKJh9d+SW9nsPt1T01IQmj8wH3DxsAPBmM1LMjZ8ggedCt3pFFuVwa9EzVUCCIHb5iUbSoe1UFa9w5aPQMCKXkVVxZ+q4BcjC6y/IuaMG4972CdMlbfkrjI4EROuh1/xEdRYfvAro31msv/hKomDfucp4A5qSwkRVmv4bwx+sgFzQECgDr7oFAcIuzTKZccIr6NA75g8rgmxxqgk=" 107 | file_glob: true 108 | file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.* 109 | on: 110 | # TODO Here you can pick which targets will generate binary releases 111 | # In this example, there are some targets that are tested using the stable 112 | # and nightly channels. This condition makes sure there is only one release 113 | # for such targets and that's generated using the stable channel 114 | condition: $TRAVIS_RUST_VERSION = stable 115 | tags: true 116 | provider: releases 117 | skip_cleanup: true 118 | 119 | cache: cargo 120 | before_cache: 121 | # Travis can't cache files that are not readable by "others" 122 | - chmod -R a+r $HOME/.cargo 123 | 124 | branches: 125 | only: 126 | # release tags 127 | - /^v\d+\.\d+\.\d+.*$/ 128 | - master 129 | 130 | notifications: 131 | email: 132 | on_success: never 133 | 134 | addons: 135 | apt: 136 | packages: 137 | - gcc-multilib 138 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.5.0 2 | 3 | * get rid of cargo dependency; use `cargo metadata` instead. 4 | * update dependencies 5 | 6 | # 0.4.0 7 | 8 | * find docker from path 9 | * update dependencies 10 | 11 | # 0.3.3 12 | 13 | * find docker binary from path 14 | + was fixed to `/usr/bin/docker` 15 | + resolve errors on macOS and other platforms 16 | 17 | # 0.3.2 18 | 19 | * add `--no-build` option 20 | 21 | # 0.3.1 22 | 23 | * update cargo 24 | 25 | # 0.3.0 26 | 27 | * update cargo 28 | 29 | # 0.2.0 30 | 31 | * update dependencies 32 | * correctly handle `tag` field 33 | 34 | # 0.1.1 35 | 36 | * support multiple `-p` option 37 | 38 | # 0.1.0 39 | 40 | * first release 41 | * basic functionalities to package into docker images 42 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "aho-corasick" 5 | version = "0.7.8" 6 | source = "registry+https://github.com/rust-lang/crates.io-index" 7 | dependencies = [ 8 | "memchr 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 9 | ] 10 | 11 | [[package]] 12 | name = "ansi_term" 13 | version = "0.11.0" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | dependencies = [ 16 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 17 | ] 18 | 19 | [[package]] 20 | name = "atty" 21 | version = "0.2.14" 22 | source = "registry+https://github.com/rust-lang/crates.io-index" 23 | dependencies = [ 24 | "hermit-abi 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", 25 | "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", 26 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 27 | ] 28 | 29 | [[package]] 30 | name = "backtrace" 31 | version = "0.3.44" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | dependencies = [ 34 | "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", 35 | "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 36 | "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", 37 | "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", 38 | ] 39 | 40 | [[package]] 41 | name = "backtrace-sys" 42 | version = "0.1.32" 43 | source = "registry+https://github.com/rust-lang/crates.io-index" 44 | dependencies = [ 45 | "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", 46 | "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", 47 | ] 48 | 49 | [[package]] 50 | name = "bitflags" 51 | version = "1.2.1" 52 | source = "registry+https://github.com/rust-lang/crates.io-index" 53 | 54 | [[package]] 55 | name = "block-buffer" 56 | version = "0.7.3" 57 | source = "registry+https://github.com/rust-lang/crates.io-index" 58 | dependencies = [ 59 | "block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 60 | "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 61 | "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", 62 | "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", 63 | ] 64 | 65 | [[package]] 66 | name = "block-padding" 67 | version = "0.1.5" 68 | source = "registry+https://github.com/rust-lang/crates.io-index" 69 | dependencies = [ 70 | "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 71 | ] 72 | 73 | [[package]] 74 | name = "byte-tools" 75 | version = "0.3.1" 76 | source = "registry+https://github.com/rust-lang/crates.io-index" 77 | 78 | [[package]] 79 | name = "byteorder" 80 | version = "1.3.4" 81 | source = "registry+https://github.com/rust-lang/crates.io-index" 82 | 83 | [[package]] 84 | name = "cargo-pack" 85 | version = "0.6.0" 86 | source = "registry+https://github.com/rust-lang/crates.io-index" 87 | dependencies = [ 88 | "cargo_metadata 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", 89 | "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 90 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 91 | "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 92 | "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", 93 | ] 94 | 95 | [[package]] 96 | name = "cargo-pack-docker" 97 | version = "0.5.0" 98 | dependencies = [ 99 | "cargo-pack 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 100 | "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", 101 | "copy_dir 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 102 | "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", 103 | "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 104 | "handlebars 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 105 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 106 | "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 107 | "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 108 | "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", 109 | "which 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 110 | ] 111 | 112 | [[package]] 113 | name = "cargo_metadata" 114 | version = "0.9.1" 115 | source = "registry+https://github.com/rust-lang/crates.io-index" 116 | dependencies = [ 117 | "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 118 | "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 119 | "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 120 | "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", 121 | ] 122 | 123 | [[package]] 124 | name = "cc" 125 | version = "1.0.50" 126 | source = "registry+https://github.com/rust-lang/crates.io-index" 127 | 128 | [[package]] 129 | name = "cfg-if" 130 | version = "0.1.10" 131 | source = "registry+https://github.com/rust-lang/crates.io-index" 132 | 133 | [[package]] 134 | name = "clap" 135 | version = "2.33.0" 136 | source = "registry+https://github.com/rust-lang/crates.io-index" 137 | dependencies = [ 138 | "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", 139 | "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", 140 | "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", 141 | "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 142 | "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", 143 | "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", 144 | "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", 145 | ] 146 | 147 | [[package]] 148 | name = "copy_dir" 149 | version = "0.1.2" 150 | source = "registry+https://github.com/rust-lang/crates.io-index" 151 | dependencies = [ 152 | "walkdir 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 153 | ] 154 | 155 | [[package]] 156 | name = "digest" 157 | version = "0.8.1" 158 | source = "registry+https://github.com/rust-lang/crates.io-index" 159 | dependencies = [ 160 | "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", 161 | ] 162 | 163 | [[package]] 164 | name = "env_logger" 165 | version = "0.7.1" 166 | source = "registry+https://github.com/rust-lang/crates.io-index" 167 | dependencies = [ 168 | "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", 169 | "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 170 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 171 | "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", 172 | "termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 173 | ] 174 | 175 | [[package]] 176 | name = "failure" 177 | version = "0.1.6" 178 | source = "registry+https://github.com/rust-lang/crates.io-index" 179 | dependencies = [ 180 | "backtrace 0.3.44 (registry+https://github.com/rust-lang/crates.io-index)", 181 | "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 182 | ] 183 | 184 | [[package]] 185 | name = "failure_derive" 186 | version = "0.1.6" 187 | source = "registry+https://github.com/rust-lang/crates.io-index" 188 | dependencies = [ 189 | "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", 190 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 191 | "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", 192 | "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", 193 | ] 194 | 195 | [[package]] 196 | name = "fake-simd" 197 | version = "0.1.2" 198 | source = "registry+https://github.com/rust-lang/crates.io-index" 199 | 200 | [[package]] 201 | name = "fuchsia-cprng" 202 | version = "0.1.1" 203 | source = "registry+https://github.com/rust-lang/crates.io-index" 204 | 205 | [[package]] 206 | name = "generic-array" 207 | version = "0.12.3" 208 | source = "registry+https://github.com/rust-lang/crates.io-index" 209 | dependencies = [ 210 | "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", 211 | ] 212 | 213 | [[package]] 214 | name = "handlebars" 215 | version = "3.0.1" 216 | source = "registry+https://github.com/rust-lang/crates.io-index" 217 | dependencies = [ 218 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 219 | "pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 220 | "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 221 | "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 222 | "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 223 | "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", 224 | ] 225 | 226 | [[package]] 227 | name = "hermit-abi" 228 | version = "0.1.7" 229 | source = "registry+https://github.com/rust-lang/crates.io-index" 230 | dependencies = [ 231 | "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", 232 | ] 233 | 234 | [[package]] 235 | name = "humantime" 236 | version = "1.3.0" 237 | source = "registry+https://github.com/rust-lang/crates.io-index" 238 | dependencies = [ 239 | "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 240 | ] 241 | 242 | [[package]] 243 | name = "itoa" 244 | version = "0.4.5" 245 | source = "registry+https://github.com/rust-lang/crates.io-index" 246 | 247 | [[package]] 248 | name = "kernel32-sys" 249 | version = "0.2.2" 250 | source = "registry+https://github.com/rust-lang/crates.io-index" 251 | dependencies = [ 252 | "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 253 | "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 254 | ] 255 | 256 | [[package]] 257 | name = "lazy_static" 258 | version = "1.4.0" 259 | source = "registry+https://github.com/rust-lang/crates.io-index" 260 | 261 | [[package]] 262 | name = "libc" 263 | version = "0.2.66" 264 | source = "registry+https://github.com/rust-lang/crates.io-index" 265 | 266 | [[package]] 267 | name = "log" 268 | version = "0.4.8" 269 | source = "registry+https://github.com/rust-lang/crates.io-index" 270 | dependencies = [ 271 | "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 272 | ] 273 | 274 | [[package]] 275 | name = "maplit" 276 | version = "1.0.2" 277 | source = "registry+https://github.com/rust-lang/crates.io-index" 278 | 279 | [[package]] 280 | name = "memchr" 281 | version = "2.3.2" 282 | source = "registry+https://github.com/rust-lang/crates.io-index" 283 | 284 | [[package]] 285 | name = "opaque-debug" 286 | version = "0.2.3" 287 | source = "registry+https://github.com/rust-lang/crates.io-index" 288 | 289 | [[package]] 290 | name = "pest" 291 | version = "2.1.2" 292 | source = "registry+https://github.com/rust-lang/crates.io-index" 293 | dependencies = [ 294 | "ucd-trie 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 295 | ] 296 | 297 | [[package]] 298 | name = "pest_derive" 299 | version = "2.1.0" 300 | source = "registry+https://github.com/rust-lang/crates.io-index" 301 | dependencies = [ 302 | "pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 303 | "pest_generator 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 304 | ] 305 | 306 | [[package]] 307 | name = "pest_generator" 308 | version = "2.1.1" 309 | source = "registry+https://github.com/rust-lang/crates.io-index" 310 | dependencies = [ 311 | "pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 312 | "pest_meta 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 313 | "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", 314 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 315 | "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", 316 | ] 317 | 318 | [[package]] 319 | name = "pest_meta" 320 | version = "2.1.2" 321 | source = "registry+https://github.com/rust-lang/crates.io-index" 322 | dependencies = [ 323 | "maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 324 | "pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 325 | "sha-1 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", 326 | ] 327 | 328 | [[package]] 329 | name = "proc-macro2" 330 | version = "1.0.8" 331 | source = "registry+https://github.com/rust-lang/crates.io-index" 332 | dependencies = [ 333 | "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 334 | ] 335 | 336 | [[package]] 337 | name = "quick-error" 338 | version = "1.2.3" 339 | source = "registry+https://github.com/rust-lang/crates.io-index" 340 | 341 | [[package]] 342 | name = "quote" 343 | version = "1.0.2" 344 | source = "registry+https://github.com/rust-lang/crates.io-index" 345 | dependencies = [ 346 | "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", 347 | ] 348 | 349 | [[package]] 350 | name = "rand" 351 | version = "0.4.6" 352 | source = "registry+https://github.com/rust-lang/crates.io-index" 353 | dependencies = [ 354 | "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 355 | "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", 356 | "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 357 | "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 358 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 359 | ] 360 | 361 | [[package]] 362 | name = "rand_core" 363 | version = "0.3.1" 364 | source = "registry+https://github.com/rust-lang/crates.io-index" 365 | dependencies = [ 366 | "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 367 | ] 368 | 369 | [[package]] 370 | name = "rand_core" 371 | version = "0.4.2" 372 | source = "registry+https://github.com/rust-lang/crates.io-index" 373 | 374 | [[package]] 375 | name = "rdrand" 376 | version = "0.4.0" 377 | source = "registry+https://github.com/rust-lang/crates.io-index" 378 | dependencies = [ 379 | "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 380 | ] 381 | 382 | [[package]] 383 | name = "regex" 384 | version = "1.3.4" 385 | source = "registry+https://github.com/rust-lang/crates.io-index" 386 | dependencies = [ 387 | "aho-corasick 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", 388 | "memchr 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 389 | "regex-syntax 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", 390 | "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 391 | ] 392 | 393 | [[package]] 394 | name = "regex-syntax" 395 | version = "0.6.14" 396 | source = "registry+https://github.com/rust-lang/crates.io-index" 397 | 398 | [[package]] 399 | name = "remove_dir_all" 400 | version = "0.5.2" 401 | source = "registry+https://github.com/rust-lang/crates.io-index" 402 | dependencies = [ 403 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 404 | ] 405 | 406 | [[package]] 407 | name = "rustc-demangle" 408 | version = "0.1.16" 409 | source = "registry+https://github.com/rust-lang/crates.io-index" 410 | 411 | [[package]] 412 | name = "ryu" 413 | version = "1.0.2" 414 | source = "registry+https://github.com/rust-lang/crates.io-index" 415 | 416 | [[package]] 417 | name = "semver" 418 | version = "0.9.0" 419 | source = "registry+https://github.com/rust-lang/crates.io-index" 420 | dependencies = [ 421 | "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 422 | "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 423 | ] 424 | 425 | [[package]] 426 | name = "semver-parser" 427 | version = "0.7.0" 428 | source = "registry+https://github.com/rust-lang/crates.io-index" 429 | 430 | [[package]] 431 | name = "serde" 432 | version = "1.0.104" 433 | source = "registry+https://github.com/rust-lang/crates.io-index" 434 | dependencies = [ 435 | "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 436 | ] 437 | 438 | [[package]] 439 | name = "serde_derive" 440 | version = "1.0.104" 441 | source = "registry+https://github.com/rust-lang/crates.io-index" 442 | dependencies = [ 443 | "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", 444 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 445 | "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", 446 | ] 447 | 448 | [[package]] 449 | name = "serde_json" 450 | version = "1.0.48" 451 | source = "registry+https://github.com/rust-lang/crates.io-index" 452 | dependencies = [ 453 | "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", 454 | "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 455 | "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 456 | ] 457 | 458 | [[package]] 459 | name = "sha-1" 460 | version = "0.8.2" 461 | source = "registry+https://github.com/rust-lang/crates.io-index" 462 | dependencies = [ 463 | "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", 464 | "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", 465 | "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 466 | "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 467 | ] 468 | 469 | [[package]] 470 | name = "strsim" 471 | version = "0.8.0" 472 | source = "registry+https://github.com/rust-lang/crates.io-index" 473 | 474 | [[package]] 475 | name = "syn" 476 | version = "1.0.14" 477 | source = "registry+https://github.com/rust-lang/crates.io-index" 478 | dependencies = [ 479 | "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", 480 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 481 | "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 482 | ] 483 | 484 | [[package]] 485 | name = "synstructure" 486 | version = "0.12.3" 487 | source = "registry+https://github.com/rust-lang/crates.io-index" 488 | dependencies = [ 489 | "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", 490 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 491 | "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", 492 | "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 493 | ] 494 | 495 | [[package]] 496 | name = "tempdir" 497 | version = "0.3.7" 498 | source = "registry+https://github.com/rust-lang/crates.io-index" 499 | dependencies = [ 500 | "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 501 | "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", 502 | ] 503 | 504 | [[package]] 505 | name = "termcolor" 506 | version = "1.1.0" 507 | source = "registry+https://github.com/rust-lang/crates.io-index" 508 | dependencies = [ 509 | "winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 510 | ] 511 | 512 | [[package]] 513 | name = "textwrap" 514 | version = "0.11.0" 515 | source = "registry+https://github.com/rust-lang/crates.io-index" 516 | dependencies = [ 517 | "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", 518 | ] 519 | 520 | [[package]] 521 | name = "thread_local" 522 | version = "1.0.1" 523 | source = "registry+https://github.com/rust-lang/crates.io-index" 524 | dependencies = [ 525 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 526 | ] 527 | 528 | [[package]] 529 | name = "typenum" 530 | version = "1.11.2" 531 | source = "registry+https://github.com/rust-lang/crates.io-index" 532 | 533 | [[package]] 534 | name = "ucd-trie" 535 | version = "0.1.2" 536 | source = "registry+https://github.com/rust-lang/crates.io-index" 537 | 538 | [[package]] 539 | name = "unicode-width" 540 | version = "0.1.7" 541 | source = "registry+https://github.com/rust-lang/crates.io-index" 542 | 543 | [[package]] 544 | name = "unicode-xid" 545 | version = "0.2.0" 546 | source = "registry+https://github.com/rust-lang/crates.io-index" 547 | 548 | [[package]] 549 | name = "vec_map" 550 | version = "0.8.1" 551 | source = "registry+https://github.com/rust-lang/crates.io-index" 552 | 553 | [[package]] 554 | name = "walkdir" 555 | version = "0.1.8" 556 | source = "registry+https://github.com/rust-lang/crates.io-index" 557 | dependencies = [ 558 | "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 559 | "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 560 | ] 561 | 562 | [[package]] 563 | name = "which" 564 | version = "3.1.0" 565 | source = "registry+https://github.com/rust-lang/crates.io-index" 566 | dependencies = [ 567 | "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 568 | "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", 569 | ] 570 | 571 | [[package]] 572 | name = "winapi" 573 | version = "0.2.8" 574 | source = "registry+https://github.com/rust-lang/crates.io-index" 575 | 576 | [[package]] 577 | name = "winapi" 578 | version = "0.3.8" 579 | source = "registry+https://github.com/rust-lang/crates.io-index" 580 | dependencies = [ 581 | "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 582 | "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 583 | ] 584 | 585 | [[package]] 586 | name = "winapi-build" 587 | version = "0.1.1" 588 | source = "registry+https://github.com/rust-lang/crates.io-index" 589 | 590 | [[package]] 591 | name = "winapi-i686-pc-windows-gnu" 592 | version = "0.4.0" 593 | source = "registry+https://github.com/rust-lang/crates.io-index" 594 | 595 | [[package]] 596 | name = "winapi-util" 597 | version = "0.1.3" 598 | source = "registry+https://github.com/rust-lang/crates.io-index" 599 | dependencies = [ 600 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 601 | ] 602 | 603 | [[package]] 604 | name = "winapi-x86_64-pc-windows-gnu" 605 | version = "0.4.0" 606 | source = "registry+https://github.com/rust-lang/crates.io-index" 607 | 608 | [metadata] 609 | "checksum aho-corasick 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "743ad5a418686aad3b87fd14c43badd828cf26e214a00f92a384291cf22e1811" 610 | "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" 611 | "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 612 | "checksum backtrace 0.3.44 (registry+https://github.com/rust-lang/crates.io-index)" = "e4036b9bf40f3cf16aba72a3d65e8a520fc4bafcdc7079aea8f848c58c5b5536" 613 | "checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" 614 | "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" 615 | "checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" 616 | "checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" 617 | "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" 618 | "checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" 619 | "checksum cargo-pack 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f14d7805a786dcf2c400896b6852a4210d5b9ce6f04a99c9386296ef8ec949d9" 620 | "checksum cargo_metadata 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "46e3374c604fb39d1a2f35ed5e4a4e30e60d01fab49446e08f1b3e9a90aef202" 621 | "checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" 622 | "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" 623 | "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" 624 | "checksum copy_dir 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6e4281031634644843bd2f5aa9c48cf98fc48d6b083bd90bb11becf10deaf8b0" 625 | "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" 626 | "checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" 627 | "checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" 628 | "checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" 629 | "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" 630 | "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" 631 | "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" 632 | "checksum handlebars 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ba758d094d31274eb49d15da6f326b96bf3185239a6359bf684f3d5321148900" 633 | "checksum hermit-abi 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e2c55f143919fbc0bc77e427fe2d74cf23786d7c1875666f2fde3ac3c659bb67" 634 | "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" 635 | "checksum itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" 636 | "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" 637 | "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 638 | "checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" 639 | "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" 640 | "checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" 641 | "checksum memchr 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53445de381a1f436797497c61d851644d0e8e88e6140f22872ad33a704933978" 642 | "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" 643 | "checksum pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e4fb201c5c22a55d8b24fef95f78be52738e5e1361129be1b5e862ecdb6894a" 644 | "checksum pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" 645 | "checksum pest_generator 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9fcf299b5712d06ee128a556c94709aaa04512c4dffb8ead07c5c998447fc0" 646 | "checksum pest_meta 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "df43fd99896fd72c485fe47542c7b500e4ac1e8700bf995544d1317a60ded547" 647 | "checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" 648 | "checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" 649 | "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" 650 | "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" 651 | "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" 652 | "checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" 653 | "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" 654 | "checksum regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8" 655 | "checksum regex-syntax 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)" = "b28dfe3fe9badec5dbf0a79a9cccad2cfc2ab5484bdb3e44cbd1ae8b3ba2be06" 656 | "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" 657 | "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" 658 | "checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" 659 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 660 | "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 661 | "checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" 662 | "checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" 663 | "checksum serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "9371ade75d4c2d6cb154141b9752cf3781ec9c05e0e5cf35060e1e70ee7b9c25" 664 | "checksum sha-1 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" 665 | "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" 666 | "checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" 667 | "checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" 668 | "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" 669 | "checksum termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" 670 | "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" 671 | "checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" 672 | "checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" 673 | "checksum ucd-trie 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8f00ed7be0c1ff1e24f46c3d2af4859f7e863672ba3a6e92e7cff702bf9f06c2" 674 | "checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" 675 | "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" 676 | "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" 677 | "checksum walkdir 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c66c0b9792f0a765345452775f3adbd28dde9d33f30d13e5dcc5ae17cf6f3780" 678 | "checksum which 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5475d47078209a02e60614f7ba5e645ef3ed60f771920ac1906d7c1cc65024c8" 679 | "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" 680 | "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" 681 | "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" 682 | "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 683 | "checksum winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80" 684 | "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 685 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Sunrin SHIMURA (keen) <3han5chou7@gmail.com>"] 3 | name = "cargo-pack-docker" 4 | version = "0.5.0" 5 | description = "pack artifacts into a docker image" 6 | repository = "https://github.com/KeenS/cargo-pack-docker" 7 | license = "MIT/Apache-2.0" 8 | categories = ["development-tools"] 9 | keywords = ["cargo-subcommand", "cargo"] 10 | readme = "README.md" 11 | edition = "2018" 12 | 13 | [dependencies] 14 | clap = "2" 15 | copy_dir = "0.1.2" 16 | env_logger = "0.7" 17 | handlebars = "3.0" 18 | log = "0.4" 19 | serde = { version = "1.0", features = ["derive"]} 20 | semver = "0.9.0" 21 | tempdir = "0.3.5" 22 | which = "3.0.0" 23 | cargo-pack = "0.6" 24 | failure = "0.1.1" 25 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rust:1.41.0-stretch 2 | ENV CARGO_PACK_DOKCER_VERSION 0.5.0 3 | ENV DOCKER_VERSION 18.03.1-ce 4 | RUN wget -q https://github.com/KeenS/cargo-pack-docker/releases/download/v${CARGO_PACK_DOKCER_VERSION}/cargo-pack-docker-v${CARGO_PACK_DOKCER_VERSION}-x86_64-unknown-linux-gnu.tar.gz && \ 5 | tar xzf cargo-pack-docker-v${CARGO_PACK_DOKCER_VERSION}-x86_64-unknown-linux-gnu.tar.gz && \ 6 | install cargo-pack-docker /usr/local/bin && \ 7 | rm -rf cargo-pack-docker cargo-pack-docker-v${CARGO_PACK_DOKCER_VERSION}-x86_64-unknown-linux-gnu.tar.gz 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/KeenS/cargo-pack-docker.svg?branch=master)](https://travis-ci.org/KeenS/cargo-pack-docker) 2 | [![Build status](https://ci.appveyor.com/api/projects/status/doa9noawxji7uy1v/branch/master?svg=true)](https://ci.appveyor.com/project/KeenS/cargo-pack-docker/branch/master) 3 | 4 | 5 | 6 | # cargo-pack-docker 7 | A [`cargo-pack`](https://github.com/KeenS/cargo-pack)er for docker; package your application into a docker image to deploy without Dockerfile 8 | 9 | THIS PRODUCT IS ALPHA STATUS. USE AT YOUR OWN RISK 10 | # install 11 | 12 | ## Built binary 13 | 14 | see releases 15 | 16 | ## building 17 | 18 | ``` 19 | cargo install cargo-pack-docker 20 | ``` 21 | 22 | # Usage 23 | 24 | ``` 25 | cargo pack-docker [-p package] [--release] [TAG] 26 | # if your configurated tag in Cargo.toml is hoge:0.1.0, the TAG will be hoge 27 | # if TAG is omitted and you have only one `[[package.metadata.pack.docker]]` section, it will be used 28 | ``` 29 | 30 | # Configulation 31 | 32 | 33 | ``` toml 34 | # configuration of cargo-pack 35 | [package.metadata.pack] 36 | default-packers = ["docker"] 37 | # files will be placet to /opt/app 38 | files = ["README.md"] 39 | 40 | # configuration of cargo-pack-docker 41 | [[package.metadata.pack.docker]] 42 | # tag of the created image. Can be omitted. 43 | # Default to PACKAGE_NAME:latest for debug profile 44 | # and PACKAGE_NAME:PACKAGE_VERSION for release profile 45 | tag = "hoge:0.1.0" 46 | # base image of the docker image. Required. 47 | base-image = "ubuntu:16.04" 48 | # the bin to include into the docker image. 49 | # will be placed to /opt/app/bin/ 50 | # can be omitted if the project have only one binary target. 51 | bin = "aaa" 52 | # `ENTRYPOINT` of Dockerfile. optional. 53 | entrypoint = ["aa", "bb"] 54 | # `CMD` of Dockerfile. optional. 55 | cmd = ["c", "d"] 56 | # inject command into the Dockerfile. optional 57 | inject = " 58 | ENV RUST_LOG debug 59 | RUN apt install libpq-dev 60 | " 61 | 62 | # you can write another configuration 63 | [[package.metadata.pack.docker]] 64 | base-image = "ubuntu:16.04" 65 | bin = "bbb" 66 | ``` 67 | 68 | with the first configuration, build a docker image with this Dockerfile content: 69 | 70 | ``` 71 | FROM ubuntu:16.04 72 | 73 | RUN mkdir -p /opt/app/bin 74 | COPY README.md /opt/app 75 | COPY aaa /opt/app/bin 76 | WORKDIR /opt/app 77 | 78 | ENV RUST_LOG debug 79 | RUN apt install libpq-dev 80 | 81 | 82 | ENTRYPOINT ["aa", "bb"] 83 | CMD ["c", "d"] 84 | 85 | ``` 86 | 87 | # Running cargo-pack-docker in docker 88 | 89 | There are images 90 | 91 | [blackenedgold/cargo-pack-docker](https://hub.docker.com/r/blackenedgold/cargo-pack-docker/) 92 | . 93 | 94 | To build a docker image using the cargo-pack-docker docker image, run this command. 95 | 96 | ``` console 97 | docker run \ 98 | -v /var/run/docker.sock:/var/run/docker.sock \ 99 | -v `which docker`:/usr//bin/docker \ 100 | -v $(pwd):/tmp/app \ 101 | -w /tmp/app 102 | blackenedgold/cargo-pack-docker \ 103 | cargo pack-docker 104 | ``` 105 | 106 | 107 | and if you prefer docker-compose, use this yaml fragment. 108 | 109 | ``` yaml 110 | build: 111 | image: blackenedgold/cargo-pack-docker:0.4.0-rust-1.32.0 112 | command: cargo pack-docker 113 | working_dir: /tmp/app 114 | volumes: 115 | - ./ /tmp/app 116 | - /var/run/docker.sock:/var/run/docker.sock 117 | # your path to docker 118 | - /usr/bin/docker:/usr/bin/docker 119 | 120 | ``` 121 | 122 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # Based on the "trust" template v0.1.2 2 | # https://github.com/japaric/trust/tree/v0.1.2 3 | 4 | environment: 5 | global: 6 | RUST_VERSION: stable 7 | 8 | CRATE_NAME: cargo-pack-docker 9 | 10 | matrix: 11 | # MinGW 12 | - TARGET: i686-pc-windows-gnu 13 | - TARGET: x86_64-pc-windows-gnu 14 | 15 | # MSVC 16 | - TARGET: i686-pc-windows-msvc 17 | - TARGET: x86_64-pc-windows-msvc 18 | 19 | # Testing other channels 20 | - TARGET: x86_64-pc-windows-gnu 21 | RUST_VERSION: nightly 22 | - TARGET: x86_64-pc-windows-msvc 23 | RUST_VERSION: nightly 24 | 25 | install: 26 | - ps: >- 27 | If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') { 28 | $Env:PATH += ';C:\msys64\mingw64\bin' 29 | } ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') { 30 | $Env:PATH += ';C:\msys64\mingw32\bin' 31 | } 32 | - curl -sSf -o rustup-init.exe https://win.rustup.rs/ 33 | - rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION% 34 | - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin 35 | - rustc -Vv 36 | - cargo -V 37 | 38 | test_script: 39 | # we don't run the "test phase" when doing deploys 40 | - if [%APPVEYOR_REPO_TAG%]==[false] ( 41 | cargo build --target %TARGET% --release && 42 | cargo test --target %TARGET% --release 43 | ) 44 | 45 | before_deploy: 46 | - cargo rustc --target %TARGET% --release 47 | - ps: ci\before_deploy.ps1 48 | 49 | deploy: 50 | artifact: /.*\.zip/ 51 | auth_token: 52 | secure: rt17ehMwGFhxW5RvFl1D4WirAwPbOihH3M2PpFua1kRYEYa4KGFrSJFY/n/u1a8z 53 | description: '' 54 | on: 55 | RUST_VERSION: stable 56 | appveyor_repo_tag: true 57 | provider: GitHub 58 | 59 | cache: 60 | - C:\Users\appveyor\.cargo\registry 61 | - target 62 | 63 | branches: 64 | only: 65 | # Release tags 66 | - /^v\d+\.\d+\.\d+.*$/ 67 | - master 68 | 69 | notifications: 70 | - provider: Email 71 | on_build_success: false 72 | 73 | # Building is done in the test phase, so we disable Appveyor's build phase. 74 | build: false 75 | -------------------------------------------------------------------------------- /ci/before_deploy.ps1: -------------------------------------------------------------------------------- 1 | # This script takes care of packaging the build artifacts that will go in the 2 | # release zipfile 3 | 4 | $SRC_DIR = $PWD.Path 5 | $STAGE = [System.Guid]::NewGuid().ToString() 6 | 7 | Set-Location $ENV:Temp 8 | New-Item -Type Directory -Name $STAGE 9 | Set-Location $STAGE 10 | 11 | $ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip" 12 | 13 | Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\cargo-pack-docker.exe" '.\' 14 | 15 | 7z a "$ZIP" * 16 | 17 | Push-AppveyorArtifact "$ZIP" 18 | 19 | Remove-Item *.* -Force 20 | Set-Location .. 21 | Remove-Item $STAGE 22 | Set-Location $SRC_DIR 23 | -------------------------------------------------------------------------------- /ci/before_deploy.sh: -------------------------------------------------------------------------------- 1 | # This script takes care of building your crate and packaging it for release 2 | 3 | set -ex 4 | 5 | main() { 6 | local src=$(pwd) \ 7 | stage= 8 | 9 | case $TRAVIS_OS_NAME in 10 | linux) 11 | stage=$(mktemp -d) 12 | ;; 13 | osx) 14 | stage=$(mktemp -d -t tmp) 15 | ;; 16 | esac 17 | 18 | test -f Cargo.lock || cargo generate-lockfile 19 | 20 | cross rustc --target $TARGET --release 21 | 22 | cp target/$TARGET/release/cargo-pack-docker $stage/ 23 | 24 | cd $stage 25 | tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz * 26 | cd $src 27 | 28 | rm -rf $stage 29 | } 30 | 31 | main 32 | -------------------------------------------------------------------------------- /ci/install.sh: -------------------------------------------------------------------------------- 1 | set -ex 2 | 3 | main() { 4 | local target= 5 | if [ $TRAVIS_OS_NAME = linux ]; then 6 | target=x86_64-unknown-linux-musl 7 | sort=sort 8 | else 9 | target=x86_64-apple-darwin 10 | sort=gsort # for `sort --sort-version`, from brew's coreutils. 11 | fi 12 | 13 | # Builds for iOS are done on OSX, but require the specific target to be 14 | # installed. 15 | case $TARGET in 16 | aarch64-apple-ios) 17 | rustup target install aarch64-apple-ios 18 | ;; 19 | armv7-apple-ios) 20 | rustup target install armv7-apple-ios 21 | ;; 22 | armv7s-apple-ios) 23 | rustup target install armv7s-apple-ios 24 | ;; 25 | i386-apple-ios) 26 | rustup target install i386-apple-ios 27 | ;; 28 | x86_64-apple-ios) 29 | rustup target install x86_64-apple-ios 30 | ;; 31 | esac 32 | 33 | # This fetches latest stable release 34 | local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \ 35 | | cut -d/ -f3 \ 36 | | grep -E '^v[0.1.0-9.]+$' \ 37 | | $sort --version-sort \ 38 | | tail -n1) 39 | curl -LSfs https://japaric.github.io/trust/install.sh | \ 40 | sh -s -- \ 41 | --force \ 42 | --git japaric/cross \ 43 | --tag $tag \ 44 | --target $target 45 | } 46 | 47 | main 48 | -------------------------------------------------------------------------------- /ci/script.sh: -------------------------------------------------------------------------------- 1 | # This script takes care of testing your crate 2 | 3 | set -ex 4 | 5 | main() { 6 | cross build --target $TARGET --release 7 | 8 | if [ ! -z $DISABLE_TESTS ]; then 9 | return 10 | fi 11 | 12 | cross test --target $TARGET --release 13 | 14 | } 15 | 16 | # we don't run the "test phase" when doing deploys 17 | if [ -z $TRAVIS_TAG ]; then 18 | main 19 | fi 20 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KeenS/cargo-pack-docker/55c305bf9ee66834ac17edeb9a9d4a37a5f7a6b1/rustfmt.toml -------------------------------------------------------------------------------- /src/docker.rs: -------------------------------------------------------------------------------- 1 | use crate::error::*; 2 | use cargo_pack::CargoPack; 3 | use copy_dir; 4 | use failure::format_err; 5 | use handlebars::{no_escape, Handlebars}; 6 | use log::debug; 7 | use serde::{Deserialize, Serialize}; 8 | use std::fs; 9 | use std::fs::File; 10 | use std::io::{BufWriter, Write}; 11 | use std::path::Path; 12 | use std::process::Command; 13 | use tempdir::TempDir; 14 | 15 | #[derive(Deserialize, Debug)] 16 | #[serde(rename_all = "kebab-case")] 17 | pub struct PackDocker { 18 | entrypoint: Option>, 19 | cmd: Option>, 20 | base_image: String, 21 | bin: Option, 22 | inject: Option, 23 | tag: Option, 24 | } 25 | 26 | #[derive(Deserialize, Debug)] 27 | pub struct PackDockerConfig { 28 | docker: Vec, 29 | } 30 | 31 | // assuming single bin. 32 | pub struct Docker { 33 | config: PackDockerConfig, 34 | pack: CargoPack, 35 | tags: Vec, 36 | is_release: bool, 37 | } 38 | 39 | #[derive(Deserialize, Serialize, Debug)] 40 | pub struct DockerfileConfig { 41 | entrypoint: Option, 42 | cmd: Option, 43 | baseimage: String, 44 | files: Vec, 45 | bin: String, 46 | inject: String, 47 | } 48 | 49 | impl PackDocker { 50 | fn base_name(&self, docker: &Docker) -> Result { 51 | self.tag(docker).map(|name| { 52 | name.rsplitn(2, ':') 53 | .last() 54 | // should be safe but not confident 55 | .unwrap() 56 | .to_string() 57 | }) 58 | } 59 | 60 | fn bin_name<'a>(&'a self, docker: &'a Docker) -> Result<&'a str> { 61 | let bins = docker 62 | .pack 63 | .package()? 64 | .targets 65 | .iter() 66 | .filter(|t| t.kind.contains(&"bin".to_string())) 67 | .map(|t| &t.name) 68 | .collect::>(); 69 | 70 | if let Some(name) = self.bin.as_ref() { 71 | if bins.contains(&name) { 72 | return Ok(name); 73 | } else { 74 | return Err(Error::BinNotFound(name.clone()).into()); 75 | } 76 | } 77 | match bins.len() { 78 | 0 => Err(Error::NoBins.into()), 79 | 1 => Ok(bins.get(0).unwrap()), 80 | _ => Err(Error::AmbiguousBinName(bins.into_iter().map(Into::into).collect()).into()), 81 | } 82 | } 83 | 84 | fn tag(&self, docker: &Docker) -> Result { 85 | if let Some(ref tag) = self.tag { 86 | Ok(tag.to_string()) 87 | } else { 88 | let bin_name = self.bin_name(docker)?; 89 | let package = docker.pack.package().unwrap(); 90 | let version = if docker.is_release { 91 | package.version.to_string() 92 | } else { 93 | "latest".to_string() 94 | }; 95 | Ok(format!("{}:{}", bin_name, version)) 96 | } 97 | } 98 | } 99 | 100 | impl<'cfg> Docker { 101 | pub fn new( 102 | config: PackDockerConfig, 103 | pack: CargoPack, 104 | tags: Vec, 105 | is_release: bool, 106 | ) -> Self { 107 | Docker { 108 | config, 109 | pack, 110 | tags, 111 | is_release, 112 | } 113 | } 114 | 115 | pub fn pack(&self) -> Result<()> { 116 | debug!("tags: {:?}, config: {:?}", self.tags, self.config); 117 | debug!("workspace: {:?}", self.pack.package()); 118 | debug!("preparing"); 119 | for pack_docker in self.targets() { 120 | let tmpdir = self.prepare(pack_docker)?; 121 | debug!("building a image"); 122 | self.build(tmpdir, pack_docker)?; 123 | } 124 | Ok(()) 125 | } 126 | 127 | fn prepare(&self, pack_docker: &PackDocker) -> Result { 128 | let tmp = TempDir::new("cargo-pack-docker")?; 129 | debug!("created: {:?}", tmp); 130 | self.copy_files(&tmp)?; 131 | let bin = self.add_bin(&tmp, pack_docker)?; 132 | let data = DockerfileConfig { 133 | entrypoint: pack_docker.entrypoint.as_ref().map(|e| { 134 | e.iter() 135 | .map(|s| format!("\"{}\"", s)) 136 | .collect::>() 137 | .join(", ") 138 | }), 139 | cmd: pack_docker.cmd.as_ref().map(|c| { 140 | c.iter() 141 | .map(|s| format!("\"{}\"", s)) 142 | .collect::>() 143 | .join(", ") 144 | }), 145 | baseimage: pack_docker.base_image.clone(), 146 | files: self.pack.files().into(), 147 | bin: bin, 148 | inject: pack_docker 149 | .inject 150 | .as_ref() 151 | .map(|s| s.as_ref()) 152 | .unwrap_or("") 153 | .to_string(), 154 | }; 155 | self.gen_dockerfile(&tmp, &data)?; 156 | Ok(tmp) 157 | } 158 | 159 | fn build>(&self, path: P, pack_docker: &PackDocker) -> Result<()> { 160 | let image_tag = pack_docker.tag(self)?; 161 | // FIXME: take from user 162 | let dockerbin = ::which::which("docker")?; 163 | let status = Command::new(dockerbin) 164 | .current_dir(&path) 165 | .arg("build") 166 | .arg(path.as_ref().to_str().unwrap()) 167 | .args(&["-t", image_tag.as_str()]) 168 | .spawn()? 169 | .wait()?; 170 | 171 | if status.success() { 172 | Ok(()) 173 | } else { 174 | Err(format_err!("docker command faild")) 175 | } 176 | } 177 | 178 | fn copy_files>(&self, path: P) -> Result<()> { 179 | for file in self.pack.files() { 180 | let to = path.as_ref().join(file); 181 | debug!("copying file: from {:?} to {:?}", file, to); 182 | copy_dir::copy_dir(file, to)?; 183 | } 184 | Ok(()) 185 | } 186 | 187 | fn add_bin>(&self, path: P, pack_docker: &PackDocker) -> Result { 188 | let name = pack_docker.bin_name(self)?; 189 | let from = if self.is_release { 190 | self.pack 191 | .metadata() 192 | .target_directory 193 | .join("release") 194 | .join(&name) 195 | } else { 196 | self.pack 197 | .metadata() 198 | .target_directory 199 | .join("debug") 200 | .join(&name) 201 | }; 202 | 203 | let to = path.as_ref().join(&name); 204 | debug!("copying file: from {:?} to {:?}", from, to); 205 | fs::copy(from, to)?; 206 | Ok(name.into()) 207 | } 208 | 209 | fn targets(&self) -> Vec<&PackDocker> { 210 | if self.tags.len() == 0 { 211 | self.config.docker.iter().collect() 212 | } else { 213 | // TODO: warn non existing tags 214 | self.config 215 | .docker 216 | .iter() 217 | .filter(|p| { 218 | p.base_name(&self) 219 | .map(|name| self.tags.contains(&name)) 220 | .unwrap_or(false) 221 | }) 222 | .collect() 223 | } 224 | } 225 | 226 | fn gen_dockerfile>(&self, path: P, data: &DockerfileConfig) -> Result<()> { 227 | let dockerfile = path.as_ref().join("Dockerfile"); 228 | debug!("generating {:?}", dockerfile); 229 | let file = File::create(dockerfile)?; 230 | debug!("Dockerfile creation succeeded."); 231 | debug!("templating with {:?}", data); 232 | let mut buf = BufWriter::new(file); 233 | let template = r#" 234 | FROM {{ baseimage }} 235 | 236 | RUN mkdir -p /opt/app/bin 237 | {{#each files as |file| ~}} 238 | COPY {{ file }} /opt/app 239 | {{/each~}} 240 | COPY {{bin}} /opt/app/bin 241 | WORKDIR /opt/app 242 | 243 | {{inject}} 244 | 245 | {{#if entrypoint ~}} 246 | ENTRYPOINT [{{entrypoint}}] 247 | {{else ~}} 248 | ENTRYPOINT ["/opt/app/bin/{{bin}}"] 249 | {{/if ~}} 250 | {{#if cmd ~}} 251 | CMD [{{cmd}}] 252 | {{/if}} 253 | "#; 254 | let mut handlebars = Handlebars::new(); 255 | 256 | handlebars.register_escape_fn(no_escape); 257 | handlebars 258 | .register_template_string("dockerfile", template) 259 | .expect("internal error: illegal template"); 260 | 261 | handlebars 262 | .render_to_write("dockerfile", data, &mut buf) 263 | .unwrap(); 264 | debug!("templating done"); 265 | let _ = buf.flush()?; 266 | debug!( 267 | "content:{}", 268 | fs::read_to_string(path.as_ref().join("Dockerfile"))? 269 | ); 270 | 271 | Ok(()) 272 | } 273 | } 274 | // mktmpdir 275 | // cp files to tmpdir 276 | // output Dockerfile 277 | // docker build -f Dockerfile ./ 278 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #![deny(dead_code)] 2 | 3 | pub mod docker; 4 | pub use crate::docker::*; 5 | 6 | mod error { 7 | use failure::Fail; 8 | 9 | #[derive(Debug, Fail)] 10 | pub enum Error { 11 | #[fail(display = "No bins found. Cargo pack-docker only operates on bin crates")] 12 | NoBins, 13 | #[fail(display = "ambiguous bin name: {:?}", _0)] 14 | AmbiguousBinName(Vec), 15 | #[fail(display = "bin '{}' doesn't exist", _0)] 16 | BinNotFound(String), 17 | } 18 | pub type Result = ::std::result::Result; 19 | } 20 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use cargo_pack::CargoPack; 2 | use cargo_pack_docker::{Docker, PackDockerConfig}; 3 | use clap::{App, Arg, SubCommand}; 4 | use log::debug; 5 | use std::process::Command; 6 | 7 | fn doit(package: Option, is_release: bool, is_no_build: bool, tag: Option<&str>) { 8 | let pack = CargoPack::new(package.clone()).expect("initializing cargo-pack failed"); 9 | let package = package.into_iter().collect::>(); 10 | if !is_no_build { 11 | let build_mode = if is_release { "--release" } else { "--debug" }; 12 | let mut build_options = package 13 | .iter() 14 | .flat_map(|name| vec!["--package", name]) 15 | .collect::>(); 16 | build_options.push(build_mode); 17 | let mut args = vec!["build"]; 18 | args.append(&mut build_options); 19 | let mut cmd = Command::new("cargo"); 20 | let cmd = cmd.args(&args); 21 | debug!("running command {:?}", cmd); 22 | match cmd.status() { 23 | Ok(_) => (), 24 | Err(e) => { 25 | eprintln!("failed to build: {}", e); 26 | return; 27 | } 28 | } 29 | } 30 | 31 | let docker_config: PackDockerConfig = pack 32 | .decode_from_manifest() 33 | .expect("decoding pack-docker config failed"); 34 | debug!("using docker config {:?}", docker_config); 35 | let docker = Docker::new( 36 | docker_config, 37 | pack, 38 | tag.into_iter().map(|tag| tag.to_string()).collect(), 39 | is_release, 40 | ); 41 | docker.pack().expect("pack failed"); 42 | } 43 | 44 | fn main() { 45 | env_logger::init(); 46 | let opts = App::new("cargo") 47 | .subcommand( 48 | SubCommand::with_name("pack-docker") 49 | .version(env!("CARGO_PKG_VERSION")) 50 | .about(env!("CARGO_PKG_DESCRIPTION")) 51 | .author("κeen") 52 | .arg( 53 | Arg::with_name("package") 54 | .help("parent package to pack") 55 | .takes_value(true) 56 | .multiple(true) 57 | .short("p") 58 | .long("package"), 59 | ) 60 | .arg( 61 | Arg::with_name("release") 62 | .help("build with release profile") 63 | .long("release"), 64 | ) 65 | .arg( 66 | Arg::with_name("no-build") 67 | .help("do not build rust before packing the docker image") 68 | .long("no-build"), 69 | ) 70 | .arg(Arg::with_name("TAG").help("tag of the docker image to build")), 71 | ) 72 | .get_matches(); 73 | 74 | let opts = opts 75 | .subcommand_matches("pack-docker") 76 | .expect("cargo-pack-docker must be used as a subcommand"); 77 | let tag = opts.value_of("TAG"); 78 | let packages = opts 79 | .values_of("package") 80 | .map(|vs| vs.into_iter().map(|p| p.to_string()).collect::>()); 81 | let is_release = opts.is_present("release"); 82 | let is_no_build = opts.is_present("no-build"); 83 | debug!( 84 | "tag: {:?}, package: {:?}, is_release: {:?}", 85 | tag, packages, is_release 86 | ); 87 | match packages { 88 | None => doit(None, is_release, is_no_build, tag), 89 | Some(packages) => { 90 | for package in packages { 91 | doit(Some(package), is_release, is_no_build, tag); 92 | } 93 | } 94 | } 95 | } 96 | --------------------------------------------------------------------------------