diff --git a/rpmust/src/main.rs b/rpmust/src/main.rs index 41107c2c5656614b6491ce91cbaf0380eec33450..b6c8f9f9947f8fade100f3b4476bdd16153767d4 100644 --- a/rpmust/src/main.rs +++ b/rpmust/src/main.rs @@ -11,6 +11,7 @@ OPTIONS: SUBCOMMANDS: build merge the RPMPackageMetadata.yaml and out.cpio to a rpm file decode turn the rpm file to RPMPackageMetadata.yaml and out.cpio + clean clean the output file help Print this message or the help of the given subcommand(s) 例如: @@ -146,15 +147,14 @@ fn main() -> io::Result<()> { let cpio = fs::read("out.cpio").unwrap(); for entry in cpio_reader::iter_files(&cpio) { - println!("\x1b[93mFile name:\x1b[0m {}",entry.name()); let mut p = &entry.name()[2..entry.name().len()]; let p = &("./out/".to_owned() + p); let path = std::path::Path::new(p); + println!("\x1b[93mFile name:\x1b[0m {}",path.display()); let prefix = path.parent().unwrap(); - if !prefix.exists() { + if !path.exists() { + std::fs::create_dir_all(prefix).unwrap(); - } - if !prefix.exists() { let mut f = File::create(p)?; f.write_all(entry.file()); } @@ -196,42 +196,6 @@ fn main() -> io::Result<()> { } file.write_all(&cpio_file); } - Some(("build", _sub_matches)) => { - let yaml_path = _sub_matches.value_of("PATH"); - let mut file = std::fs::File::open(yaml_path.unwrap()).unwrap(); - let mut yaml_str = String::new(); - file.read_to_string(&mut yaml_str).expect("Input the yaml file path"); - let rpm: RPMPackageMetadata = serde_yaml::from_str(&yaml_str).expect("yaml read failed!"); - - println!("Building the out.rpm"); - let mut file = File::create("out.rpm")?; - rpm.write(&mut file); - - let mut cpio_file = Vec::new(); - for i in 0..rpm.header.index_entries.len() { - if rpm.header.index_entries[i].tag == IndexTag::RPMTAG_PAYLOADCOMPRESSOR { - match &rpm.header.index_entries[i].data { - IndexData::StringTag(s) => { - if s == "xz" || s == "lzma" { - cpio_file = fs::read("out.cpio.xz")?; - } else if s == "gzip" { - cpio_file = fs::read("out.cpio.gz")?; - } else if s == "zstd" { - cpio_file = fs::read("out.cpio.zst")?; - } else if s == "bzip2" { - cpio_file = fs::read("out.cpio.bz2")?; - } else { - cpio_file = fs::read("out.cpio")?; - } - }, - _ => { - - } - } - } - } - file.write_all(&cpio_file); - } Some(("clean", _sub_matches)) => { let mut is = true; let out_dir_path = std::path::Path::new("./out"); diff --git a/rpmust/src/test/389-ds-base-devel-1.3.8.4-15.el7.x86_64.rpm b/rpmust/src/test/389-ds-base-devel-1.3.8.4-15.el7.x86_64.rpm deleted file mode 100644 index 20cea342b005f0e42044f87c187340379068eafe..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/389-ds-base-devel-1.3.8.4-15.el7.x86_64.rpm and /dev/null differ diff --git a/rpmust/src/test/BackupPC-4.4.0-6.fc36.x86_64.rpm b/rpmust/src/test/BackupPC-4.4.0-6.fc36.x86_64.rpm deleted file mode 100644 index 3b0ee17364aed87459e1e6ecfaf36c5e1328e7ec..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/BackupPC-4.4.0-6.fc36.x86_64.rpm and /dev/null differ diff --git a/rpmust/src/test/SDL-1.2.14-7.el6_7.1.i686.rpm b/rpmust/src/test/SDL-1.2.14-7.el6_7.1.i686.rpm deleted file mode 100644 index 9bcc135f80d1ae93c9db95ecaa578daf2553bb0c..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/SDL-1.2.14-7.el6_7.1.i686.rpm and /dev/null differ diff --git a/rpmust/src/test/alsa-lib-1.2.3-1.oe1.src.rpm b/rpmust/src/test/alsa-lib-1.2.3-1.oe1.src.rpm new file mode 100644 index 0000000000000000000000000000000000000000..62ad2763a46ef27300ab80c513066363125a0de7 Binary files /dev/null and b/rpmust/src/test/alsa-lib-1.2.3-1.oe1.src.rpm differ diff --git a/rpmust/src/test/apr-1.7.0-2.oe1.src.rpm b/rpmust/src/test/apr-1.7.0-2.oe1.src.rpm new file mode 100644 index 0000000000000000000000000000000000000000..fc0bf249cadedb504f16b6ef066eaf453f3eb149 Binary files /dev/null and b/rpmust/src/test/apr-1.7.0-2.oe1.src.rpm differ diff --git a/rpmust/src/test/bzip2-1.0.6-lp150.4.6.1.x86_64.rpm b/rpmust/src/test/bzip2-1.0.6-lp150.4.6.1.x86_64.rpm deleted file mode 100644 index 7d6638e007a4e2b65f49e23a26806c100640b61f..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/bzip2-1.0.6-lp150.4.6.1.x86_64.rpm and /dev/null differ diff --git a/rpmust/src/test/bzip2-1.0.8-150400.1.77.aarch64.rpm b/rpmust/src/test/bzip2-1.0.8-150400.1.77.aarch64.rpm deleted file mode 100644 index 2e0eba0522cd1e2d78ae64943472e568eba4c7d4..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/bzip2-1.0.8-150400.1.77.aarch64.rpm and /dev/null differ diff --git a/rpmust/src/test/bzip2-1.0.8-2.fc32.ppc64le.rpm b/rpmust/src/test/bzip2-1.0.8-2.fc32.ppc64le.rpm deleted file mode 100644 index 26091e2a6f818b26e1d336af635b074e5377df9c..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/bzip2-1.0.8-2.fc32.ppc64le.rpm and /dev/null differ diff --git a/rpmust/src/test/bzip2-1.0.8-2.fc32.s390x.rpm b/rpmust/src/test/bzip2-1.0.8-2.fc32.s390x.rpm deleted file mode 100644 index 0940cc1e96f52641d986d9da706a15ac4c828cef..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/bzip2-1.0.8-2.fc32.s390x.rpm and /dev/null differ diff --git a/rpmust/src/test/bzip2-1.0.8-2.fc32.x86_64.rpm b/rpmust/src/test/bzip2-1.0.8-2.fc32.x86_64.rpm deleted file mode 100644 index e86db928b7445e3c85190ed45c8841f830c7f79b..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/bzip2-1.0.8-2.fc32.x86_64.rpm and /dev/null differ diff --git a/rpmust/src/test/bzip2-1.0.8-2.mga8.i586.rpm b/rpmust/src/test/bzip2-1.0.8-2.mga8.i586.rpm deleted file mode 100644 index 1a9c3fd7b0dbad9b7eddf3d020cfee8c5d8f648b..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/bzip2-1.0.8-2.mga8.i586.rpm and /dev/null differ diff --git a/rpmust/src/test/bzip2-1.0.8-9.fc35.armv7hl.rpm b/rpmust/src/test/bzip2-1.0.8-9.fc35.armv7hl.rpm deleted file mode 100644 index 3538b4ff4c228baaffda172823b9400d9be1a0aa..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/bzip2-1.0.8-9.fc35.armv7hl.rpm and /dev/null differ diff --git a/rpmust/src/test/centos-release-samba412-1.0-1.el8.noarch.rpm b/rpmust/src/test/centos-release-samba412-1.0-1.el8.noarch.rpm deleted file mode 100644 index 1354043ec04b914d36fbb0e18bfacc23c2070e75..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/centos-release-samba412-1.0-1.el8.noarch.rpm and /dev/null differ diff --git a/rpmust/src/test/clang-10.0.1-0.oe1.aarch64.rpm b/rpmust/src/test/clang-10.0.1-0.oe1.aarch64.rpm deleted file mode 100644 index 535c197140c2c55a67691a5b1968a7d1eb8e5678..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/clang-10.0.1-0.oe1.aarch64.rpm and /dev/null differ diff --git a/rpmust/src/test/eclipse-nls-id-3.6.0.v20120721114722-2.el6.x86_64.rpm b/rpmust/src/test/eclipse-nls-id-3.6.0.v20120721114722-2.el6.x86_64.rpm deleted file mode 100644 index f1fb9c9c237796fde08fc6aa98cb0c928e801e4e..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/eclipse-nls-id-3.6.0.v20120721114722-2.el6.x86_64.rpm and /dev/null differ diff --git a/rpmust/src/test/git-daemon-1.7.1-8.el6.x86_64.rpm b/rpmust/src/test/git-daemon-1.7.1-8.el6.x86_64.rpm deleted file mode 100644 index 439618670c2d567343a4b0e161aa8b3de96f52f7..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/git-daemon-1.7.1-8.el6.x86_64.rpm and /dev/null differ diff --git a/rpmust/src/test/glibc-common-2.12-1.209.el6.x86_64.rpm b/rpmust/src/test/glibc-common-2.12-1.209.el6.x86_64.rpm deleted file mode 100644 index c3c190305e93f5eab5d9afd1ce813d6f19974202..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/glibc-common-2.12-1.209.el6.x86_64.rpm and /dev/null differ diff --git a/rpmust/src/test/ima_signed.rpm b/rpmust/src/test/ima_signed.rpm deleted file mode 100644 index a5c844324943f6e19a24b2b574467d9236d005c4..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/ima_signed.rpm and /dev/null differ diff --git a/rpmust/src/test/jikes-1.23-0.20050308.14-omv4050.x86_64.rpm b/rpmust/src/test/jikes-1.23-0.20050308.14-omv4050.x86_64.rpm deleted file mode 100644 index 876c0d344f72af5cbfa144bb11de69a57457af82..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/jikes-1.23-0.20050308.14-omv4050.x86_64.rpm and /dev/null differ diff --git a/rpmust/src/test/libucil-0.9.10-7.el7.aarch64.rpm b/rpmust/src/test/libucil-0.9.10-7.el7.aarch64.rpm deleted file mode 100644 index 6383167e4a39ca2d8887dbc1e2a27a339f80d284..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/libucil-0.9.10-7.el7.aarch64.rpm and /dev/null differ diff --git a/rpmust/src/test/llvm-10.0.1-2.oe1.aarch64.rpm b/rpmust/src/test/llvm-10.0.1-2.oe1.aarch64.rpm deleted file mode 100644 index 7433ea46410f4dd8d3b04df9a769377646e5b8a4..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/llvm-10.0.1-2.oe1.aarch64.rpm and /dev/null differ diff --git a/rpmust/src/test/monkeysphere-0.37-1.el7.noarch.rpm b/rpmust/src/test/monkeysphere-0.37-1.el7.noarch.rpm deleted file mode 100644 index 6889c54f2590192f57b6ba555f48a69683efe3c1..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/monkeysphere-0.37-1.el7.noarch.rpm and /dev/null differ diff --git a/rpmust/src/test/qemu-4.1.0-13.oe1.x86_64.rpm b/rpmust/src/test/qemu-4.1.0-13.oe1.x86_64.rpm deleted file mode 100644 index 83eea625f4872920b5789bb81f48f77b1a5ddc89..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/qemu-4.1.0-13.oe1.x86_64.rpm and /dev/null differ diff --git a/rpmust/src/test/qt-mysql-4.8.7-67.fc36.i686.rpm b/rpmust/src/test/qt-mysql-4.8.7-67.fc36.i686.rpm deleted file mode 100644 index 83ee13e11784165f4644a4f495fd3b6ebab584ba..0000000000000000000000000000000000000000 Binary files a/rpmust/src/test/qt-mysql-4.8.7-67.fc36.i686.rpm and /dev/null differ