From eebccba9328f05b1a974a63d1952ac357edcfa96 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Fri, 18 Oct 2024 12:20:09 -0600
Subject: [PATCH] 0.2.26: Update to use pkgutils rewrite

---
 Cargo.lock            | 390 +++++++++++++++---------------------------
 Cargo.toml            |   4 +-
 res/test.toml         | 324 +++++++++++++++++++++++++++++++++++
 res/update.sh         |  21 +++
 src/bin/installer.rs  |   1 -
 src/config/package.rs |   1 -
 src/lib.rs            |  98 ++++-------
 test.sh               |   2 +-
 test.toml             | 177 -------------------
 9 files changed, 524 insertions(+), 494 deletions(-)
 create mode 100644 res/test.toml
 create mode 100755 res/update.sh
 delete mode 100644 test.toml

diff --git a/Cargo.lock b/Cargo.lock
index 14fd0b0..835ec65 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -17,12 +17,6 @@ version = "2.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
 
-[[package]]
-name = "adler32"
-version = "1.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
-
 [[package]]
 name = "aes"
 version = "0.7.5"
@@ -35,18 +29,6 @@ dependencies = [
  "opaque-debug",
 ]
 
-[[package]]
-name = "ahash"
-version = "0.8.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
-dependencies = [
- "cfg-if 1.0.0",
- "once_cell",
- "version_check",
- "zerocopy",
-]
-
 [[package]]
 name = "aho-corasick"
 version = "1.1.3"
@@ -57,10 +39,19 @@ dependencies = [
 ]
 
 [[package]]
-name = "allocator-api2"
-version = "0.2.18"
+name = "alloc-no-stdlib"
+version = "2.0.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
+checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3"
+
+[[package]]
+name = "alloc-stdlib"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece"
+dependencies = [
+ "alloc-no-stdlib",
+]
 
 [[package]]
 name = "android-tzdata"
@@ -137,9 +128,9 @@ dependencies = [
 
 [[package]]
 name = "anyhow"
-version = "1.0.89"
+version = "1.0.90"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
+checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95"
 
 [[package]]
 name = "arg_parser"
@@ -169,6 +160,19 @@ version = "0.5.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
 
+[[package]]
+name = "async-compression"
+version = "0.4.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "103db485efc3e41214fe4fda9f3dbeae2eb9082f48fd236e6095627a9422066e"
+dependencies = [
+ "brotli",
+ "futures-core",
+ "memchr",
+ "pin-project-lite",
+ "tokio",
+]
+
 [[package]]
 name = "atty"
 version = "0.2.14"
@@ -219,12 +223,6 @@ version = "1.6.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
 
-[[package]]
-name = "bidir-map"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "75bf05cf4e05e803d8458ba57c61201b90068fa39f9200962fa401cd5f9ab403"
-
 [[package]]
 name = "bitflags"
 version = "1.3.2"
@@ -282,6 +280,27 @@ dependencies = [
  "generic-array",
 ]
 
+[[package]]
+name = "brotli"
+version = "7.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd"
+dependencies = [
+ "alloc-no-stdlib",
+ "alloc-stdlib",
+ "brotli-decompressor",
+]
+
+[[package]]
+name = "brotli-decompressor"
+version = "4.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a45bd2e4095a8b518033b128020dd4a55aab1c0a381ba4404a472630f4bc362"
+dependencies = [
+ "alloc-no-stdlib",
+ "alloc-stdlib",
+]
+
 [[package]]
 name = "bumpalo"
 version = "3.16.0"
@@ -370,6 +389,19 @@ version = "1.0.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
 
+[[package]]
+name = "console"
+version = "0.15.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb"
+dependencies = [
+ "encode_unicode",
+ "lazy_static",
+ "libc",
+ "unicode-width",
+ "windows-sys 0.52.0",
+]
+
 [[package]]
 name = "constant_time_eq"
 version = "0.1.5"
@@ -382,15 +414,6 @@ version = "0.8.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
 
-[[package]]
-name = "core2"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505"
-dependencies = [
- "memchr",
-]
-
 [[package]]
 name = "cpufeatures"
 version = "0.2.14"
@@ -415,24 +438,6 @@ version = "2.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5"
 
-[[package]]
-name = "crc32fast"
-version = "1.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
-dependencies = [
- "cfg-if 1.0.0",
-]
-
-[[package]]
-name = "crossbeam-channel"
-version = "0.5.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2"
-dependencies = [
- "crossbeam-utils",
-]
-
 [[package]]
 name = "crossbeam-deque"
 version = "0.8.5"
@@ -478,12 +483,6 @@ dependencies = [
  "subtle",
 ]
 
-[[package]]
-name = "dary_heap"
-version = "0.3.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7762d17f1241643615821a8455a0b2c3e803784b058693d990b11f2dce25a0ca"
-
 [[package]]
 name = "deranged"
 version = "0.3.11"
@@ -548,6 +547,12 @@ version = "1.13.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
 
+[[package]]
+name = "encode_unicode"
+version = "0.3.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
+
 [[package]]
 name = "endian-num"
 version = "0.1.2"
@@ -583,16 +588,6 @@ version = "1.0.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
 
-[[package]]
-name = "errno"
-version = "0.3.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
-dependencies = [
- "libc",
- "windows-sys 0.52.0",
-]
-
 [[package]]
 name = "error-chain"
 version = "0.12.4"
@@ -615,24 +610,6 @@ dependencies = [
  "log",
 ]
 
-[[package]]
-name = "filetime"
-version = "0.2.25"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586"
-dependencies = [
- "cfg-if 1.0.0",
- "libc",
- "libredox",
- "windows-sys 0.59.0",
-]
-
-[[package]]
-name = "fixedbitset"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
-
 [[package]]
 name = "fnv"
 version = "1.0.7"
@@ -772,16 +749,6 @@ dependencies = [
  "uuid",
 ]
 
-[[package]]
-name = "hashbrown"
-version = "0.14.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
-dependencies = [
- "ahash",
- "allocator-api2",
-]
-
 [[package]]
 name = "hashbrown"
 version = "0.15.0"
@@ -954,7 +921,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
 dependencies = [
  "equivalent",
- "hashbrown 0.15.0",
+ "hashbrown",
+]
+
+[[package]]
+name = "indicatif"
+version = "0.17.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3"
+dependencies = [
+ "console",
+ "instant",
+ "number_prefix",
+ "portable-atomic",
+ "unicode-width",
+]
+
+[[package]]
+name = "instant"
+version = "0.1.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"
+dependencies = [
+ "cfg-if 1.0.0",
 ]
 
 [[package]]
@@ -993,15 +982,6 @@ dependencies = [
  "wasm-bindgen",
 ]
 
-[[package]]
-name = "keccak"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654"
-dependencies = [
- "cpufeatures",
-]
-
 [[package]]
 name = "lazy_static"
 version = "1.5.0"
@@ -1010,33 +990,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
 
 [[package]]
 name = "libc"
-version = "0.2.159"
+version = "0.2.161"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
-
-[[package]]
-name = "libflate"
-version = "2.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "45d9dfdc14ea4ef0900c1cddbc8dcd553fbaacd8a4a282cf4018ae9dd04fb21e"
-dependencies = [
- "adler32",
- "core2",
- "crc32fast",
- "dary_heap",
- "libflate_lz77",
-]
-
-[[package]]
-name = "libflate_lz77"
-version = "2.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e6e0d73b369f386f1c44abd9c570d5318f55ccde816ff4b562fa452e5182863d"
-dependencies = [
- "core2",
- "hashbrown 0.14.5",
- "rle-decode-fast",
-]
+checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1"
 
 [[package]]
 name = "libredox"
@@ -1061,12 +1017,6 @@ dependencies = [
  "walkdir",
 ]
 
-[[package]]
-name = "linux-raw-sys"
-version = "0.4.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
-
 [[package]]
 name = "log"
 version = "0.4.22"
@@ -1132,6 +1082,12 @@ dependencies = [
  "autocfg",
 ]
 
+[[package]]
+name = "number_prefix"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
+
 [[package]]
 name = "numtoa"
 version = "0.2.4"
@@ -1169,33 +1125,12 @@ dependencies = [
  "winapi",
 ]
 
-[[package]]
-name = "pbr"
-version = "1.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed5827dfa0d69b6c92493d6c38e633bbaa5937c153d0d7c28bf12313f8c6d514"
-dependencies = [
- "crossbeam-channel",
- "libc",
- "winapi",
-]
-
 [[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.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db"
-dependencies = [
- "fixedbitset",
- "indexmap",
-]
-
 [[package]]
 name = "pin-project-lite"
 version = "0.2.14"
@@ -1267,6 +1202,12 @@ version = "0.2.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
 
+[[package]]
+name = "portable-atomic"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2"
+
 [[package]]
 name = "powerfmt"
 version = "0.2.0"
@@ -1410,11 +1351,28 @@ version = "0.3.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "436d45c2b6a5b159d43da708e62b25be3a4a3d5550d654b72216ade4c4bfd717"
 
+[[package]]
+name = "redox-pkg"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e74e8f571b1a91c18e716d73accdf1bdc72a1c93c586f349a6018db3b1424afd"
+dependencies = [
+ "indicatif",
+ "pkgar",
+ "pkgar-core",
+ "pkgar-keys",
+ "reqwest",
+ "serde",
+ "serde_derive",
+ "thiserror",
+ "toml",
+]
+
 [[package]]
 name = "redox-scheme"
-version = "0.2.3"
+version = "0.2.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "95624e20d2c1808f7ca0820720d30aad9f5d2fc404e1ef379431ad7a790c3f7e"
+checksum = "6143c4d307e1c99ac14f60b5b07b2dccaf9d17137f7cee4e4e29977dd8014a1b"
 dependencies = [
  "libredox",
  "redox_syscall",
@@ -1422,7 +1380,7 @@ dependencies = [
 
 [[package]]
 name = "redox_installer"
-version = "0.2.25"
+version = "0.2.26"
 dependencies = [
  "anyhow",
  "arg_parser",
@@ -1435,8 +1393,8 @@ dependencies = [
  "pkgar-core",
  "pkgar-keys",
  "rand",
+ "redox-pkg",
  "redox_liner",
- "redox_pkgutils",
  "redox_syscall",
  "redoxfs",
  "rust-argon2",
@@ -1460,28 +1418,6 @@ dependencies = [
  "unicode-width",
 ]
 
-[[package]]
-name = "redox_pkgutils"
-version = "0.1.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c76d0906f7fb9a69996b777be79fa793295aa3ebbdde89c375a1df841ee3ce43"
-dependencies = [
- "bidir-map",
- "clap",
- "indexmap",
- "libflate",
- "pbr",
- "petgraph",
- "redox_liner",
- "reqwest",
- "serde",
- "serde_derive",
- "sha3",
- "tar",
- "toml",
- "version-compare",
-]
-
 [[package]]
 name = "redox_syscall"
 version = "0.5.7"
@@ -1569,6 +1505,7 @@ version = "0.12.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b"
 dependencies = [
+ "async-compression",
  "base64 0.22.1",
  "bytes",
  "futures-channel",
@@ -1597,6 +1534,7 @@ dependencies = [
  "sync_wrapper",
  "tokio",
  "tokio-rustls",
+ "tokio-util",
  "tower-service",
  "url",
  "wasm-bindgen",
@@ -1621,12 +1559,6 @@ dependencies = [
  "windows-sys 0.52.0",
 ]
 
-[[package]]
-name = "rle-decode-fast"
-version = "1.0.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422"
-
 [[package]]
 name = "rust-argon2"
 version = "0.8.3"
@@ -1651,19 +1583,6 @@ version = "2.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
 
-[[package]]
-name = "rustix"
-version = "0.38.37"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811"
-dependencies = [
- "bitflags 2.6.0",
- "errno",
- "libc",
- "linux-raw-sys",
- "windows-sys 0.52.0",
-]
-
 [[package]]
 name = "rustls"
 version = "0.23.15"
@@ -1757,9 +1676,9 @@ dependencies = [
 
 [[package]]
 name = "serde_json"
-version = "1.0.128"
+version = "1.0.130"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8"
+checksum = "610f75ff4a8e3cb29b85da56eabdd1bff5b06739059a4b8e2967fef32e5d9944"
 dependencies = [
  "itoa",
  "memchr",
@@ -1788,16 +1707,6 @@ dependencies = [
  "serde",
 ]
 
-[[package]]
-name = "sha3"
-version = "0.10.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60"
-dependencies = [
- "digest 0.10.7",
- "keccak",
-]
-
 [[package]]
 name = "shlex"
 version = "1.3.0"
@@ -1893,17 +1802,6 @@ dependencies = [
  "futures-core",
 ]
 
-[[package]]
-name = "tar"
-version = "0.4.42"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ff6c40d3aedb5e06b57c6f669ad17ab063dd1e63d977c6a88e7f4dfa4f04020"
-dependencies = [
- "filetime",
- "libc",
- "xattr",
-]
-
 [[package]]
 name = "termion"
 version = "4.0.3"
@@ -2005,6 +1903,19 @@ dependencies = [
  "tokio",
 ]
 
+[[package]]
+name = "tokio-util"
+version = "0.7.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "pin-project-lite",
+ "tokio",
+]
+
 [[package]]
 name = "toml"
 version = "0.8.19"
@@ -2147,12 +2058,6 @@ version = "0.8.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
 
-[[package]]
-name = "version-compare"
-version = "0.0.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "03fcf84b72310ec15c6b2dc9dd8f31765d10debdfb240392fc96ff4cc0ec2f16"
-
 [[package]]
 name = "version_check"
 version = "0.9.5"
@@ -2523,17 +2428,6 @@ dependencies = [
  "memchr",
 ]
 
-[[package]]
-name = "xattr"
-version = "1.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f"
-dependencies = [
- "libc",
- "linux-raw-sys",
- "rustix",
-]
-
 [[package]]
 name = "zerocopy"
 version = "0.7.35"
diff --git a/Cargo.toml b/Cargo.toml
index 6a8be29..40a4513 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "redox_installer"
-version = "0.2.25"
+version = "0.2.26"
 description = "A Redox filesystem builder"
 license = "MIT"
 authors = ["Jeremy Soller <jackpot51@gmail.com>"]
@@ -37,7 +37,7 @@ pkgar-core = "0.1.13"
 pkgar-keys = "0.1.13"
 rand = "0.8"
 redox_liner = "0.5"
-redox_pkgutils = "0.1.9"
+redox-pkg = { version = "0.2.1", features = ["indicatif"] }
 redox_syscall = "0.5.2"
 redoxfs = "0.6.5"
 rust-argon2 = "0.8.2"
diff --git a/res/test.toml b/res/test.toml
new file mode 100644
index 0000000..659878b
--- /dev/null
+++ b/res/test.toml
@@ -0,0 +1,324 @@
+# Automatically generated by update.sh
+
+include = []
+
+[general]
+prompt = false
+filesystem_size = 256
+
+[packages.bootloader]
+
+[packages.bootstrap]
+
+[packages.ca-certificates]
+
+[packages.coreutils]
+
+[packages.drivers]
+
+[packages.escalated]
+
+[packages.extrautils]
+
+[packages.findutils]
+
+[packages.initfs]
+
+[packages.ion]
+
+[packages.ipcd]
+
+[packages.kernel]
+
+[packages.netdb]
+
+[packages.netstack]
+
+[packages.netutils]
+
+[packages.pkgutils]
+
+[packages.ptyd]
+
+[packages.smith]
+
+[packages.userutils]
+
+[packages.uutils]
+
+[[files]]
+path = "/usr/lib/init.d/00_base"
+data = """
+# clear and recreate tmpdir with 0o1777 permission
+rm -r /tmp
+mkdir -m a=rwxt /tmp
+
+ipcd
+ptyd
+escalated
+"""
+symlink = false
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/usr/lib/init.d/00_drivers"
+data = """
+pcid /etc/pcid.d/
+"""
+symlink = false
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/etc/hostname"
+data = """
+redox
+"""
+symlink = false
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/usr/lib/os-release"
+data = '''
+PRETTY_NAME="Redox OS 0.9.0"
+NAME="Redox OS"
+VERSION_ID="0.9.0"
+VERSION="0.9.0"
+ID="redox-os"
+
+HOME_URL="https://redox-os.org/"
+DOCUMENTATION_URL="https://redox-os.org/docs/"
+SUPPORT_URL="https://redox-os.org/community/"
+'''
+symlink = false
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/etc/os-release"
+data = "../usr/lib/os-release"
+symlink = true
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/usr"
+data = ""
+symlink = false
+directory = true
+mode = 493
+recursive_chown = false
+
+[[files]]
+path = "/usr/bin"
+data = ""
+symlink = false
+directory = true
+mode = 493
+recursive_chown = false
+
+[[files]]
+path = "/bin"
+data = "usr/bin"
+symlink = true
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/usr/include"
+data = ""
+symlink = false
+directory = true
+mode = 493
+recursive_chown = false
+
+[[files]]
+path = "/include"
+data = "usr/include"
+symlink = true
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/usr/lib"
+data = ""
+symlink = false
+directory = true
+mode = 493
+recursive_chown = false
+
+[[files]]
+path = "/lib"
+data = "usr/lib"
+symlink = true
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/usr/libexec"
+data = ""
+symlink = false
+directory = true
+mode = 493
+recursive_chown = false
+
+[[files]]
+path = "/libexec"
+data = "usr/libexec"
+symlink = true
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/usr/share"
+data = ""
+symlink = false
+directory = true
+mode = 493
+recursive_chown = false
+
+[[files]]
+path = "/share"
+data = "usr/share"
+symlink = true
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/dev/null"
+data = "/scheme/null"
+symlink = true
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/dev/random"
+data = "/scheme/rand"
+symlink = true
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/dev/urandom"
+data = "/scheme/rand"
+symlink = true
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/dev/zero"
+data = "/scheme/zero"
+symlink = true
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/dev/tty"
+data = "libc:tty"
+symlink = true
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/dev/stdin"
+data = "libc:stdin"
+symlink = true
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/dev/stdout"
+data = "libc:stdout"
+symlink = true
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/dev/stderr"
+data = "libc:stderr"
+symlink = true
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/usr/lib/init.d/10_net"
+data = """
+smolnetd
+dnsd
+dhcpd -b
+"""
+symlink = false
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/etc/net/dns"
+data = """
+208.67.222.222
+"""
+symlink = false
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/etc/net/ip"
+data = """
+10.0.2.15
+"""
+symlink = false
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/etc/net/ip_router"
+data = """
+10.0.2.2
+"""
+symlink = false
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/etc/net/ip_subnet"
+data = """
+255.255.255.0
+"""
+symlink = false
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/usr/lib/init.d/30_console"
+data = """
+inputd -A 2
+getty 2
+getty /scheme/debug -J
+"""
+symlink = false
+directory = false
+recursive_chown = false
+
+[[files]]
+path = "/etc/pkg.d/50_redox"
+data = "https://static.redox-os.org/pkg"
+symlink = false
+directory = false
+recursive_chown = false
+
+[users.root]
+password = "password"
+uid = 0
+gid = 0
+name = "root"
+home = "/root"
+shell = "/usr/bin/ion"
+
+[users.user]
+password = ""
+shell = "/usr/bin/ion"
+
+[groups.sudo]
+gid = 1
+members = ["user"]
diff --git a/res/update.sh b/res/update.sh
new file mode 100755
index 0000000..ff55158
--- /dev/null
+++ b/res/update.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+set -e
+
+RES_PATH="$(dirname "$0")"
+
+if [ -d "$1" ]
+then
+    REDOX_PATH="$1"
+else
+    echo "$0 [path to redox repository]" >&2
+    exit 1
+fi
+
+set -x
+
+# Update res/test.toml from the redoxer.toml template
+cargo run --release --manifest-path "${RES_PATH}/../Cargo.toml" -- \
+    --config="${REDOX_PATH}/config/x86_64/minimal-net.toml" \
+    --output-config="${RES_PATH}/test.toml"
+sed -i '1s/^/# Automatically generated by update.sh\n\n/' "${RES_PATH}/test.toml"
diff --git a/src/bin/installer.rs b/src/bin/installer.rs
index 3e95be5..152820c 100644
--- a/src/bin/installer.rs
+++ b/src/bin/installer.rs
@@ -114,7 +114,6 @@ fn main() {
                                 version: None,
                                 git: None,
                                 path: None,
-                                pkg_path: None,
                             } => false,
                             _ => true,
                         })
diff --git a/src/config/package.rs b/src/config/package.rs
index 46c222c..b5b695c 100644
--- a/src/config/package.rs
+++ b/src/config/package.rs
@@ -9,7 +9,6 @@ pub enum PackageConfig {
         version: Option<String>,
         git: Option<String>,
         path: Option<String>,
-        pkg_path: Option<String>,
     },
 }
 
diff --git a/src/lib.rs b/src/lib.rs
index 8960788..169aa61 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -10,17 +10,19 @@ pub use crate::config::Config;
 use crate::disk_wrapper::DiskWrapper;
 
 use anyhow::{bail, Result};
-use pkgutils::{Package, Repo};
+use pkg::Library;
 use rand::{rngs::OsRng, RngCore};
 use redoxfs::{unmount_path, Disk, DiskIo, FileSystem};
 use termion::input::TermRead;
 
 use std::{
+    cell::RefCell,
     collections::BTreeMap,
     env, fs,
     io::{self, Seek, SeekFrom, Write},
     path::Path,
     process,
+    rc::Rc,
     sync::mpsc::channel,
     thread,
     time::{SystemTime, UNIX_EPOCH},
@@ -33,8 +35,6 @@ pub struct DiskOption<'a> {
     pub efi_partition_size: Option<u32>, //MiB
 }
 
-const REMOTE: &'static str = "https://static.redox-os.org/pkg";
-
 fn get_target() -> String {
     env::var("TARGET").unwrap_or(
         option_env!("TARGET").map_or("x86_64-unknown-redox".to_string(), |x| x.to_string()),
@@ -78,12 +78,21 @@ fn prompt_password(prompt: &str, confirm_prompt: &str) -> Result<String> {
     Ok(password.unwrap_or("".to_string()))
 }
 
+fn install_local_pkgar(cookbook: &str, target: &str, packagename: &str, dest: &str) {
+    let public_path = format!("{cookbook}/build/id_ed25519.pub.toml",);
+    let pkgar_path = format!("{cookbook}/repo/{target}/{packagename}.pkgar");
+    pkgar::extract(&public_path, &pkgar_path, dest).unwrap();
+
+    let head_path = format!("{dest}/pkg/{packagename}.pkgar_head");
+    pkgar::split(&public_path, &pkgar_path, &head_path, Option::<&str>::None).unwrap();
+}
+
 //TODO: error handling
 fn install_packages(config: &Config, dest: &str, cookbook: Option<&str>) {
     let target = &get_target();
 
-    let mut repo = Repo::new(target);
-    repo.add_remote(REMOTE);
+    let callback = pkg::callback::IndicatifCallback::new();
+    let mut library = Library::new(dest, target, Rc::new(RefCell::new(callback))).unwrap();
 
     if let Some(cookbook) = cookbook {
         let dest_pkg = format!("{}/pkg", dest);
@@ -92,14 +101,8 @@ fn install_packages(config: &Config, dest: &str, cookbook: Option<&str>) {
         }
 
         for (packagename, package) in &config.packages {
-            let pkgar_path = format!(
-                "{cwd}/{cookbook}/repo/{target}/{packagename}.pkgar",
-                cwd = env::current_dir().unwrap().to_string_lossy(),
-            );
-
-            enum Rule<'a> {
+            enum Rule {
                 RemotePrebuilt,
-                LocalPrebuilt { pkg_path: &'a str },
                 Build,
             }
 
@@ -111,75 +114,35 @@ fn install_packages(config: &Config, dest: &str, cookbook: Option<&str>) {
                         version: None,
                         git: None,
                         path: None,
-                        pkg_path: None,
                     },
-                ) => {
-                    // prebuilt
-                    Rule::RemotePrebuilt
-                }
+                ) => Rule::RemotePrebuilt,
                 (_, PackageConfig::Build(rule)) if rule == "binary" => Rule::RemotePrebuilt,
-                (
-                    _,
-                    PackageConfig::Spec {
-                        pkg_path: Some(pkg_path),
-                        ..
-                    },
-                ) => Rule::LocalPrebuilt {
-                    pkg_path: &*pkg_path,
-                },
-
                 _ => Rule::Build,
             };
 
             match rule {
-                Rule::LocalPrebuilt { pkg_path } => {
-                    println!(
-                        "Installing package from local pkgar file: {packagename} <- `{pkg_path}`"
-                    );
-                    Package::from_path(pkg_path).unwrap().install(dest).unwrap();
-                }
                 Rule::RemotePrebuilt => {
                     println!("Installing package from remote: {packagename}");
-                    repo.fetch(&packagename).unwrap().install(dest).unwrap();
-                }
-                Rule::Build if Path::new(&pkgar_path).exists() => {
-                    println!("Installing package from local repo: {}", packagename);
-                    let public_path = format!(
-                        "{cwd}/{cookbook}/build/id_ed25519.pub.toml",
-                        cwd = env::current_dir().unwrap().to_string_lossy(),
-                    );
-                    pkgar::extract(&public_path, &pkgar_path, dest).unwrap();
-
-                    let head_path = format!("{dest_pkg}/{packagename}.pkgar_head");
-                    pkgar::split(&public_path, &pkgar_path, &head_path, Option::<&str>::None)
+                    library
+                        .install(vec![pkg::PackageName::new(packagename).unwrap()])
                         .unwrap();
                 }
                 Rule::Build => {
-                    println!("Installing package tar.gz from local repo: {packagename}");
-                    let path = format!(
-                        "{cwd}/{cookbook}/repo/{target}/{packagename}.tar.gz",
-                        cwd = env::current_dir().unwrap().to_string_lossy(),
-                    );
-                    Package::from_path(&path).unwrap().install(dest).unwrap();
+                    println!("Installing package from local repo: {}", packagename);
+                    install_local_pkgar(cookbook, target, packagename, dest);
                 }
             }
         }
     } else {
-        for (packagename, package) in &config.packages {
-            let mut package = if let PackageConfig::Spec {
-                pkg_path: Some(override_path),
-                ..
-            } = package
-            {
-                println!("Installing package from local file: {}", packagename);
-                Package::from_path(override_path).unwrap()
-            } else {
-                println!("Installing package from remote: {}", packagename);
-                repo.fetch(&packagename).unwrap()
-            };
-            package.install(dest).unwrap();
+        for (packagename, _package) in &config.packages {
+            println!("Installing package from remote: {}", packagename);
+            library
+                .install(vec![pkg::PackageName::new(packagename).unwrap()])
+                .unwrap();
         }
     }
+
+    library.apply().unwrap();
 }
 
 pub fn install_dir(
@@ -500,6 +463,13 @@ pub fn fetch_bootloaders(
 
     let mut bootloader_config = Config::default();
     bootloader_config.general = config.general.clone();
+    // Ensure a pkgar remote is available
+    FileConfig {
+        path: "/etc/pkg.d/50_redox".to_string(),
+        data: "https://static.redox-os.org/pkg".to_string(),
+        ..Default::default()
+    }
+    .create(&bootloader_dir)?;
     bootloader_config
         .packages
         .insert("bootloader".to_string(), PackageConfig::default());
diff --git a/test.sh b/test.sh
index 8615d39..3de5e78 100755
--- a/test.sh
+++ b/test.sh
@@ -24,6 +24,6 @@ cargo build --release
 rm -f "${IMAGE}"
 fallocate -l 1GiB "${IMAGE}"
 
-target/release/redox_installer -c test.toml "${IMAGE}"
+target/release/redox_installer -c res/test.toml "${IMAGE}"
 
 qemu-system-x86_64 "${QEMU_ARGS[@]}" -drive "file=${IMAGE},format=raw"
diff --git a/test.toml b/test.toml
deleted file mode 100644
index 08b9f2b..0000000
--- a/test.toml
+++ /dev/null
@@ -1,177 +0,0 @@
-# This is the default configuration file
-
-# General settings
-[general]
-# Do not prompt if settings are not defined
-prompt = false
-
-# Package settings
-[packages]
-audiod = {}
-bootloader = {}
-ca-certificates = {}
-contain = {}
-coreutils = {}
-dash = {}
-diffutils = {}
-drivers = {}
-extrautils = {}
-findutils = {}
-gdbserver = {}
-gnu-make = {}
-installer = {}
-ion = {}
-ipcd = {}
-kernel = {}
-netdb = {}
-netstack = {}
-netsurf = {}
-netutils = {}
-orbdata = {}
-orbital = {}
-orbterm = {}
-orbutils = {}
-pkgutils = {}
-ptyd = {}
-redoxfs = {}
-relibc = {}
-resist = {}
-smith = {}
-strace = {}
-userutils = {}
-uutils = {}
-vim = {}
-
-# User settings
-[users.root]
-password = "password"
-uid = 0
-gid = 0
-name = "root"
-home = "/root"
-
-[users.user]
-# Password is unset
-password = ""
-
-# Group settings
-[groups.sudo]
-gid = 1
-members = ["user"]
-
-[[files]]
-path = "/etc/init.d/00_base"
-data = """
-ipcd
-ptyd
-pcid /etc/pcid.d/
-"""
-
-[[files]]
-path = "/etc/init.d/10_net"
-data = """
-smolnetd
-dnsd
-dhcpd -b
-"""
-
-[[files]]
-path = "/etc/init.d/20_orbital"
-data = """
-audiod
-orbital display:3/activate orblogin launcher
-"""
-
-[[files]]
-path = "/etc/init.d/30_console"
-data = """
-getty display:2
-getty debug: -J
-"""
-
-[[files]]
-path = "/etc/net/dns"
-data = """
-208.67.222.222
-"""
-
-[[files]]
-path = "/etc/net/ip"
-data = """
-10.0.2.15
-"""
-
-[[files]]
-path = "/etc/net/ip_router"
-data = """
-10.0.2.2
-"""
-
-[[files]]
-path = "/etc/net/ip_subnet"
-data = """
-255.255.255.0
-"""
-
-[[files]]
-path = "/etc/net/mac"
-data = """
-54-52-00-ab-cd-ef
-"""
-
-[[files]]
-path = "/etc/pkg.d/50_redox"
-data = "https://static.redox-os.org/pkg"
-
-[[files]]
-path = "/etc/hostname"
-data = """
-redox
-"""
-
-[[files]]
-path = "/usr/bin"
-data = "../bin"
-symlink = true
-
-[[files]]
-path = "/usr/include"
-data = "../include"
-symlink = true
-
-[[files]]
-path = "/usr/lib"
-data = "../lib"
-symlink = true
-
-[[files]]
-path = "/usr/share"
-data = "../share"
-symlink = true
-
-[[files]]
-path = "/tmp"
-data = ""
-directory= true
-# 0o1777
-mode = 1023
-
-[[files]]
-path = "/dev/null"
-data = "null:"
-symlink = true
-
-[[files]]
-path = "/dev/random"
-data = "rand:"
-symlink = true
-
-[[files]]
-path = "/dev/urandom"
-data = "rand:"
-symlink = true
-
-[[files]]
-path = "/dev/zero"
-data = "zero:"
-symlink = true
-- 
GitLab