A recommended way of building is to use official build environment available on Github: https://github.com/termux/termux-packages. See Termux Developer's Wiki for tips about its usage.
It is possible to use our build environment directly on device without Docker image or VM setup. You need only to:
git clone https://github.com/termux/termux-packages
cd termux-packages
./scripts/setup-termux.sh
Packages are built by executing./build-package.sh -I package_name.
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.
By default, with Termux build environment you can build only existing packages. If package is not exist in ./packages
directory, then you will have to write its build.sh manually.
If you managed to successfully build a new package, consider to make a pull request.
Some notes about on-device building:
$PREFIX
.$PREFIX
and is not tracked by dpkg. This is expected behaviour. If you don't want this stuff, install generated deb files and uninstall.There no universal guide about building/porting packages in Termux, especially since Termux isn't a standard platform.
Though you can follow some recommendations mentioned here:
Make sure that minimal set of build tools is installed:
pkg install build-essential
After extracting package source code, check for files named like "README" or "INSTALL". They usually contain information about how to build a package.
Autotools based projects (have ./configure script in project's root) in most cases can be built with the following commands:
./configure --prefix=$PREFIX
make && make install
It is highly recommended to check the accepted configuration options by executing ./configure --help
.
In case of configuration failure, read the output printed on screen and check the file config.log
(contains a lot of text, but all information about error's source exist in it).
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" ..
make
make install
Be careful when running make install
as it will unconditionally write files to $PREFIX
. Never execute any of build commands as root.
Note about "bug reports": if you trying to build custom package and it fails, do not submit bug reports regarding it.
Note about "package requests": 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.
Githubで公開されている公式のビルド環境(https://github.com/termux/termux-packages)を使ってビルドすることをお勧めします。使い方のコツは Termux Developer's Wiki を参照してください。
https://github.com/termux/termux-packages/wiki/Build-environment - ビルド環境を構築する。
https://github.com/termux/termux-packages/wiki/Building-packages](https://github.com/termux/termux-packages/wiki/Building-packages)) - パッケージをビルドする方法。
https://github.com/termux/termux-packages/wiki/Creating-new-package - パッケージスクリプト(build.sh)の書き方についての情報です。
DockerイメージやVMのセットアップをせずに、デバイス上で直接ビルド環境を使用することができます。必要な作業は以下の通りです。
git リポジトリをクローンする。
git clone https://github.com/termux/termux-packages
セットアップスクリプトを実行する。
cd termux-packages
./scripts/setup-termux.sh
を実行します。
パッケージのビルドは、./build-package.sh -I package_name
を実行します。I" オプションは build-package.sh が依存パッケージを自動的にダウンロードし、インストールすることを意味し、ビルドを高速化します。
Termuxのビルド環境では、デフォルトで既存のパッケージのみをビルドすることができます。もしパッケージが ./packages
ディレクトリに存在しない場合は、手動で build.sh
を作成する必要があります。
もし、新しいパッケージのビルドに成功した場合は、プルリクエストを作成することを検討してください。
デバイス上でのビルドに関するいくつかの注意点。
$PREFIX
にあるものを削除してしまうものがあり、デバイス上でビルドするには安全でないと考えられています。$PREFIX
に直接インストールされ、dpkg によって追跡されることはありません。これは予想された動作です。このようなものが不要な場合は、生成された deb ファイルをインストールしてからアンインストールしてください。Termuxは標準的なプラットフォームではないため、パッケージのビルドやポーティングに関する普遍的なガイドはありません。
しかし、ここに書かれているいくつかの推奨事項に従うことができます。
pkg install build-essential
./configure
スクリプトがある)は、ほとんどの場合、次のコマンドでビルドすることができます。./configure --prefix=$PREFIX
make && make install
./configure --help
を実行して、受け入れられる設定オプションを確認することを強くお勧めします。
設定に失敗した場合は、画面に表示される出力を読み、config.log ファイルを確認します (多くのテキストが含まれていますが、エラーの原因に関するすべての情報が含まれています)。
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" ....
make
make install
make install
を実行すると、無条件で$PREFIX
にファイルを書き込んでしまうので、注意してください。また、ビルドコマンドは絶対にroot権限で実行しないでください。
バグレポートに関する注意: カスタムパッケージをビルドしようとして失敗した場合、それに関するバグレポートを提出しないでください。
パッケージ要求に関する注意: もし、あなたがビルドできないパッケージのパッケージ要求を提出することに決めたなら、そのパッケージが他の人にとって有用であることを確認してください。そうでなければ、そのような要求は単に拒否されるだけでしょう。
Crieitは誰でも投稿できるサービスです。 是非記事の投稿をお願いします。どんな軽い内容でも投稿できます。
また、「こんな記事が読みたいけど見つからない!」という方は是非記事投稿リクエストボードへ!
こじんまりと作業ログやメモ、進捗を書き残しておきたい方はボード機能をご利用ください。
ボードとは?
コメント