### Prebuilt Gems Packaging (Bash) Source: https://context7.com/tamatebako/tebako/llms.txt This example shows how to package an application that relies on prebuilt gem files (`.gem`). The `--root` points to the directory containing the gem files, and `--entry-point` specifies the executable from one of the gems. The packaging process installs these gems. ```bash # Project structure: # gems/ # mygem-1.0.0.gem # anothergem-2.1.0.gem tebako press \ --root=gems \ --entry-point=mygem \ --output=mygem-package # Runs: gem install *.gem # Executes: /bin/mygem ``` -------------------------------- ### Configure MinGW ucrt64 for Windows Source: https://github.com/tamatebako/tebako/blob/main/INSTALLATION.adoc Enables the MinGW ucrt64 environment and installs essential development packages using pacman. This setup is necessary for certain Windows build environments. ```sh idk enable ucrt64 pacman -S git tar bison flex pactoys bash -c "pacboy sync toolchain:p make:p cmake:p boost:p diffutils:p libevent:p double-conversion:p fmt:p glog:p dlfcn:p gtest:p autotools:p ncurses:p libyaml:p" ``` -------------------------------- ### Example: Create Tebako Application Package Source: https://github.com/tamatebako/tebako/blob/main/README.adoc Illustrates the creation of a Tebako application package. This example specifies the output package name ('tebako-application-package'), the entry point script ('start.rb'), the project root directory ('~/projects/myproject'), and the Ruby version ('3.4.1'). ```sh tebako press -m application \ -o tebako-application-package \ -e start.rb \ -r ~/projects/myproject \ -R 3.4.1 ``` -------------------------------- ### Install Clang/Clang++ on Ubuntu Source: https://github.com/tamatebako/tebako/blob/main/INSTALLATION.adoc Installs Clang C/C++ compiler version 12 or later on Ubuntu using apt. It configures system alternatives to use the installed Clang binaries. ```sh apt install -y clang-12 update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 150 update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-12 150 ``` -------------------------------- ### Example: Create and Run Tebako Bundle Package Source: https://github.com/tamatebako/tebako/blob/main/README.adoc An example demonstrating the creation of a Tebako bundle package for a project located at '~/projects/myproject' with Ruby version 3.4.1, named 'myproject-bundle'. It then shows how to run the created bundle package. ```sh $ tebako bundle create -o myproject-bundle -r ~/projects/myproject -R 3.4.1 # => creates `myproject-bundle`, a bundle package for Ruby 3.4.1 $ myproject-bundle ``` -------------------------------- ### Bundled Project (Gemfile) Packaging (Bash) Source: https://context7.com/tamatebako/tebako/llms.txt This example shows how to package a Ruby project that uses a Gemfile, such as a Rails application. It includes specifying the root directory, the entry point (e.g., `bin/rails`), the output name, and optionally the Ruby version. The process involves running `bundle install`. ```bash # Project structure: # rails-app/ # Gemfile # Gemfile.lock # app/ # config/ # bin/rails tebako press \ --root=rails-app \ --entry-point=bin/rails \ --output=rails-server \ --Ruby=3.2.4 # Runs: bundle install # Files copied to: /local/ # Executes: /local/bin/rails ``` -------------------------------- ### Tebako Setup Command Source: https://github.com/tamatebako/tebako/blob/main/README.adoc The `tebako setup` command collects required packages, builds the environment, and prepares for packaging. It can take up to an hour to complete. Optional parameters allow specifying the Tebako root folder, Ruby version, development mode, and the path to the tebafile. ```sh tebako setup \ [-p|--prefix=] \ [-R|--Ruby=] \ [-D|--devmode] \ [-t|--tebafile=] ``` -------------------------------- ### Build and Install Gem Source: https://github.com/tamatebako/tebako/blob/main/README.adoc Commands to build and install a Ruby gem. Assumes a .gemspec file is present in the root folder. The entry point is expected to be an executable installed in the binary folder. ```sh gem build gem install ``` -------------------------------- ### Install GCC/G++ on Ubuntu Source: https://github.com/tamatebako/tebako/blob/main/INSTALLATION.adoc Installs GNU C/C++ compilers version 10 or later on Ubuntu using apt. It updates the system's alternatives to use the newly installed compilers. ```sh apt install -y gcc-10 g++-10 update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10 ``` -------------------------------- ### Example: Create Tebako Runtime Package for Ruby 3.4.1 Source: https://github.com/tamatebako/tebako/blob/main/README.adoc An example demonstrating the creation of a Tebako runtime package specifically for Ruby version 3.4.1. The output is a directory named 'tebako-ruby-3.4.1' which contains the runtime environment. ```sh tebako press -o tebako-ruby-3.4.1 -R 3.4.1 ``` -------------------------------- ### Install Prebuilt Gems Source: https://github.com/tamatebako/tebako/blob/main/README.adoc Command to install prebuilt .gem files located in the root folder. Tebako installs these gems in a random order. The entry point is assumed to be an executable installed in the binary folder. ```sh gem install ``` -------------------------------- ### Example: Packaging and Running a Ruby Application Source: https://github.com/tamatebako/tebako/blob/main/README.adoc Demonstrates the process of creating separate runtime and application packages for a simple Ruby script and then running the application using the packaged runtime. It includes the creation of packages and the execution command with arguments. ```Ruby puts "Hello, #{ARGV[0]}!" ``` ```sh tebako press -m runtime -o tebako-runtime-package tebako press -m application -o tebako-application-package -e hello.rb -r test tebako-runtime-package --tebako-run tebako-application-package Maxim ``` -------------------------------- ### Tebako Packaging Example Source: https://github.com/tamatebako/tebako/blob/main/README.adoc Demonstrates how to use the `tebako press` command to package a Ruby project. It specifies the project root, entry point, and the desired output file name. ```sh tebako press \ --root='~/projects/myproject' \ --entry=start.rb \ --output=/temp/myproject.tebako ``` -------------------------------- ### Install Development Tools on Ubuntu Source: https://github.com/tamatebako/tebako/blob/main/INSTALLATION.adoc Installs a comprehensive set of development tools and libraries required for Tebako on Ubuntu. Includes build essentials, version control, compression libraries, and various development headers. ```sh apt-get -y install sudo git curl build-essential pkg-config bison flex autoconf \n binutils-dev libevent-dev acl-dev libfmt-dev libjemalloc-dev libiberty-dev \n libdouble-conversion-dev liblz4-dev liblzma-dev libssl-dev libunwind-dev \n libboost-filesystem-dev libboost-program-options-dev libboost-system-dev \n libboost-iostreams-dev libboost-date-time-dev libboost-context-dev \n libboost-regex-dev libboost-thread-dev libbrotli-dev libdwarf-dev libelf-dev \n libgoogle-glog-dev libffi-dev libgdbm-dev libyaml-dev libncurses-dev \n libreadline-dev libutfcpp-dev ruby-dev ruby-bundler ``` -------------------------------- ### Install Homebrew Bundles on macOS Source: https://github.com/tamatebako/tebako/blob/main/INSTALLATION.adoc Installs all Tebako dependencies on macOS using Homebrew and the provided Brewfile. This is the recommended method for setting up the development environment. ```sh brew bundle ``` -------------------------------- ### Build and Install Bundled Gem Source: https://github.com/tamatebako/tebako/blob/main/README.adoc Commands to install dependencies, build, and install a Ruby gem when both a Gemfile and .gemspec are present. This ensures all project dependencies are handled correctly before gem installation. ```sh bundle install bundle exec gem build bundle exec gem install ``` -------------------------------- ### Run Tebako Bundle Package Source: https://github.com/tamatebako/tebako/blob/main/README.adoc Command to execute a Tebako bundle package. This will start the packaged application. ```sh $ ``` -------------------------------- ### Example: Extracting Metanorma Package Content Source: https://github.com/tamatebako/tebako/blob/main/README.adoc Provides a concrete example of using the `--tebako-extract` option to extract the filesystem content of the 'metanorma' package into a directory named 'temp-image'. ```sh metanorma --tebako-extract temp-image ``` -------------------------------- ### Install CMake 3.20+ on Ubuntu Source: https://github.com/tamatebako/tebako/blob/main/INSTALLATION.adoc Installs CMake version 3.20 or later on Ubuntu. This script removes existing CMake, adds the Kitware APT repository, and then installs the latest CMake version. ```sh apt-get remove --purge --auto-remove cmake apt-get update apt-get install -y software-properties-common lsb-release curl apt-get clean all curl https://apt.kitware.com/kitware-archive.sh | bash apt-get install cmake ``` -------------------------------- ### Install Tebako Ruby Gem Source: https://github.com/tamatebako/tebako/blob/main/INSTALLATION.adoc Installs the Tebako gem using the Ruby package manager. A pre-existing Ruby development environment is required. ```sh gem install tebako ``` -------------------------------- ### Prepare Tebako Packaging Environment Source: https://context7.com/tamatebako/tebako/llms.txt Shows how to initialize the Tebako environment using the `tebako setup` command. This includes setting up with default Ruby, specifying a Ruby version and custom prefix, using environment variables for the prefix, and configuring via a `.tebako.yml` file. ```bash tebako setup ``` ```bash tebako setup \ --Ruby=3.2.5 \ --prefix=/opt/tebako ``` ```bash export TEBAKO_PREFIX=/home/user/tebako-env tebako setup --Ruby=3.3.7 ``` ```bash tebako setup --tebafile=.tebako.yml ``` -------------------------------- ### Install Homebrew Packages Manually on macOS Source: https://github.com/tamatebako/tebako/blob/main/INSTALLATION.adoc Installs necessary packages on macOS manually using Homebrew. This includes tools like bison, pkg-config, and various libraries such as boost, jemalloc, and openssl. ```sh brew update brew install gnu-sed bash pkg-config bison flex binutils libffi gdbm zlib ncurses double-conversion boost jemalloc fmt glog libevent libsodium lz4 xz libyaml openssl@3 ``` -------------------------------- ### Start Interactive Tebako Container Session Source: https://github.com/tamatebako/tebako/blob/main/README.adoc This command starts an interactive bash session inside a Tebako Docker container, mounting a local application folder to '/mnt/w'. This allows for executing packaging commands directly within the container environment. Replace '' with the path to your application and '' with the desired image tag. ```sh docker run -it --rm -v :/mnt/w \ ghcr.io/tamatebako/tebako-:latest bash ``` -------------------------------- ### Gem Packaging (Bash) Source: https://context7.com/tamatebako/tebako/llms.txt Demonstrates packaging a Ruby gem project. It requires specifying the root directory of the gem, the entry point (usually the gem's executable name), and the output package name. This process typically involves building the gem and installing it. ```bash # Project structure: # mygem/ # mygem.gemspec # lib/ # bin/ # mygem tebako press \ --root=mygem \ --entry-point=mygem \ --output=mygem-package # Runs: gem build && gem install # Executes: /bin/mygem ``` -------------------------------- ### Install APK Packages on Alpine Source: https://github.com/tamatebako/tebako/blob/main/INSTALLATION.adoc Installs all prerequisite packages for Tebako on Alpine Linux version 3.17 using the apk package manager. This command ensures all necessary build tools and libraries are available. ```sh apk --no-cache --upgrade add build-base cmake git bash autoconf boost-static \n boost-dev flex-dev bison make binutils-dev libevent-dev acl-dev sed python3 \n pkgconfig lz4-dev openssl-dev zlib-dev xz ninja zip unzip curl libdwarf-dev \n libunwind-dev gflags-dev elfutils-dev libevent-static openssl-libs-static \n lz4-static xz-dev zlib-static libunwind-static acl-static tar libffi-dev \n gdbm-dev yaml-dev yaml-static ncurses-dev ncurses-static readline-dev \n readline-static p7zip ruby-dev gcompat gettext-dev gperf brotli-dev \n brotli-static jemalloc-dev fmt-dev xz-static ``` -------------------------------- ### Package Application Interactively in Tebako Container Source: https://github.com/tamatebako/tebako/blob/main/README.adoc After starting an interactive session inside the Tebako container, this command executes the 'tebako press' command with your specific parameters to package an application. The example shows packaging a Ruby application named 'fontist' to './fontist-package'. Ensure you have started the container interactively first. ```sh $ docker run -it --rm -v $PWD:/mnt/w ghcr.io/tamatebako/tebako-:latest bash tebako press ``` -------------------------------- ### Bundled Gem Packaging (Bash) Source: https://context7.com/tamatebako/tebako/llms.txt This scenario covers packaging a gem project that also has a Gemfile, indicating it might have development dependencies or a more complex build process. It includes specifying the root, entry point, output, and Ruby version. The packaging process includes `bundle install` before building and installing the gem. ```bash # Project structure: # fontist/ # fontist.gemspec # Gemfile # lib/ # exe/ # fontist tebako press \ --root=fontist \ --entry-point=fontist \ --output=fontist \ --Ruby=3.3.7 # Runs: bundle install && bundle exec gem build && bundle exec gem install # Executes: /bin/fontist ``` -------------------------------- ### Check Rosetta 2 Emulation on macOS Source: https://github.com/tamatebako/tebako/blob/main/INSTALLATION.adoc This script checks if the system is running on Apple Silicon under Rosetta 2 emulation and sets the LG_VADDR environment variable accordingly. It differentiates between Rosetta 2, native Apple Silicon, and Intel Silicon. ```bash if [[ "$ARCH" == "x86_64" && $(sysctl -n sysctl.proc_translated) == "1" ]]; then echo "Running on Apple Silicon under Rosetta 2 emulation" export LG_VADDR=39 elif [[ "$ARCH" == "arm64" ]]; then echo "Running on Apple Silicon" export LG_VADDR=39 else echo "Running on Intel Silicon" export LG_VADDR=48 fi echo "Setting lg-vaddr to $LG_VADDR" ``` -------------------------------- ### Using Tebako Docker Containers Source: https://context7.com/tamatebako/tebako/llms.txt Provides examples of using Tebako within Docker containers. This includes pulling the latest Tebako image, packaging an application by mounting the local directory, and running interactive sessions inside the container for manual packaging. It also shows using an Alpine Linux container for musl-based packages. ```bash docker pull ghcr.io/tamatebako/tebako-ubuntu-20.04:latest ``` ```bash docker run -v $PWD:/mnt/w \ -t ghcr.io/tamatebako/tebako-ubuntu-20.04:latest \ tebako press \ --root=/mnt/w/myapp \ --entry-point=start.rb \ --output=/mnt/w/myapp-package \ --Ruby=3.2.4 ``` ```bash docker run -it --rm -v $PWD:/mnt/w \ ghcr.io/tamatebako/tebako-ubuntu-20.04:latest bash ``` ```bash # Then inside container: tebako press \ --root=/mnt/w/fontist \ --entry-point=fontist \ --output=/mnt/w/fontist-package \ --Ruby=3.3.7 ``` ```bash docker run -v $PWD:/mnt/w \ -t ghcr.io/tamatebako/tebako-alpine-3.17:latest \ tebako press \ --root=/mnt/w/app \ --entry-point=main.rb \ --output=/mnt/w/app-alpine ``` -------------------------------- ### C/C++ Conditional Formatting Example Source: https://github.com/tamatebako/tebako/blob/main/CONTRIBUTING.adoc Demonstrates the required use of braces for conditional statements in C/C++ code, even for single-line blocks. This ensures code consistency and readability. ```c if (something) { return val; } ``` -------------------------------- ### Set Target Installation Directories in CMake Source: https://github.com/tamatebako/tebako/blob/main/CMakeLists.txt This CMake code defines target directories for installing binaries, libraries, and local files within the packaged filesystem structure. It sets variables like 'TBD' (binary), 'TLIBD' (library), and 'TLD' (local), pointing to subdirectories within 'DATA_SRC_DIR'. Additionally, it defines 'TGD' for installing Ruby gems, ensuring proper organization of packaged application components. ```cmake set (TBD ${DATA_SRC_DIR}/bin) set (TLIBD ${DATA_SRC_DIR}/lib) set (TLD ${DATA_SRC_DIR}/local) set (TGD ${DATA_SRC_DIR}/lib/ruby/gems/${RUBY_API_VER}) ``` -------------------------------- ### Tebafile YAML Configuration for Tebako Source: https://context7.com/tamatebako/tebako/llms.txt Explains how to configure Tebako using a `.tebako.yml` file in YAML format. The configuration can specify options like `prefix`, `Ruby` version, `log-level`, and packaging `mode`. Examples show how to use the Tebafile and how command-line options override Tebafile settings. ```yaml # .tebako.yml options: prefix: /tmp/tebako Ruby: 3.2.4 log-level: debug mode: bundle ``` -------------------------------- ### C/C++ Default Failure Value Example Source: https://github.com/tamatebako/tebako/blob/main/CONTRIBUTING.adoc Illustrates the recommended practice of initializing `ret` variables with a default failure value in C/C++. This helps in managing return codes and error handling. ```c rnp_result_t ret = RNP_ERROR_GENERIC; // ... return ret; ``` -------------------------------- ### Ruby Class and Method Documentation with YARD Source: https://github.com/tamatebako/tebako/blob/main/CONTRIBUTING.adoc Ruby code documentation should use YARD. This example demonstrates documenting a 'Person' class, including its attributes, initialization, and a predicate method. It specifies return types, parameter types, and descriptions for clarity. ```ruby # A person class to represent individuals class Person # @return [String] the person's full name attr_reader :name # Creates a new person # # @param name [String] the person's full name # @param age [Integer] the person's age in years # @return [Person] a new instance of Person def initialize(name, age) @name = name @age = age end # Determines if the person is an adult # # @return [Boolean] true if the person is 18 or older def adult? @age >= 18 end end ``` -------------------------------- ### C/C++ Local Variable Storage Class Example Source: https://github.com/tamatebako/tebako/blob/main/CONTRIBUTING.adoc Contrasts the incorrect usage of the `static` storage class for non-constant local variables with the correct usage for constant local variables in C/C++. This promotes efficient memory management. ```c // Not OK int somefunc() { static char buffer[256]; //... } // OK int somefunc() { static const uint16_t some_data[] = { 0x00, 0x01, 0x02, //... }; } ``` -------------------------------- ### Print Build Configuration Summary in CMake Source: https://github.com/tamatebako/tebako/blob/main/CMakeLists.txt This CMake code prints a summary of the current build configuration to the console using 'message(STATUS)'. It displays information about the Ruby version and source directory, the DwarFS wrapper status and version/tag, and various filesystem-related paths including the mount point. This output is useful for verifying the build setup. ```cmake message("Configuration summary:") message(STATUS "ruby: v${RUBY_VER} at ${RUBY_SOURCE_DIR}") if(DWARFS_PRELOAD) message(STATUS "dwarfs with tebako wrapper: deploying v${LIBDWARFS_WR_VER} to ${LIBDWARFS_WR_SOURCE_DIR}") else(DWARFS_PRELOAD) message(STATUS "dwarfs with tebako wrapper: @${DWARFS_WR_TAG} at ${DWARFS_WR_SOURCE_DIR}") endif(DWARFS_PRELOAD) message(STATUS "DATA_SRC_DIR: ${DATA_SRC_DIR}") message(STATUS "DATA_PRE_DIR: ${DATA_PRE_DIR}") message(STATUS "DATA_BIN_DIR: ${DATA_BIN_DIR}") message(STATUS "DATA_BIN_FILE: ${DATA_BIN_FILE}") message(STATUS "Target binary directory: ${TBD}") message(STATUS "Target library directory: ${TLIBD}") message(STATUS "Target local directory: ${TLD}") message(STATUS "Target Gem directory: ${TGD}") message(STATUS "FS_MOUNT_POINT: ${FS_MOUNT_POINT}") message(STATUS "Building for Win32 Ruby (RB_W32): ${RB_W32}") message(STATUS "Removing GLIBC_PRIVATE reference: ${WITH_PATCHELF}") ``` -------------------------------- ### Tebako Clean Ruby Command Source: https://github.com/tamatebako/tebako/blob/main/README.adoc This command specifically cleans only the Ruby artifacts within the specified prefix directory. These artifacts are generated by the `setup` and `press` commands. It allows optional configuration for the prefix, Ruby version to clean, and the tebafile path. If no Ruby version is specified, all versions are cleaned. ```sh $ tebako clean_ruby [-p|--prefix=] \ [-R|--Ruby=] \ [-t|--tebafile=] ``` ```sh tebako clean_ruby --prefix='~/.tebako' ``` -------------------------------- ### Tebako Clean Command Source: https://github.com/tamatebako/tebako/blob/main/README.adoc The `tebako clean` command removes all Tebako artifacts from a specified prefix directory. These artifacts are typically generated by the `setup` and `press` commands. This command is usually unnecessary as Tebako manages artifact lifecycles automatically. It accepts optional prefix and tebafile path arguments. ```sh tebako clean \ [-p|--prefix=] \ [-t|--tebafile=] ``` ```sh tebako clean --prefix='~/.tebako' ``` -------------------------------- ### Set LG_VADDR for jemalloc Build on macOS Source: https://github.com/tamatebako/tebako/blob/main/INSTALLATION.adoc Sets the LG_VADDR environment variable to configure the jemalloc build on macOS, particularly when running in emulated environments. This example script demonstrates how to set LG_VADDR based on the CPU architecture. ```sh #!/bin/bash # Check the CPU architecture ARCH=$(uname -m) ``` -------------------------------- ### Set Bison Path on macOS Source: https://github.com/tamatebako/tebako/blob/main/INSTALLATION.adoc Sets the PATH environment variable on macOS to include the Homebrew-installed Bison binary. This is necessary on macOS 14 where the default Bison version is outdated. ```sh export PATH="$(brew --prefix bison)/bin:$PATH" ``` -------------------------------- ### Simple Script Packaging (Bash) Source: https://context7.com/tamatebako/tebako/llms.txt This scenario demonstrates how to package a simple Ruby script with its dependencies. It specifies the root directory of the project, the entry point script, and the output package name. Files are typically copied to `/local/` and executed from there. ```bash # Project structure: # myproject/ # start.rb # lib/ # helper.rb # data/ # config.json tebako press \ --root=myproject \ --entry-point=start.rb \ --output=myproject # Files copied to: /local/ # Executes: /local/start.rb ``` -------------------------------- ### Create Both Runtime and Application Packages with Tebako Source: https://github.com/tamatebako/tebako/blob/main/README.adoc This command creates both a Tebako runtime package and a Tebako application package. The runtime package is output to the specified location, and the application package is generated with the same name as the runtime package but with a '.package' extension. Requires specifying an entry point and project root. ```sh tebako press -m both \ -o \ -e \ -r \ [-R ] ``` -------------------------------- ### Using Tebafile with Tebako CLI Source: https://context7.com/tamatebako/tebako/llms.txt Demonstrates how to use the `.tebako.yml` configuration file with the `tebako press` command. This includes using the Tebafile in the current directory, specifying a custom Tebafile location, and showing how command-line options take precedence over settings in the Tebafile. ```bash tebako press \ --root=~/projects/app \ --entry-point=start.rb ``` ```bash tebako press \ --root=~/projects/app \ --entry-point=start.rb \ --tebafile=config/custom-tebako.yml ``` ```bash tebako press \ --root=~/projects/app \ --entry-point=start.rb \ --Ruby=3.3.7 \ --tebafile=.tebako.yml # Ruby version from CLI takes precedence ``` -------------------------------- ### Create Tebako Application Package Only Source: https://github.com/tamatebako/tebako/blob/main/README.adoc This command focuses on creating a Tebako application package. This package is designed to be executed using a pre-existing Tebako runtime package. Key parameters include the output package name, the application's entry point, and the project's root folder. ```sh tebako press -m application \ -o \ -e \ -r \ [-R ] ``` -------------------------------- ### Tebako Setup Custom Target Source: https://github.com/tamatebako/tebako/blob/main/CMakeLists.txt Defines a custom target 'setup' for Tebako. It echoes a completion message and depends on the DWARFS and Ruby build projects. Includes a dependency on 'patchELF' for GNU systems. ```cmake add_custom_target(setup ${CMAKE_COMMAND} -E echo "Tebako setup has completed" DEPENDS ${DWARFS_WR_PRJ} ${RUBY_PRJ} ) if(IS_GNU) add_dependencies(setup ${PATCHELF_PRJ}) endif(IS_GNU) ``` -------------------------------- ### Run Application Package with Runtime (Bash) Source: https://context7.com/tamatebako/tebako/llms.txt This section explains how to create and run an application package using Tebako's runtime. It covers creating separate runtime and application packages and then executing the application with the runtime, including passing arguments. ```bash # Create runtime and application separately tebako press --mode=runtime -o tebako-runtime-3.4.1 -R 3.4.1 tebako press --mode=application -o myapp -e hello.rb -r ./app -R 3.4.1 # Run application with runtime ./tebako-runtime-3.4.1 --tebako-run myapp.tebako # Run with arguments ./tebako-runtime-3.4.1 --tebako-run myapp.tebako arg1 arg2 # Example: Hello world application # File: hello.rb # puts "Hello, #{ARGV[0]}!" ./tebako-runtime-3.4.1 --tebako-run hello.tebako "World" # Output: Hello, World! ``` -------------------------------- ### Package Application with Tebako CLI Source: https://context7.com/tamatebako/tebako/llms.txt Demonstrates various ways to package a Ruby application using the `tebako press` command. This includes specifying the root directory, entry point, output file, Ruby version, logging level, and working directory. It also shows options for creating separate runtime and application packages, and forward-portable packages with `patchelf`. ```bash tebako press \ --root=~/projects/myapp \ --entry-point=start.rb \ --output=/tmp/myapp.tebako \ --Ruby=3.3.7 ``` ```bash tebako press \ -r ~/projects/rails-app \ -e bin/rails \ -o /tmp/rails-server \ -R 3.2.4 \ -l debug ``` ```bash tebako press \ --root=~/projects/cli-tool \ --entry-point=bin/tool \ --cwd=local \ --output=./my-tool ``` ```bash tebako press \ --mode=both \ --root=~/projects/app \ --entry-point=main.rb \ --output=tebako-runtime-3.3.7 \ --Ruby=3.3.7 ``` ```bash tebako press \ --mode=runtime \ --output=tebako-ruby-3.4.1 \ --Ruby=3.4.1 ``` ```bash tebako press \ --mode=application \ --root=~/projects/fontist \ --entry-point=fontist \ --output=fontist-app \ --Ruby=3.2.4 ``` ```bash tebako press \ --root=~/projects/app \ --entry-point=start.rb \ --output=portable-app \ --patchelf ``` -------------------------------- ### Tebako Verification Custom Target Source: https://github.com/tamatebako/tebako/blob/main/CMakeLists.txt Defines an alternative custom target 'setup' for Tebako when not in setup mode. It echoes a verification message and depends on the DWARFS and Ruby build projects, including 'patchELF' for GNU systems. ```cmake add_custom_target(setup ${CMAKE_COMMAND} -E echo "Tebako setup has been verified" DEPENDS ${DWARFS_WR_PRJ} ${RUBY_PRJ} ) if(IS_GNU) add_dependencies(setup ${PATCHELF_PRJ}) endif(IS_GNU) ``` -------------------------------- ### Passing Command Line Options to Packaged Application Source: https://github.com/tamatebako/tebako/blob/main/README.adoc Demonstrates how Tebako packages generally pass command-line options and parameters directly to the packaged application. The bootstrap code translates the Tebako package execution into the original application's execution with its arguments. ```sh tebako press \ --root='~/projects/myproject' \ --entry=start.rb \ --output=/temp/myproject.tebako /temp/myproject.tebako --option --parameter value ``` -------------------------------- ### Tebako Main Entry Point and Utilities (C++) Source: https://context7.com/tamatebako/tebako/llms.txt This C++ code snippet defines the main entry point for a Tebako application (`tebako_main`) and provides functions to access Tebako's filesystem mount point and the original working directory. It also includes a function to check if the environment is running `miniruby`. ```cpp #include #include // Application entry point - called by tebako bootstrap extern "C" int tebako_main(int* argc, char*** argv) { // Mount filesystem from embedded DwarFS image // Process command-line arguments // Parse --tebako-extract, --tebako-mount, --tebako-run // Initialize Ruby runtime // Execute entry point return 0; } // Get mount point from C code extern "C" const char* tebako_mount_point(void) { return tebako::fs_mount_point; } // Get original working directory extern "C" const char* tebako_original_pwd(void) { return tebako::original_cwd; } // Check if running miniruby (build-time) extern "C" int tebako_is_running_miniruby(void) { return running_miniruby; } ``` -------------------------------- ### Docker Package Application Source: https://github.com/tamatebako/tebako/blob/main/README.adoc This command demonstrates packaging an application using `tebako press` from outside a Docker container. It mounts the application folder and runs the `tebako press` command with necessary parameters for specifying the application root, entry point, output location, and Ruby version. ```sh docker run -v :/mnt/w \ -t ghcr.io/tamatebako/tebako-:latest \ tebako press ``` -------------------------------- ### Main Tebako Custom Target Source: https://github.com/tamatebako/tebako/blob/main/CMakeLists.txt Defines the main 'tebako' custom target, which is a no-op command. It depends on the 'setup' and 'tebako-fs' targets, ensuring they are built first. ```cmake add_custom_target(tebako COMMAND ${CMAKE_COMMAND} -E true) add_dependencies(tebako setup tebako-fs) ``` -------------------------------- ### Packaged Filesystem Custom Target Source: https://github.com/tamatebako/tebako/blob/main/CMakeLists.txt Defines a custom target 'packaged_filesystem' that runs a deployment script. It depends on the 'setup' target and produces the data binary file. ```cmake add_custom_target(packaged_filesystem COMMAND ruby ${DEPS_BIN_DIR}/deploy.rb ${RUBY_VER} DEPENDS setup BYPRODUCTS ${DATA_BIN_FILE} ) ``` -------------------------------- ### Mount Host Folders to Package (Bash) Source: https://context7.com/tamatebako/tebako/llms.txt Demonstrates how to mount host directories into a Tebako package for persistent storage or access to external files. Supports mounting single or multiple folders. ```bash # Mount single folder (Rails tmp directory) ./rails.tebako --tebako-mount local/tmp:$PWD/tmp server # Mount multiple folders ./myapp.tebako \ --tebako-mount local/tmp:/tmp/app-tmp \ --tebako-mount local/cache:$HOME/.cache/myapp \ start # Mount log directory for persistent logging ./production-app.tebako \ --tebako-mount local/log:/var/log/myapp \ --tebako-mount local/data:/data \ run ``` -------------------------------- ### Mount Host Folder with Tebako (Shell) Source: https://github.com/tamatebako/tebako/blob/main/README.adoc Mounts a host folder into the memfs tree using the `--tebako-mount` option. This is useful for Ruby applications that require read-write access to specific directories within the packaged environment. The option takes a `:` argument, where the memfs path is relative to the memfs root and the host path is an absolute path to the directory on the host system. Multiple mounts can be specified by repeating the option. Any remaining command-line arguments are passed to the application. ```sh rails.tebako --tebako-mount local/tmp:$PWD/tmp server ``` -------------------------------- ### Determine OpenSSL Version based on Ruby Version Source: https://github.com/tamatebako/tebako/blob/main/CMakeLists.txt Sets the OPENSSL_VER variable to '1.1' or '3' based on whether the RUBY_VER is less than '3.1.0'. This ensures compatibility with the installed OpenSSL version. ```cmake if(${RUBY_VER} VERSION_LESS "3.1.0") set(OPENSSL_VER "1.1") else(${RUBY_VER} VERSION_LESS "3.1.0") set(OPENSSL_VER "3") endif(${RUBY_VER} VERSION_LESS "3.1.0") ``` -------------------------------- ### Process Mode Selection and Package Path Validation Source: https://github.com/tamatebako/tebako/blob/main/CMakeLists.txt Determines whether the script is running in setup mode or press mode. It validates the output package path, ensuring it is absolute and normalizing it. ```cmake if(NOT ${SETUP_MODE}) message(STATUS "Running tebako press script") if ("-${PCKG}" STREQUAL "-") message(FATAL_ERROR "Project OUTPUT PACKAGE is not specified.") endif() cmake_path(IS_RELATIVE PCKG IS_PK_RELATIVE) if(${IS_PK_RELATIVE}) message(FATAL_ERROR "Path to output package shall be absolute. Relative path '${PCKG}' is not allowed.") else() cmake_path(SET APP_NAME NORMALIZE ${PCKG}) endif() message("Running tebako press script") else() message("Running tebako setup script") endif() ``` -------------------------------- ### Darwin Specific Build Flags Source: https://github.com/tamatebako/tebako/blob/main/CMakeLists.txt Configures include and library paths for macOS (Darwin) builds, specifically targeting OpenSSL and zlib installations via Homebrew. Sets the OpenSSL option for Ruby. ```cmake if(IS_DARWIN) string(CONCAT RUBY_C_FLAGS ${RUBY_C_FLAGS} " -I${BREW_PREFIX}/opt/openssl@${OPENSSL_VER}/include -I${BREW_PREFIX}/opt/zlib/include -I${BREW_PREFIX}/include") string(CONCAT RUBY_L_FLAGS ${RUBY_L_FLAGS} " -L${BREW_PREFIX}/opt/openssl@${OPENSSL_VER}/lib -L${BREW_PREFIX}/opt/zlib/lib -L${BREW_PREFIX}/lib") set(OPENSSL_RUBY_OPTION "--with-openssl-dir=${BREW_PREFIX}/opt/openssl@${OPENSSL_VER}") endif(IS_DARWIN) ``` -------------------------------- ### C/C++ File and Function Documentation with Doxygen Source: https://github.com/tamatebako/tebako/blob/main/CONTRIBUTING.adoc Documentation for C/C++ code should be in Doxygen format, placed in header files. It covers file-level descriptions and detailed function documentation including parameters, return values, and error conditions. Exceptions are made for static or definition-only functions. ```c /** Some comments regarding the file purpose, like 'Tebako filesystem utilities' * @file * * This file contains functions and definitions related to the Tebako filesystem. * Ensure to document all public interfaces thoroughly. */ /** brief description of the sample function which does something, keyword 'brief' is omitted * Which may be continued here * * After an empty line you may add detailed description in case it is needed. You may put * details about the memory allocation, what happens if function fails and so on. * * @param param1 first parameter, null-terminated string which should not be NULL * @param param2 integer, some number representing something * @param size number of bytes available to store in buffer * @param buffer buffer to store results, may be NULL. In this case size can be used to * obtain the required buffer length * @return 0 if operation succeeds, or error code otherwise. If operation succeeds then buffer * is populated with the resulting data, and size contains the length of this data. * if error code is E_BUF_TOOSMALL then size will contain the required size to store * the result **/ rnp_result_t tebako_do_operation(const char *param1, const int param2, int *size, char *buffer); ``` -------------------------------- ### Tebako Mount Option Syntax (Shell) Source: https://github.com/tamatebako/tebako/blob/main/README.adoc Defines the syntax for the `--tebako-mount` option in Tebako. This option is used to specify which host directories or files should be mounted into the memfs tree of the packaged application. The format requires a memfs path and a host path, separated by a colon. ```sh --tebako-mount : ``` -------------------------------- ### C++ Filesystem Configuration Constants for Tebako Source: https://context7.com/tamatebako/tebako/llms.txt This C++ code snippet defines external constants used for configuring the Tebako filesystem. These include settings for the DwarFS log level, the Memfs mount point, the application entry point within Memfs, the current working directory within the package, and the original working directory on the host filesystem. These configurations are crucial for Tebako's runtime operation and application deployment. ```cpp // tebako-fs.h usage #include namespace tebako { // DwarFS log level: error, warn, debug, trace extern const char* fs_log_level; // Memfs mount point (e.g., "/__tebako_memfs__") extern const char* fs_mount_point; // Application entry point path in memfs extern const char* fs_entry_point; // Current working directory in package extern const char* package_cwd; // Original working directory (host filesystem) extern char original_cwd[PATH_MAX]; } ``` -------------------------------- ### Add libdwarfs-wr Dependency (Pre-compiled Archive) Source: https://github.com/tamatebako/tebako/blob/main/CMakeLists.txt This snippet uses CMake's ExternalProject_Add to download and install a pre-compiled version of libdwarfs-wr. It's used when DWARFS_PRELOAD is enabled and fetches the library from a specified URL, including SHA256 hash verification. ```cmake set(__LIBDWARFS_WR "${DEPS_LIB_DIR}/libdwarfs-wr.a") if(DWARFS_PRELOAD) ExternalProject_Add(${LIBDWARFS_WR_PRJ} PREFIX ${DEPS} URL https://github.com/tamatebako/libdwarfs/releases/download/v${LIBDWARFS_WR_VER}/libdwarfs-wr-${LIBDWARFS_WR_VER_M}-mingw-ucrt64.7z URL_HASH SHA256=${LIBDWARFS_WR_HASH} DOWNLOAD_NO_PROGRESS true SOURCE_DIR ${LIBDWARFS_WR_SOURCE_DIR} UPDATE_COMMAND "" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS} COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDWARFS_WR_SOURCE_DIR} ${DEPS} TEST_COMMAND "" ) endif(DWARFS_PRELOAD) ``` -------------------------------- ### Create Tebako Bundle Package Source: https://github.com/tamatebako/tebako/blob/main/README.adoc Command to create a Tebako bundle package, which includes the Ruby runtime and the application. The -o flag specifies the output file name, -r specifies the project root folder, and -R (optional) specifies the Ruby version. ```sh $ tebako bundle create -o -r [-R ] ``` -------------------------------- ### Tebako 'press' Command Usage Source: https://github.com/tamatebako/tebako/blob/main/README.adoc The 'press' command packages a Ruby project into a single executable binary. It requires an entry point and optionally accepts project root, Tebako root folder, Ruby version, output file name, log level, current working directory, development mode, patchelf flag, mode, runtime reference, and Tebafile path. ```sh tebako press \ -e|--entry-point= \ -r|--root= \ [-p|--prefix=] \ [-R|--Ruby=] \ [-o|--output=] \ [-l|--log-level=] \ [-c|--cwd=] \ [-D|--devmode] \ [-P|--patchelf] \ [-m|--mode=] \ [-u|--ref=] \ [-t|--tebafile=] ``` -------------------------------- ### Running Tebako Application with Runtime Package Source: https://github.com/tamatebako/tebako/blob/main/README.adoc Executes a Tebako application package using a separate Tebako runtime package. The runtime package must be created in 'runtime' or 'both' mode, and the application package in 'application' or 'both' mode. This allows for decoupling the application logic from the runtime environment. ```sh $ --tebako-run [] ```