### Armake2 Command-Line Interface Source: https://github.com/koffeinflummi/armake2/blob/master/README.md Demonstrates the various commands available in the Armake2 CLI, including options for rapifying, preprocessing, binarizing, building, packing, inspecting, unpacking, signing, and verifying files. ```bash armake2 rapify [-v] [-f] [-w ]... [-i ]... [ []] armake2 preprocess [-v] [-f] [-w ]... [-i ]... [ []] armake2 derapify [-v] [-f] [-d ] [ []] armake2 binarize [-v] [-f] [-w ]... armake2 build [-v] [-f] [-w ]... [-i ]... [-x ]... [-e ]... [-k ] [-s ] [] armake2 pack [-v] [-f] [] armake2 inspect [-v] [] armake2 unpack [-v] [-f] armake2 cat [-v] [] armake2 keygen [-v] [-f] armake2 sign [-v] [-f] [-s ] [--v2] [] armake2 verify [-v] [] armake2 paa2img [-v] [-f] [ []] armake2 img2paa [-v] [-f] [-z] [-t ] [ []] armake2 (-h | --help) armake2 --version ``` -------------------------------- ### Armake2 Command-Line Build Workflow Source: https://context7.com/koffeinflummi/armake2/llms.txt Demonstrates a typical command-line workflow for building a signed Arma 3 mod using the `armake2` tool. It covers preprocessing configs, rapifying them, and building a PBO with binarization and signing capabilities. Excludes specific file types and sets author metadata. ```bash # Preprocess a config file armake2 preprocess -i /path/to/includes config.cpp config.preprocessed # Rapify the preprocessed config armake2 rapify -i /path/to/includes config.cpp config.bin # Build a PBO with binarization from directory armake2 build \ -i /path/to/includes \ -x "*.psd" -x "*.txt" \ -e "author=MyName" \ -k my_key.biprivatekey \ @my_mod/addons/main \ my_mod.pbo ``` -------------------------------- ### Building PBOs from Directories Source: https://context7.com/koffeinflummi/armake2/llms.txt This function creates a PBO archive from a specified directory. It supports automatic binarization of configurations and allows exclusion of specific file patterns. The PBO is then written to an output file. ```APIDOC ## POST /pbo/build ### Description Creates a PBO archive from a directory with automatic binarization and config rapification. ### Method POST ### Endpoint /pbo/build ### Parameters #### Request Body - **source_dir** (string) - Required - The path to the source directory for the PBO. - **binarization** (boolean) - Optional - Whether to enable binarization for configuration files (defaults to true). - **exclude_patterns** (array of strings) - Optional - A list of glob patterns for files to exclude. - **include_folders** (array of strings) - Optional - A list of relative folder paths to include within the PBO. ### Request Example ```json { "source_dir": "@my_mod/addons/main", "exclude_patterns": ["*.psd", "*.txt"], "include_folders": ["."] } ``` ### Response #### Success Response (200) - **pbo_file_name** (string) - The name of the generated PBO file. - **file_count** (integer) - The number of files included in the PBO. #### Response Example ```json { "pbo_file_name": "my_mod.pbo", "file_count": 125 } ``` ``` -------------------------------- ### Signing and Verifying PBO Files Source: https://github.com/koffeinflummi/armake2/blob/master/README.md Code snippets for signing and verifying PBO files using Armake2. This involves using a private key to sign a PBO and a public key to verify its integrity. ```bash armake2 sign [-v] [-f] [-s ] [--v2] [] armake2 verify [-v] [] ``` -------------------------------- ### Build PBOs from Directories (Rust) Source: https://context7.com/koffeinflummi/armake2/llms.txt This Rust code builds a PBO archive from a specified directory, enabling automatic binarization and config rapification. It takes a source directory, exclusion patterns, and inclusion folders as input. The resulting PBO is written to an output file. ```Rust use armake2::pbo::PBO; use std::path::PathBuf; use std::fs::File; // Build a PBO from a mod directory with binarization enabled let source_dir = PathBuf::from("@my_mod/addons/main"); let exclude_patterns = vec!["*.psd".to_string(), "*.txt".to_string()]; let include_folders = vec![PathBuf::from(".")]; // Create PBO with binarization, excluding certain file patterns let pbo = PBO::from_directory( source_dir, true, // enable binarization &exclude_patterns, &include_folders ).expect("Failed to create PBO"); // Write to output file let mut output_file = File::create("my_mod.pbo").expect("Failed to create output file"); pbo.write(&mut output_file).expect("Failed to write PBO"); println!("PBO created with {} files", pbo.files.len()); ``` -------------------------------- ### Build Armake2 with Cargo Source: https://github.com/koffeinflummi/armake2/blob/master/README.md Instructions for compiling and running the Armake2 project using Cargo, Rust's package manager. This includes commands for both development builds and release builds. ```bash cargo run cargo build --release ``` -------------------------------- ### Sign PBO Files in Rust Source: https://context7.com/koffeinflummi/armake2/llms.txt Signs a PBO file using a provided private key, generating a verification signature file. Supports both command-line execution and programmatic signing via the `armake2` library. Requires the `armake2` crate and relevant PBO files. Uses BISignVersion::V3 for Arma 3 compatibility. ```rust use armake2::sign::{BIPrivateKey, BISignVersion, cmd_sign}; use std::path::PathBuf; let privatekey_path = PathBuf::from("my_mod_key.biprivatekey"); let pbo_path = PathBuf::from("my_mod.pbo"); let signature_path = Some(PathBuf::from("my_mod.pbo.my_mod_key.bisign")); // Sign with v3 signature (recommended for Arma 3) cmd_sign( privatekey_path, pbo_path, signature_path, BISignVersion::V3 ).expect("Failed to sign PBO"); println!("PBO signed successfully"); // Or sign programmatically use armake2::pbo::PBO; use std::fs::File; let mut key_file = File::open("key.biprivatekey").expect("Failed to open key"); let private_key = BIPrivateKey::read(&mut key_file).expect("Failed to read key"); let mut pbo_file = File::open("mod.pbo").expect("Failed to open PBO"); let pbo = PBO::read(&mut pbo_file).expect("Failed to read PBO"); let signature = private_key.sign(&pbo, BISignVersion::V3); let mut sig_file = File::create("mod.pbo.key.bisign").expect("Failed to create signature"); signature.write(&mut sig_file).expect("Failed to write signature"); ``` -------------------------------- ### Preprocess Configuration Files (Rust) Source: https://context7.com/koffeinflummi/armake2/llms.txt This Rust code preprocesses Arma config files, handling C-style preprocessor directives. It takes an input string and optional origin/include folders. The output contains the processed config with expanded macros. Information about line origins is also provided. ```Rust use armake2::preprocess::preprocess; use std::path::PathBuf; let input = r#" #define WEAPON_DAMAGE 42 #define QUOTE(x) #x #define DOUBLES(x,y) x##_##y class CfgWeapons { class MyWeapon { displayName = QUOTE(DOUBLES(Custom, Rifle)); damage = WEAPON_DAMAGE; }; }; "#.to_string(); let origin = Some(PathBuf::from("config.cpp")); let include_folders = vec![PathBuf::from(".")]; // Preprocess with macro expansion let (output, info) = preprocess(input, origin, &include_folders) .expect("Failed to preprocess"); // Output contains expanded macros println!("{}", output.trim()); // Line origins map each output line to its source file and line number for (line_num, origin_file) in info.line_origins { println!("Line {} from {:?}:{:?}", line_num, origin_file.0, origin_file.1); } ``` -------------------------------- ### Preprocessing Configuration Files Source: https://context7.com/koffeinflummi/armake2/llms.txt Processes Arma config files with C-style preprocessor directives, including macros, includes, and conditionals. It returns the preprocessed content and information about line origins. ```APIDOC ## POST /preprocess/config ### Description Processes Arma config files with C-style preprocessor directives, including macros, includes, and conditionals. ### Method POST ### Endpoint /preprocess/config ### Parameters #### Request Body - **input** (string) - Required - The raw content of the configuration file to preprocess. - **origin** (string) - Optional - The origin path of the input file (e.g., "config.cpp"). - **include_folders** (array of strings) - Optional - A list of directories to search for included files. ### Request Example ```json { "input": "#define VERSION 1.0\nclass CfgPatches {\n class MyMod {\n units[] = {};\n weapons[] = {};\n requiredVersion = VERSION;\n };\n};", "origin": "config.cpp", "include_folders": ["."] } ``` ### Response #### Success Response (200) - **output** (string) - The preprocessed configuration content. - **info** (object) - Information about the line origins in the preprocessed output. - **line_origins** (array of objects) - Maps output lines to their source file and line number. - **line_num** (integer) - The line number in the output. - **origin_file** (object) - **file** (string) - The source file path. - **line** (integer) - The source line number. #### Response Example ```json { "output": "class CfgPatches {\n class MyMod {\n units[] = {};\n weapons[] = {};\n requiredVersion = 1.0;\n };\n};", "info": { "line_origins": [ { "line_num": 1, "origin_file": { "file": "config.cpp", "line": 1 } }, { "line_num": 2, "origin_file": { "file": "config.cpp", "line": 2 } } ] } } ``` ``` -------------------------------- ### Pack Directory to PBO (Rust Library) Source: https://context7.com/koffeinflummi/armake2/llms.txt Programmatically packs a directory's contents into a PBO archive using the armake2 Rust library. This operation can exclude specific files and include custom header information without binarization. ```rust use armake2::pbo::cmd_pack; use std::path::PathBuf; use std::fs::File; let source_dir = PathBuf::from("@my_mod/addons/sources"); let mut output_file = File::create("sources.pbo").expect("Failed to create file"); let exclude_patterns = vec!["*.tmp".to_string()]; let header_extensions = vec!["version=1.0.0".to_string(), "author=MyName".to_string()]; // Pack directory without any processing cmd_pack( source_dir, &mut output_file, &header_extensions, &exclude_patterns ).expect("Failed to pack PBO"); println!("Source PBO packed successfully"); ``` -------------------------------- ### Reading and Inspecting PBO Files Source: https://context7.com/koffeinflummi/armake2/llms.txt This function reads an existing PBO archive from a file and provides access to its contents, including header extensions and file list. It also allows checking for a checksum if present. ```APIDOC ## GET /pbo/read ### Description Reads an existing PBO archive and inspects its contents, including header extensions and file checksum. ### Method GET ### Endpoint /pbo/read ### Parameters #### Query Parameters - **pbo_file** (string) - Required - The path to the PBO file to read. ### Response #### Success Response (200) - **header_extensions** (object) - Key-value pairs of header metadata. - **files** (object) - A map where keys are filenames and values are file sizes in bytes. - **checksum** (string) - The checksum of the PBO file, if present (hex encoded). #### Response Example ```json { "header_extensions": { "prefix": "my_mod_prefix" }, "files": { "config.bin": 1024, "textures/my_texture.paa": 2048 }, "checksum": "a1b2c3d4e5f6" } ``` ``` -------------------------------- ### Generate Keypair for Signing (armake2) Source: https://context7.com/koffeinflummi/armake2/llms.txt Generates a public/private key pair for signing PBO files. This operation creates two files: a private key for signing and a public key for verification. ```shell armake2 keygen my_mod_key # Creates: my_mod_key.biprivatekey and my_mod_key.bikey ``` -------------------------------- ### Read and Inspect PBO Files (Rust) Source: https://context7.com/koffeinflummi/armake2/llms.txt This Rust code reads an existing PBO archive and inspects its contents. It opens a PBO file, reads its data, and allows inspection of header extensions, file listings, and checksums. This is useful for verifying PBO integrity and accessing its internal structure. ```Rust use armake2::pbo::PBO; use std::fs::File; // Open and read an existing PBO file let mut input_file = File::open("my_mod.pbo").expect("Failed to open PBO"); let pbo = PBO::read(&mut input_file).expect("Failed to read PBO"); // Inspect header extensions (metadata) if let Some(prefix) = pbo.header_extensions.get("prefix") { println!("PBO prefix: {}", prefix); } // List all files in the PBO for (filename, cursor) in pbo.files.iter() { println!("{}: {} bytes", filename, cursor.get_ref().len()); } // Verify checksum is present (only for read PBOs) if let Some(checksum) = &pbo.checksum { println!("PBO checksum: {:x?}", checksum); } ``` -------------------------------- ### Generate Cryptographic Keypairs in Rust Source: https://context7.com/koffeinflummi/armake2/llms.txt Generates BI-format private and public key files essential for signing PBO files. Supports both command-line utility calls and programmatic generation using the `armake2` library. Requires the `armake2` crate. ```rust use armake2::sign::{BIPrivateKey, cmd_keygen}; use std::path::PathBuf; // Generate a new 1024-bit keypair (Arma 3 standard) let keyname = PathBuf::from("my_mod_key"); // Creates my_mod_key.biprivatekey and my_mod_key.bikey files cmd_keygen(keyname).expect("Failed to generate keypair"); // Or generate programmatically let private_key = BIPrivateKey::generate(1024, "my_mod_key".to_string()); let public_key = private_key.to_public_key(); // Save keys to files use std::fs::File; let mut private_file = File::create("my_key.biprivatekey").expect("Failed to create file"); private_key.write(&mut private_file).expect("Failed to write private key"); let mut public_file = File::create("my_key.bikey").expect("Failed to create file"); public_key.write(&mut public_file).expect("Failed to write public key"); println!("Keypair generated successfully"); ``` -------------------------------- ### Unpacking PBO Archives Source: https://context7.com/koffeinflummi/armake2/llms.txt This function extracts all files from a given PBO archive to a specified output directory. ```APIDOC ## POST /pbo/unpack ### Description Extracts all files from a PBO archive to a target directory. ### Method POST ### Endpoint /pbo/unpack ### Parameters #### Request Body - **pbo_file** (string) - Required - The path to the PBO file to unpack. - **output_dir** (string) - Required - The directory where the files should be extracted. ### Request Example ```json { "pbo_file": "my_mod.pbo", "output_dir": "unpacked_mod" } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating successful unpacking. #### Response Example ```json { "message": "PBO unpacked successfully" } ``` ``` -------------------------------- ### Sign PBO File (armake2) Source: https://context7.com/koffeinflummi/armake2/llms.txt Signs an existing PBO file using a provided private key. This is crucial for ensuring the integrity and authenticity of mod files, especially for multiplayer. ```shell armake2 sign my_key.biprivatekey my_mod.pbo ``` -------------------------------- ### Unpack PBO to Directory (armake2) Source: https://context7.com/koffeinflummi/armake2/llms.txt Unpacks the contents of a PBO archive into a specified directory. This allows access to the individual files within the PBO for modification or inspection. ```shell armake2 unpack my_mod.pbo unpacked_output/ ``` -------------------------------- ### Verify PBO Signatures in Rust Source: https://context7.com/koffeinflummi/armake2/llms.txt Verifies the cryptographic signature of a PBO file against a given public key. This function checks the integrity and authenticity of the PBO. Supports both command-line verification and programmatic checks using the `armake2` library. Requires the `armake2` crate, PBO files, and signature files. ```rust use armake2::sign::{BIPublicKey, BISign, cmd_verify}; use std::path::PathBuf; let publickey_path = PathBuf::from("my_mod_key.bikey"); let pbo_path = PathBuf::from("my_mod.pbo"); let signature_path = Some(PathBuf::from("my_mod.pbo.my_mod_key.bisign")); // Verify signature (returns Ok(()) if valid, Err if invalid) match cmd_verify(publickey_path, pbo_path, signature_path) { Ok(()) => println!("Signature is valid"), Err(e) => eprintln!("Signature verification failed: {}", e), } // Or verify programmatically use armake2::pbo::PBO; use std::fs::File; let mut key_file = File::open("key.bikey").expect("Failed to open key"); let public_key = BIPublicKey::read(&mut key_file).expect("Failed to read key"); let mut pbo_file = File::open("mod.pbo").expect("Failed to open PBO"); let pbo = PBO::read(&mut pbo_file).expect("Failed to read PBO"); let mut sig_file = File::open("mod.pbo.key.bisign").expect("Failed to open signature"); let signature = BISign::read(&mut sig_file).expect("Failed to read signature"); public_key.verify(&pbo, &signature).expect("Verification failed"); println!("PBO signature verified successfully"); ``` -------------------------------- ### Verify Signed PBO File (armake2) Source: https://context7.com/koffeinflummi/armake2/llms.txt Verifies the signature of a signed PBO file using its corresponding public key. This confirms that the PBO has not been tampered with since it was signed. ```shell armake2 verify my_key.bikey my_mod.pbo ``` -------------------------------- ### Unpack PBO Archives (Rust) Source: https://context7.com/koffeinflummi/armake2/llms.txt This Rust code extracts all files from a PBO archive to a specified target directory. It utilizes the `cmd_unpack` function to handle the unpacking process, taking an input file and an output directory as arguments. This is essential for accessing the contents of a PBO file. ```Rust use armake2::pbo::cmd_unpack; use std::fs::File; use std::path::PathBuf; // Open PBO file and unpack to directory let mut input_file = File::open("my_mod.pbo").expect("Failed to open PBO"); let output_dir = PathBuf::from("unpacked_mod"); cmd_unpack(&mut input_file, output_dir).expect("Failed to unpack PBO"); println!("PBO unpacked successfully"); ``` -------------------------------- ### Inspect PBO Contents (armake2) Source: https://context7.com/koffeinflummi/armake2/llms.txt Inspects the contents of a PBO file, displaying metadata and file structure without extracting them. This is useful for understanding the archive's composition. ```shell armake2 inspect my_mod.pbo ``` -------------------------------- ### Extract Specific File from PBO (armake2) Source: https://context7.com/koffeinflummi/armake2/llms.txt Extracts a single, specific file from a PBO archive and redirects its content to a new file. This is useful for retrieving individual configuration or data files. ```shell armake2 cat my_mod.pbo config.bin > extracted_config.bin ``` -------------------------------- ### Derapify Config File (armake2) Source: https://context7.com/koffeinflummi/armake2/llms.txt Converts a binarized configuration file back into its human-readable text format. This is essential for editing or understanding compiled configuration files. ```shell armake2 derapify config.bin config.cpp ``` -------------------------------- ### Rapify and Derapify Configs in Rust Source: https://context7.com/koffeinflummi/armake2/llms.txt Converts between unrapified text and rapified binary configuration formats using the armake2 library. Handles parsing from strings, writing to files, and in-memory conversions. Requires the `armake2` crate. ```rust use armake2::config::Config; use std::path::PathBuf; use std::fs::File; // Parse unrapified config from string let config_text = r#"# #define VALUE 100 class CfgVehicles { class Car { maxSpeed = VALUE; armor = 50; crew[] = {"Soldier1", "Soldier2"}; }; }; "#.to_string(); let include_folders = vec![PathBuf::from(".")]; let config = Config::from_string(config_text, None, &include_folders) .expect("Failed to parse config"); // Write rapified binary format let mut rapified_file = File::create("config.bin").expect("Failed to create file"); config.write_rapified(&mut rapified_file).expect("Failed to write rapified config"); // Or get as in-memory cursor let cursor = config.to_cursor().expect("Failed to create cursor"); assert_eq!(&cursor.get_ref()[..4], b"\0raP"); // Convert back to text format let text_output = config.to_string().expect("Failed to convert to string"); println!("{}", text_output); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.