Skip to content

Commit

Permalink
Merge pull request #19 from YuzukiTsuru/dev
Browse files Browse the repository at this point in the history
リファインドパーティション出力のサポート
  • Loading branch information
YuzukiTsuru committed Jul 1, 2022
2 parents 16b77a6 + b18db21 commit de271c7
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 10 deletions.
36 changes: 36 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 21 additions & 5 deletions src/OpenixCard/FEX2CFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
#include <string>
#include <sstream>

#include <ColorCout.hpp>

#include "FEX2CFG.h"
#include "LOG.h"
#include "exception.h"

#include <payloads/chip.h>

FEX2CFG::FEX2CFG(const std::string &dump_path) {
Expand Down Expand Up @@ -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();
}

Expand All @@ -128,14 +134,24 @@ void FEX2CFG::gen_cfg() {
}

[[maybe_unused]] void FEX2CFG::print_partition_table() {
std::cout << cc::green;
for (auto &sect: 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<inicpp::string_ini_t>() << "'" << std::endl;
if (opt.get_name() == "name") {
auto name = opt.get<inicpp::string_ini_t>();
std::cout << name << "' ";
if (name == "UDISK") {
std::cout << "Remaining space.";
}
} else if (opt.get_name() == "size") {
std::cout << opt.get<inicpp::unsigned_ini_t>() / 0x300 << "MB - " << opt.get<inicpp::unsigned_ini_t>() << "KB";
}
}
std::cout << std::endl;
}
std::cout << cc::reset;
}

void FEX2CFG::get_partition_real_size() {
Expand Down
2 changes: 1 addition & 1 deletion src/OpenixCard/FEX2CFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/OpenixCard/LOG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/OpenixCard/OpenixCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>\n"
<< cc::reset << std::endl;
}
Expand Down Expand Up @@ -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");
}

0 comments on commit de271c7

Please sign in to comment.