|
1 | 1 | pckg-install-local
|
2 |
| -================== |
| 2 | +================== |
| 3 | + |
| 4 | +The ``pckg-install-local`` script is a Python utility that enables local installation and testing of Arduino core packages during development. |
| 5 | + |
| 6 | +It allows to install an Arduino core without publishing it to a remote repository, from a local directory. |
| 7 | +The `arduino-cli` can only install cores which are hosted in a remote server. |
| 8 | +In CI/CD this is convenient for two use cases: |
| 9 | + |
| 10 | +- Working with the commit triggering the CI/CD pipeline for an Arduino core. |
| 11 | +- Prevent the CI/CD downloads to increase the download statistics of the core package by installing it from a published release, which will skew the real user download statistics. |
| 12 | + |
| 13 | +Overview |
| 14 | +-------- |
| 15 | + |
| 16 | +When developing an Arduino core, you typically need to test your changes before publishing. This script automates the process of: |
| 17 | + |
| 18 | +1. Starting a local HTTP server to host your package files (as arduino-cli cannot install from a local directory) |
| 19 | +2. Creating a modified package index file with local URLs |
| 20 | +3. Uninstalling any existing version of the core |
| 21 | +4. Installing the core from your local development files |
| 22 | +5. Cleaning up temporary files |
| 23 | + |
| 24 | +This tool can be used for cores generated by the :doc:`arduino-packager` tool. |
| 25 | + |
| 26 | +Features |
| 27 | +-------- |
| 28 | + |
| 29 | +- **Local HTTP server**: Automatically starts a local server on a random port (8000-8200 range) |
| 30 | +- **Package index modification**: Creates a local version of your package index with localhost URLs |
| 31 | +- **Clean installation**: Removes existing installations and staging files before installing |
| 32 | +- **Arduino CLI integration**: Uses Arduino CLI commands for proper core management |
| 33 | +- **Verbose logging**: Optional detailed output for debugging |
| 34 | +- **Cross-platform support**: Works on Linux, macOS, and Windows |
| 35 | + |
| 36 | +Usage |
| 37 | +----- |
| 38 | + |
| 39 | +Basic usage: |
| 40 | + |
| 41 | +.. code:: bash |
| 42 | +
|
| 43 | + python pckg-install-local.py |
| 44 | +
|
| 45 | +With options: |
| 46 | + |
| 47 | +.. code:: bash |
| 48 | +
|
| 49 | + python pckg-install-local.py --pckg-dir /path/to/package --verbose |
| 50 | +
|
| 51 | +Command line options |
| 52 | +^^^^^^^^^^^^^^^^^^^^ |
| 53 | + |
| 54 | +``--pckg-dir <directory>`` |
| 55 | + Path to the package directory containing the Arduino core package files. |
| 56 | + |
| 57 | + **Default**: Current working directory |
| 58 | + |
| 59 | + **Example**: ``--pckg-dir ./build/`` |
| 60 | + |
| 61 | +``--verbose`` |
| 62 | + Enable verbose logging output to see detailed information about the installation process. |
| 63 | + |
| 64 | + **Example**: ``--verbose`` |
| 65 | + |
| 66 | +``-v, --version`` |
| 67 | + Display the version of the pckg-install-local tool. |
| 68 | + |
| 69 | + **Example**: ``--version`` |
| 70 | + |
| 71 | +Package directory structure |
| 72 | +--------------------------- |
| 73 | + |
| 74 | +The package directory must contain: |
| 75 | + |
| 76 | +1. **Package index file**: A ``.json`` file (e.g., ``package_mycore_index.json``) |
| 77 | +2. **Core archive**: A ``.zip`` file containing the Arduino core (e.g., ``arduino-core-mycore-1.0.0.zip``) |
| 78 | + |
| 79 | +Example directory structure: |
| 80 | + |
| 81 | +.. code:: text |
| 82 | +
|
| 83 | + package/ |
| 84 | + ├── package_mycore_index.json # Package index manifest |
| 85 | + └── arduino-core-mycore-1.0.0.zip # Arduino core archive |
| 86 | +
|
| 87 | +Installation process |
| 88 | +-------------------- |
| 89 | + |
| 90 | +The script performs the following steps: |
| 91 | + |
| 92 | +1. **Server setup** |
| 93 | + |
| 94 | + - Starts a local HTTP server on a random port (8000-8200) |
| 95 | + - Serves files from the specified package directory |
| 96 | + |
| 97 | +2. **Package index modification** |
| 98 | + |
| 99 | + - Locates the package index JSON file in the directory |
| 100 | + - Creates a local copy with ``_local`` suffix (e.g., ``package_mycore_index_local.json``) |
| 101 | + - Updates the package URL to point to the local server |
| 102 | + |
| 103 | +3. **Core cleanup** |
| 104 | + |
| 105 | + - Uninstalls any existing version of the core using ``arduino-cli core uninstall`` |
| 106 | + - Removes staging files from Arduino's installation directory |
| 107 | + - Cleans up previous local package index files |
| 108 | + |
| 109 | +4. **Core installation** |
| 110 | + |
| 111 | + - Updates Arduino CLI core index |
| 112 | + - Installs the core using the local package index URL |
| 113 | + - Lists installed cores to verify installation |
| 114 | + |
| 115 | +Prerequisites |
| 116 | +------------- |
| 117 | + |
| 118 | +- **Python 3.x** installed on your system |
| 119 | +- **Arduino CLI** installed and available in your system PATH |
| 120 | +- **Package files** generated by the arduino-packager tool or manually created |
| 121 | +- **Network access** for Arduino CLI to update its index (internet connection) |
| 122 | + |
| 123 | +.. note:: |
| 124 | + The script requires Arduino CLI to be properly installed and configured. You can install it using the :doc:`arduino-cli-install` script. |
| 125 | + |
| 126 | +Examples |
| 127 | +-------- |
| 128 | + |
| 129 | +**Install from current directory:** |
| 130 | + |
| 131 | +.. code:: bash |
| 132 | +
|
| 133 | + python pckg-install-local.py |
| 134 | +
|
| 135 | +**Install with verbose output:** |
| 136 | + |
| 137 | +.. code:: bash |
| 138 | +
|
| 139 | + python pckg-install-local.py --verbose |
| 140 | +
|
| 141 | +**Install from specific package directory:** |
| 142 | + |
| 143 | +.. code:: bash |
| 144 | +
|
| 145 | + python pckg-install-local.py --pckg-dir ./build/package --verbose |
| 146 | +
|
| 147 | +**Check version:** |
| 148 | + |
| 149 | +.. code:: bash |
| 150 | +
|
| 151 | + python pckg-install-local.py --version |
| 152 | +
|
| 153 | +Troubleshooting |
| 154 | +--------------- |
| 155 | + |
| 156 | +**"Package index file not found" error:** |
| 157 | + Ensure your package directory contains a ``.json`` file (package index manifest). |
| 158 | + |
| 159 | +**"Package archive file not found" error:** |
| 160 | + Ensure your package directory contains a ``.zip`` file (Arduino core archive). |
| 161 | + |
| 162 | +**"Server could not start" error:** |
| 163 | + The script tries random ports between 8000-8200. If all ports are busy, try closing other applications or restart your system. |
| 164 | + |
| 165 | +**Arduino CLI command fails:** |
| 166 | + Verify that Arduino CLI is properly installed and accessible from the command line: |
| 167 | + |
| 168 | + .. code:: bash |
| 169 | + |
| 170 | + arduino-cli version |
| 171 | +
|
| 172 | +**Core installation fails:** |
| 173 | + Check that your package index file is valid JSON and contains the required Arduino core package structure. |
| 174 | + |
| 175 | +.. warning:: |
| 176 | + This script modifies Arduino CLI's core installations. Make sure to backup any important Arduino configurations before running it. |
| 177 | + |
| 178 | +.. tip:: |
| 179 | + Use the ``--verbose`` flag to see detailed logging output when troubleshooting installation issues. |
0 commit comments