From c46aea2bd57729014067516e72b4d9dec29af9be Mon Sep 17 00:00:00 2001 From: YuzukiTsuru <740291272@qq.com> Date: Mon, 27 Jun 2022 13:20:37 +0800 Subject: [PATCH 1/2] add openixcard --- snap/snapcraft.yaml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 snap/snapcraft.yaml diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000..0466067 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,36 @@ +name: openixcard +adopt-info: openixcard +summary: Open Source Version of Allwinner PhoenixCard to Dump, Unpack, Flash Allwinner IMG Files on Linux. +description: | + OpenixCard is a Open Source Version of Allwinner PhoenixCard to Dump, Unpack, Flash Allwinner IMG Files on Linux, Support Linux images. +grade: stable +confinement: strict +icon: "./favicon.png" +apps: + openixcard: + command: openixcard +base: core18 +parts: + openixcard: + plugin: cmake + source: https://github.com/YuzukiTsuru/OpenixCard + source-type: git + source-depth: 1 + build-snaps: [cmake/latest/edge] + build-packages: + - pkg-config + - libconfuse-dev + - automake + - autoconf + - aclocal + override-build: | + /snap/bin/cmake \ + -DCMAKE_INSTALL_PREFIX=$SNAPCRAFT_PART_INSTALL/usr/local \ + -DCMAKE_BUILD_TYPE=Release \ + $SNAPCRAFT_PART_SRC + make -j 4 + make install + snapcraftctl set-version "$(git rev-list --count HEAD)" +passthrough: + title: OpenixCard + license: GPL \ No newline at end of file From b18db21c939655219e738c358cba3a8ea00d2d48 Mon Sep 17 00:00:00 2001 From: YuzukiTsuru Date: Fri, 1 Jul 2022 22:41:15 +0800 Subject: [PATCH 2/2] support print Partition Table --- src/OpenixCard/FEX2CFG.cpp | 26 +++++++++++++++++++++----- src/OpenixCard/FEX2CFG.h | 2 +- src/OpenixCard/LOG.cpp | 2 +- src/OpenixCard/OpenixCard.cpp | 6 +++--- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/OpenixCard/FEX2CFG.cpp b/src/OpenixCard/FEX2CFG.cpp index 7721e19..5c677a0 100644 --- a/src/OpenixCard/FEX2CFG.cpp +++ b/src/OpenixCard/FEX2CFG.cpp @@ -12,9 +12,11 @@ #include #include +#include + #include "FEX2CFG.h" +#include "LOG.h" #include "exception.h" - #include FEX2CFG::FEX2CFG(const std::string &dump_path) { @@ -103,12 +105,16 @@ void FEX2CFG::parse_fex() { return awImgCfg; } -uint FEX2CFG::get_image_real_size() { +uint FEX2CFG::get_image_real_size(bool print) { get_partition_real_size(); uint total_size = 0; for (auto &size: partition_size_list) { total_size += size; } + if (print) { + LOG::DATA("Partition Table: "); + print_partition_table(); + } return total_size + linux_common_fex_compensate(); } @@ -128,14 +134,24 @@ void FEX2CFG::gen_cfg() { } [[maybe_unused]] void FEX2CFG::print_partition_table() { + std::cout << cc::green; for (auto §: fex_classed) { - std::cout << " Partition: '" << sect.get_name() << "'" << std::endl; + std::cout << " Partition: '"; // Iterate through options in a section for (auto &opt: sect) { - std::cout << " Option: '" << opt.get_name() << "' with value(s): "; - std::cout << "'" << opt.get() << "'" << std::endl; + if (opt.get_name() == "name") { + auto name = opt.get(); + std::cout << name << "' "; + if (name == "UDISK") { + std::cout << "Remaining space."; + } + } else if (opt.get_name() == "size") { + std::cout << opt.get() / 0x300 << "MB - " << opt.get() << "KB"; + } } + std::cout << std::endl; } + std::cout << cc::reset; } void FEX2CFG::get_partition_real_size() { diff --git a/src/OpenixCard/FEX2CFG.h b/src/OpenixCard/FEX2CFG.h index 7751c4e..04c58e6 100644 --- a/src/OpenixCard/FEX2CFG.h +++ b/src/OpenixCard/FEX2CFG.h @@ -35,7 +35,7 @@ class FEX2CFG { [[maybe_unused]] [[nodiscard]] std::string get_image_name() const; // get image real size - [[maybe_unused]] uint get_image_real_size(); + [[maybe_unused]] uint get_image_real_size(bool print); // Print out the partition table [[maybe_unused]] void print_partition_table(); diff --git a/src/OpenixCard/LOG.cpp b/src/OpenixCard/LOG.cpp index 6d99ae1..4ef95fd 100644 --- a/src/OpenixCard/LOG.cpp +++ b/src/OpenixCard/LOG.cpp @@ -14,7 +14,7 @@ #include "LOG.h" void LOG::DATA(const std::string &msg) { - std::cout << cc::green << "[OpenixCard INFO] " << msg << cc::reset << std::endl; + std::cout << cc::green << msg << cc::reset << std::endl; } void LOG::INFO(const std::string &msg) { diff --git a/src/OpenixCard/OpenixCard.cpp b/src/OpenixCard/OpenixCard.cpp index 8dab4be..a2986aa 100644 --- a/src/OpenixCard/OpenixCard.cpp +++ b/src/OpenixCard/OpenixCard.cpp @@ -140,13 +140,13 @@ OpenixCard::OpenixCard(int argc, char **argv) { } void OpenixCard::show_logo() { - std::cout << cc::blue << + std::cout << cc::green << " _____ _ _____ _ \n" "| |___ ___ ___|_|_ _| |___ ___ _| |\n" "| | | . | -_| | |_'_| --| .'| _| . |\n" "|_____| _|___|_|_|_|_,_|_____|__,|_| |___|\n" " |_| Version: " << PROJECT_GIT_HASH - << cc::yellow << + << cc::magenta << "\nCopyright (c) 2022, YuzukiTsuru \n" << cc::reset << std::endl; } @@ -227,7 +227,7 @@ void OpenixCard::check_file(const std::string &file_path) { void OpenixCard::get_real_size() { LOG::INFO("Getting accurate size of Allwinner img..."); FEX2CFG fex2Cfg(temp_file_path); - auto real_size = fex2Cfg.get_image_real_size(); + auto real_size = fex2Cfg.get_image_real_size(true); LOG::DATA("The accurate size of image: " + std::to_string(real_size / 1024) + "MB, " + std::to_string(real_size) + "KB"); }