diff --git a/Cargo.lock b/Cargo.lock index caeaca3..4cdbb00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aho-corasick" version = "1.1.2" @@ -11,6 +17,28 @@ dependencies = [ "memchr", ] +[[package]] +name = "ascii_table" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c2bee9b9ee0e5768772e38c07ef0ba23a490d7e1336ec7207c25712a2661c55" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "bit-set" version = "0.5.3" @@ -26,12 +54,27 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "bstr" version = "1.9.0" @@ -46,10 +89,22 @@ dependencies = [ name = "buildpacks-apt" version = "0.0.0" dependencies = [ - "libcnb", + "commons", + "indoc", + "libcnb 0.18.0", "libcnb-test", ] +[[package]] +name = "byte-unit" +version = "4.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da78b32057b8fdfc352504708feeba7216dcd65a2c9ab02978cbd288d1279b6c" +dependencies = [ + "serde", + "utf8-width", +] + [[package]] name = "camino" version = "1.1.6" @@ -82,12 +137,84 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "commons" +version = "0.0.0" +source = "git+https://github.com/heroku/buildpacks-ruby?branch=main#dda4ede413fc3fe4d6d2f2f63f039c7c1e5cc5fd" +dependencies = [ + "ascii_table", + "byte-unit", + "const_format", + "fancy-regex 0.13.0", + "fs-err", + "fs_extra", + "fun_run", + "glob", + "indoc", + "lazy_static", + "libcnb 0.17.0", + "libherokubuildpack", + "regex", + "serde", + "sha2", + "tempfile", + "thiserror", + "walkdir", +] + +[[package]] +name = "const_format" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -113,6 +240,26 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "either" version = "1.9.0" @@ -132,7 +279,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "fancy-regex" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7493d4c459da9f84325ad297371a6b2b8a162800873a22e3b6b6512e61d18c05" +dependencies = [ + "bit-set", + "regex", ] [[package]] @@ -152,24 +309,102 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +[[package]] +name = "filetime" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "windows-sys 0.52.0", +] + [[package]] name = "fixedbitset" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "libz-sys", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs-err" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" +dependencies = [ + "autocfg", +] + [[package]] name = "fs_extra" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" +[[package]] +name = "fun_run" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f1c09c4db8c8f60b5ab97bddf2e93a458ee43d65c6e02f9a4643b07159d4962" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "globset" version = "0.4.14" @@ -195,7 +430,17 @@ version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", ] [[package]] @@ -248,15 +493,40 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libcnb" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c385c618fa8afebe2d1b499b74bc0a3682507b0d91aa4aad09708b81681e2ca" +dependencies = [ + "libcnb-common 0.17.0", + "libcnb-data 0.17.0", + "libcnb-proc-macros 0.17.0", + "serde", + "thiserror", + "toml", +] + [[package]] name = "libcnb" version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01a3489808fbae57c1b5a66a4c38062cb1baa66548a4a1c738f297e7a29df944" dependencies = [ - "libcnb-common", - "libcnb-data", - "libcnb-proc-macros", + "libcnb-common 0.18.0", + "libcnb-data 0.18.0", + "libcnb-proc-macros 0.18.0", + "serde", + "thiserror", + "toml", +] + +[[package]] +name = "libcnb-common" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28fede7cd4353004ff1976ce66c34bb266fa35095be12c6d3d4c2358ef790778" +dependencies = [ "serde", "thiserror", "toml", @@ -273,14 +543,28 @@ dependencies = [ "toml", ] +[[package]] +name = "libcnb-data" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20c0c825002ee57279d0c9e23309863804536f0c45687436d574dd3e8c7420fb" +dependencies = [ + "fancy-regex 0.12.0", + "libcnb-proc-macros 0.17.0", + "serde", + "thiserror", + "toml", + "uriparse", +] + [[package]] name = "libcnb-data" version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baab61150f401f2570a338993e667ce2c5988e2df6c1fa95ef359953fa24ac02" dependencies = [ - "fancy-regex", - "libcnb-proc-macros", + "fancy-regex 0.13.0", + "libcnb-proc-macros 0.18.0", "serde", "thiserror", "toml", @@ -296,14 +580,26 @@ dependencies = [ "cargo_metadata", "ignore", "indoc", - "libcnb-common", - "libcnb-data", + "libcnb-common 0.18.0", + "libcnb-data 0.18.0", "petgraph", "thiserror", "uriparse", "which", ] +[[package]] +name = "libcnb-proc-macros" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f0afde3a7327936afd743e2cb52f6de3a0d4a4894f6f13bdae1a41e6879c17" +dependencies = [ + "cargo_metadata", + "fancy-regex 0.12.0", + "quote", + "syn", +] + [[package]] name = "libcnb-proc-macros" version = "0.18.0" @@ -311,7 +607,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d45827270d4493f5634a96fdc1238653fb00b12abc1b6fc4d1e7ed920f3785b" dependencies = [ "cargo_metadata", - "fancy-regex", + "fancy-regex 0.13.0", "quote", "syn", ] @@ -324,13 +620,42 @@ checksum = "d89d3c16306a2719734316cc523dc6320112d6d51121392324a4afde7ea64366" dependencies = [ "fastrand", "fs_extra", - "libcnb-common", - "libcnb-data", + "libcnb-common 0.18.0", + "libcnb-data 0.18.0", "libcnb-package", "tempfile", "thiserror", ] +[[package]] +name = "libherokubuildpack" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e800ca80376b707d57d55ea95f48c88d2621864a0250cc41f54eab8e9481887" +dependencies = [ + "crossbeam-utils", + "flate2", + "libcnb 0.17.0", + "pathdiff", + "sha2", + "tar", + "termcolor", + "thiserror", + "toml", + "ureq", +] + +[[package]] +name = "libz-sys" +version = "1.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037731f5d3aaa87a5675e895b63ddff1a87624bc29f77004ea829809654e48f6" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linux-raw-sys" version = "0.4.13" @@ -349,12 +674,33 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +[[package]] +name = "miniz_oxide" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +dependencies = [ + "adler", +] + [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + [[package]] name = "petgraph" version = "0.6.4" @@ -365,6 +711,12 @@ dependencies = [ "indexmap", ] +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + [[package]] name = "proc-macro2" version = "1.0.78" @@ -383,6 +735,27 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "regex" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + [[package]] name = "regex-automata" version = "0.4.5" @@ -400,17 +773,62 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "ring" +version = "0.17.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +dependencies = [ + "cc", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.48.0", +] + [[package]] name = "rustix" version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags", + "bitflags 2.4.2", "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "048a63e5b3ac996d78d402940b5fa47973d2d080c6c6fffa1d0f19c4445310b7" + +[[package]] +name = "rustls-webpki" +version = "0.102.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] @@ -477,6 +895,29 @@ dependencies = [ "serde", ] +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + [[package]] name = "syn" version = "2.0.48" @@ -488,6 +929,16 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tar" +version = "0.4.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b16afcea1f22891c49a00c751c7b63b2233284064f11a200fc624137c51e2ddb" +dependencies = [ + "filetime", + "libc", +] + [[package]] name = "tempfile" version = "3.10.0" @@ -497,7 +948,16 @@ dependencies = [ "cfg-if", "fastrand", "rustix", - "windows-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", ] [[package]] @@ -520,6 +980,21 @@ dependencies = [ "syn", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "toml" version = "0.8.10" @@ -554,12 +1029,61 @@ dependencies = [ "winnow", ] +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "ureq" +version = "2.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11f214ce18d8b2cbe84ed3aa6486ed3f5b285cf8d8fbdbce9f3f767a724adc35" +dependencies = [ + "base64", + "log", + "once_cell", + "rustls", + "rustls-pki-types", + "rustls-webpki", + "url", + "webpki-roots", +] + [[package]] name = "uriparse" version = "0.6.4" @@ -570,6 +1094,35 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf8-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + [[package]] name = "walkdir" version = "2.4.0" @@ -580,6 +1133,21 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "webpki-roots" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "which" version = "6.0.0" @@ -590,7 +1158,7 @@ dependencies = [ "home", "once_cell", "rustix", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -624,13 +1192,37 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.0", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -639,51 +1231,93 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.0" @@ -698,3 +1332,9 @@ checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" dependencies = [ "memchr", ] + +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/Cargo.toml b/Cargo.toml index 763ef15..6191ad6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,10 +4,12 @@ edition = "2021" rust-version = "1.76" [dependencies] +commons = { git = "https://github.com/heroku/buildpacks-ruby", branch = "main" } libcnb = "=0.18.0" [dev-dependencies] libcnb-test = "=0.18.0" +indoc = "2" [lints.rust] unreachable_pub = "warn" diff --git a/src/aptfile.rs b/src/aptfile.rs new file mode 100644 index 0000000..b9e1ad1 --- /dev/null +++ b/src/aptfile.rs @@ -0,0 +1,136 @@ +use std::collections::HashSet; +use std::str::FromStr; + +#[derive(Debug, Eq, PartialEq)] +pub(crate) struct Aptfile { + packages: HashSet, +} + +impl FromStr for Aptfile { + type Err = ParseAptfileError; + + fn from_str(value: &str) -> Result { + value + .lines() + .map(str::trim) + .filter(|line| !line.starts_with('#') && !line.is_empty()) + .map(DebianPackageName::from_str) + .collect::, _>>() + .map_err(ParseAptfileError) + .map(|packages| Aptfile { packages }) + } +} + +#[derive(Debug, PartialEq)] +pub(crate) struct ParseAptfileError(ParseDebianPackageNameError); + +#[derive(Debug, Eq, PartialEq, Hash)] +pub(crate) struct DebianPackageName(String); + +impl FromStr for DebianPackageName { + type Err = ParseDebianPackageNameError; + + fn from_str(value: &str) -> Result { + // https://www.debian.org/doc/debian-policy/ch-controlfields.html#source + // Package names (both source and binary, see Package) must consist only of + // lower case letters (a-z), digits (0-9), plus (+) and minus (-) signs, + // and periods (.). They must be at least two characters long and must + // start with an alphanumeric character. + let is_valid_package_name = value + .chars() + .all(|c| matches!(c, 'a'..='z' | '0'..='9' | '+' | '-' | '.')) + && value.chars().count() >= 2 + && value.starts_with(|c: char| c.is_ascii_alphanumeric()); + + if is_valid_package_name { + Ok(DebianPackageName(value.to_string())) + } else { + Err(ParseDebianPackageNameError(value.to_string())) + } + } +} + +#[derive(Debug, PartialEq)] +pub(crate) struct ParseDebianPackageNameError(String); + +#[cfg(test)] +mod tests { + use super::*; + use indoc::indoc; + + #[test] + fn parse_valid_debian_package_name() { + let valid_names = [ + "a0", // min length, starting with number + "0a", // min length, starting with letter + "g++", // alphanumeric to start followed by non-alphanumeric characters + "libevent-2.1-6", // just a mix of allowed characters + "a0+.-", // all the allowed characters + ]; + for valid_name in valid_names { + assert_eq!( + DebianPackageName::from_str(valid_name).unwrap(), + DebianPackageName(valid_name.to_string()) + ); + } + } + + #[test] + fn parse_invalid_debian_package_name() { + let invalid_names = [ + "a", // too short + "+a", // can't start with non-alphanumeric character + "ab_c", // can't contain invalid characters + "aBc", // uppercase is not allowed + "package=1.2.3-1", // versioning is not allowed, package name only + ]; + for invalid_name in invalid_names { + assert_eq!( + DebianPackageName::from_str(invalid_name).unwrap_err(), + ParseDebianPackageNameError(invalid_name.to_string()) + ); + } + } + + #[test] + fn parse_aptfile() { + let aptfile = Aptfile::from_str(indoc! { " + # comment line + # comment line with leading whitespace + + package-name-1 + package-name-2 + + # Package name has leading and trailing whitespace + package-name-3 \t + # Duplicates are allowed (at least for now) + package-name-1 + + " }) + .unwrap(); + assert_eq!( + aptfile, + Aptfile { + packages: HashSet::from([ + DebianPackageName("package-name-1".to_string()), + DebianPackageName("package-name-2".to_string()), + DebianPackageName("package-name-3".to_string()), + ]) + } + ); + } + + #[test] + fn parse_invalid_aptfile() { + let error = Aptfile::from_str(indoc! { " + invalid package name! + " }) + .unwrap_err(); + assert_eq!( + error, + ParseAptfileError(ParseDebianPackageNameError( + "invalid package name!".to_string() + )) + ); + } +} diff --git a/src/errors.rs b/src/errors.rs index 06ca2dc..037f49d 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,2 +1,15 @@ +use crate::aptfile::ParseAptfileError; + #[derive(Debug)] -pub(crate) enum AptBuildpackError {} +#[allow(clippy::enum_variant_names)] +pub(crate) enum AptBuildpackError { + DetectAptfile(std::io::Error), + ReadAptfile(std::io::Error), + ParseAptfile(ParseAptfileError), +} + +impl From for libcnb::Error { + fn from(value: AptBuildpackError) -> Self { + Self::BuildpackError(value) + } +} diff --git a/src/main.rs b/src/main.rs index 4775aea..77bd2b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,16 +1,23 @@ +use crate::aptfile::Aptfile; use crate::errors::AptBuildpackError; -use libcnb::build::{BuildContext, BuildResult}; -use libcnb::detect::{DetectContext, DetectResult}; +use commons::output::build_log::{BuildLog, Logger}; +use libcnb::build::{BuildContext, BuildResult, BuildResultBuilder}; +use libcnb::detect::{DetectContext, DetectResult, DetectResultBuilder}; use libcnb::generic::{GenericMetadata, GenericPlatform}; use libcnb::{buildpack_main, Buildpack}; +use std::fs; +use std::io::stdout; #[cfg(test)] use libcnb_test as _; +mod aptfile; mod errors; buildpack_main!(AptBuildpack); +const APTFILE_PATH: &str = "Aptfile"; + struct AptBuildpack; impl Buildpack for AptBuildpack { @@ -18,11 +25,30 @@ impl Buildpack for AptBuildpack { type Metadata = GenericMetadata; type Error = AptBuildpackError; - fn detect(&self, _context: DetectContext) -> libcnb::Result { - todo!() + fn detect(&self, context: DetectContext) -> libcnb::Result { + let aptfile_exists = context + .app_dir + .join(APTFILE_PATH) + .try_exists() + .map_err(AptBuildpackError::DetectAptfile)?; + + if aptfile_exists { + DetectResultBuilder::pass().build() + } else { + BuildLog::new(stdout()) + .without_buildpack_name() + .announce() + .warning("No Aptfile found."); + DetectResultBuilder::fail().build() + } } - fn build(&self, _context: BuildContext) -> libcnb::Result { - todo!() + fn build(&self, context: BuildContext) -> libcnb::Result { + let _aptfile: Aptfile = fs::read_to_string(context.app_dir.join(APTFILE_PATH)) + .map_err(AptBuildpackError::ReadAptfile)? + .parse() + .map_err(AptBuildpackError::ParseAptfile)?; + + BuildResultBuilder::new().build() } } diff --git a/tests/fixtures/basic/Aptfile b/tests/fixtures/basic/Aptfile new file mode 100644 index 0000000..e69de29 diff --git a/tests/fixtures/no_aptfile/.gitkeep b/tests/fixtures/no_aptfile/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 88d0423..016c8ec 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -3,3 +3,33 @@ // Required due to: https://github.com/rust-lang/rust/issues/95513 #![allow(unused_crate_dependencies)] + +use libcnb_test::{assert_contains, BuildConfig, PackResult, TestRunner}; + +#[test] +#[ignore = "integration test"] +fn test_successful_detection() { + TestRunner::default().build( + BuildConfig::new(get_integration_test_builder(), "tests/fixtures/basic") + .expected_pack_result(PackResult::Success), + |_| {}, + ); +} + +#[test] +#[ignore = "integration test"] +fn test_failed_detection() { + TestRunner::default().build( + BuildConfig::new(get_integration_test_builder(), "tests/fixtures/no_aptfile") + .expected_pack_result(PackResult::Failure), + |ctx| { + assert_contains!(ctx.pack_stdout, "No Aptfile found."); + }, + ); +} + +const DEFAULT_BUILDER: &str = "heroku/builder:22"; + +fn get_integration_test_builder() -> String { + std::env::var("INTEGRATION_TEST_CNB_BUILDER").unwrap_or(DEFAULT_BUILDER.to_string()) +}