tag:crieit.net,2005:https://crieit.net/tags/termux/feed 「termux」の記事 - Crieit Crieitでタグ「termux」に投稿された最近の記事 2022-05-31T17:37:46+09:00 https://crieit.net/tags/termux/feed tag:crieit.net,2005:PublicArticle/18206 2022-05-31T16:51:44+09:00 2022-05-31T17:37:46+09:00 https://crieit.net/posts/Building-packages Building packages <h2 id="Using Termux build environment"><a href="#Using+Termux+build+environment">Using Termux build environment</a></h2> <p>A recommended way of building is to use official build environment available on Github: https://github.com/termux/termux-packages. See <a target="_blank" rel="nofollow noopener" href="https://github.com/termux/termux-packages/wiki">Termux Developer's Wiki</a> for tips about its usage.</p> <ul> <li><a target="_blank" rel="nofollow noopener" href="https://github.com/termux/termux-packages/wiki/Build-environment">https://github.com/termux/termux-packages/wiki/Build-environment</a> - setting up build environment.</li> <li><a target="_blank" rel="nofollow noopener" href="https://github.com/termux/termux-packages/wiki/Building-packages">https://github.com/termux/termux-packages/wiki/Building-packages</a> - how to build a package.</li> <li><a target="_blank" rel="nofollow noopener" href="https://github.com/termux/termux-packages/wiki/Creating-new-package">https://github.com/termux/termux-packages/wiki/Creating-new-package</a> - information about writing package scripts (build.sh).</li> </ul> <h2 id="On-device usage"><a href="#On-device+usage">On-device usage</a></h2> <p>It is possible to use our build environment directly on device without Docker image or VM setup. You need only to:</p> <ol> <li>Clone the git repository:</li> </ol> <pre><code>git clone https://github.com/termux/termux-packages </code></pre> <ol start="2"> <li>Execute setup script:</li> </ol> <pre><code>cd termux-packages ./scripts/setup-termux.sh </code></pre> <p>Packages are built by executing<code>./build-package.sh -I package_name.</code> Note that option "-I" tells build-package.sh to download and install dependency packages automatically instead of building them which makes build a lot faster.</p> <p>By default, with Termux build environment you can build only existing packages. If package is not exist in <code>./packages</code> directory, then you will have to write its build.sh manually.</p> <p><strong>If you managed to successfully build a new package, consider to make a pull request.</strong></p> <p>Some notes about on-device building:</p> <ul> <li>Some packages are considered as unsafe for building on device as they remove stuff from <code>$PREFIX</code>.</li> <li>During build process, the compiled stuff is installed directly to <code>$PREFIX</code> and is not tracked by dpkg. This is expected behaviour. If you don't want this stuff, install generated deb files and uninstall.</li> <li>Some packages may throw errors when building on device. This is known issue and tracked in <a target="_blank" rel="nofollow noopener" href="https://github.com/termux/termux-packages/issues/4157">https://github.com/termux/termux-packages/issues/4157</a>.</li> <li>On-device package building for android-5 branch is not tested well.</li> </ul> <h2 id="Manually building packages"><a href="#Manually+building+packages">Manually building packages</a></h2> <p>There no universal guide about building/porting packages in Termux, especially since Termux isn't a standard platform.</p> <p>Though you can follow some recommendations mentioned here:</p> <ol> <li><p>Make sure that minimal set of build tools is installed:</p> <pre><code>pkg install build-essential </code></pre></li> <li><p>After extracting package source code, check for files named like "README" or "INSTALL". They usually contain information about how to build a package.</p></li> <li><p>Autotools based projects (have ./configure script in project's root) in most cases can be built with the following commands:</p></li> </ol> <pre><code> ./configure --prefix=$PREFIX make && make install </code></pre> <p>It is highly recommended to check the accepted configuration options by executing <code>./configure --help</code>.</p> <p>In case of configuration failure, read the output printed on screen and check the file <code>config.log</code> (contains a lot of text, but all information about error's source exist in it).</p> <ol start="4"> <li>CMake based projects (have CMakeLists in project's root) should be possible to build with:</li> </ol> <pre><code> mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" .. make make install </code></pre> <p>Be careful when running <code>make install</code> as it will unconditionally write files to <code>$PREFIX</code>. Never execute any of build commands as root.</p> <p><strong>Note about "bug reports":</strong> if you trying to build custom package and it fails, do not submit bug reports regarding it.</p> <p><strong>Note about "package requests":</strong> if you decided to submit a package request for package that you can't build, make sure this package will be useful for others. Otherwise such requests will be just rejected.</p> <p><a target="_blank" rel="nofollow noopener" href="https://rentry.co/termux">https://rentry.co/termux</a></p> <hr /> <h2 id="Termuxのビルド環境を利用する"><a href="#Termux%E3%81%AE%E3%83%93%E3%83%AB%E3%83%89%E7%92%B0%E5%A2%83%E3%82%92%E5%88%A9%E7%94%A8%E3%81%99%E3%82%8B">Termuxのビルド環境を利用する</a></h2> <p>Githubで公開されている公式のビルド環境(<a target="_blank" rel="nofollow noopener" href="https://github.com/termux/termux-packages">https://github.com/termux/termux-packages</a>)を使ってビルドすることをお勧めします。使い方のコツは Termux Developer's Wiki を参照してください。</p> <p><a target="_blank" rel="nofollow noopener" href="https://github.com/termux/termux-packages/wiki/Build-environment">https://github.com/termux/termux-packages/wiki/Build-environment</a> - ビルド環境を構築する。<br /> <a target="_blank" rel="nofollow noopener" href="[https://github.com/termux/termux-packages/wiki/Building-packages">https://github.com/termux/termux-packages/wiki/Building-packages</a>](https://github.com/termux/termux-packages/wiki/Building-packages)) - パッケージをビルドする方法。<br /> <a target="_blank" rel="nofollow noopener" href="https://github.com/termux/termux-packages/wiki/Creating-new-package">https://github.com/termux/termux-packages/wiki/Creating-new-package</a> - パッケージスクリプト(build.sh)の書き方についての情報です。</p> <h2 id="デバイス上での使用"><a href="#%E3%83%87%E3%83%90%E3%82%A4%E3%82%B9%E4%B8%8A%E3%81%A7%E3%81%AE%E4%BD%BF%E7%94%A8">デバイス上での使用</a></h2> <p>DockerイメージやVMのセットアップをせずに、デバイス上で直接ビルド環境を使用することができます。必要な作業は以下の通りです。</p> <p>git リポジトリをクローンする。</p> <pre><code>git clone https://github.com/termux/termux-packages </code></pre> <p>セットアップスクリプトを実行する。</p> <pre><code>cd termux-packages ./scripts/setup-termux.sh </code></pre> <p>を実行します。<br /> パッケージのビルドは、<code>./build-package.sh -I package_name</code> を実行します。I" オプションは build-package.sh が依存パッケージを自動的にダウンロードし、インストールすることを意味し、ビルドを高速化します。</p> <p>Termuxのビルド環境では、デフォルトで既存のパッケージのみをビルドすることができます。もしパッケージが <code>./packages</code> ディレクトリに存在しない場合は、手動で <code>build.sh</code> を作成する必要があります。</p> <p>もし、新しいパッケージのビルドに成功した場合は、プルリクエストを作成することを検討してください。</p> <p>デバイス上でのビルドに関するいくつかの注意点。</p> <ul> <li>パッケージの中には、<code>$PREFIX</code> にあるものを削除してしまうものがあり、デバイス上でビルドするには安全でないと考えられています。</li> <li>ビルド中に、コンパイルされたものが <code>$PREFIX</code> に直接インストールされ、dpkg によって追跡されることはありません。これは予想された動作です。このようなものが不要な場合は、生成された deb ファイルをインストールしてからアンインストールしてください。</li> <li>パッケージによっては、デバイス上でビルドする際にエラーが発生することがあります。これは既知の問題であり、<a target="_blank" rel="nofollow noopener" href="https://github.com/termux/termux-packages/issues/4157">https://github.com/termux/termux-packages/issues/4157</a> で追跡されています。</li> <li>android-5 ブランチのデバイス上でのパッケージのビルドはうまくテストされていません。</li> </ul> <h2 id="手動でパッケージをビルドする"><a href="#%E6%89%8B%E5%8B%95%E3%81%A7%E3%83%91%E3%83%83%E3%82%B1%E3%83%BC%E3%82%B8%E3%82%92%E3%83%93%E3%83%AB%E3%83%89%E3%81%99%E3%82%8B">手動でパッケージをビルドする</a></h2> <p>Termuxは標準的なプラットフォームではないため、パッケージのビルドやポーティングに関する普遍的なガイドはありません。</p> <p>しかし、ここに書かれているいくつかの推奨事項に従うことができます。</p> <ol> <li>最小限のビルドツールがインストールされていることを確認してください。</li> </ol> <pre><code>pkg install build-essential </code></pre> <ol start="2"> <li>パッケージのソースコードを展開したら、"README" や "INSTALL" といった名前のファイルがあるかどうか確認してください。これらは通常、パッケージのビルド方法に関する情報を含んでいます。</li> <li>Autotoolsベースのプロジェクト(プロジェクトのルートに<code>./configure</code>スクリプトがある)は、ほとんどの場合、次のコマンドでビルドすることができます。</li> </ol> <pre><code>./configure --prefix=$PREFIX make && make install </code></pre> <p><code>./configure --help</code>を実行して、受け入れられる設定オプションを確認することを強くお勧めします。</p> <p>設定に失敗した場合は、画面に表示される出力を読み、config.log ファイルを確認します (多くのテキストが含まれていますが、エラーの原因に関するすべての情報が含まれています)。</p> <ol start="4"> <li>CMakeベースのプロジェクト(プロジェクトのルートにCMakeListsがある)では、ビルドが可能なはずです。</li> </ol> <pre><code>mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" .... make make install </code></pre> <p><code>make install</code>を実行すると、無条件で<code>$PREFIX</code> にファイルを書き込んでしまうので、注意してください。また、ビルドコマンドは絶対にroot権限で実行しないでください。</p> <p>バグレポートに関する注意: カスタムパッケージをビルドしようとして失敗した場合、それに関するバグレポートを提出しないでください。</p> <p>パッケージ要求に関する注意: もし、あなたがビルドできないパッケージのパッケージ要求を提出することに決めたなら、そのパッケージが他の人にとって有用であることを確認してください。そうでなければ、そのような要求は単に拒否されるだけでしょう。</p> <p><a target="_blank" rel="nofollow noopener" href="https://rentry.co/c92nx">https://rentry.co/c92nx</a></p> tomato