[こう使って下さい!] NAVERクラウドプラットフォームでのyocto projectのビルドサーバーの構成

NAVER CLOUD PLATFORM
NAVER CLOUD PLATFORM
13 min readJun 2, 2020

*このコンテンツは、NAVERクラウドプラットフォームTech Evangelistのソン・チャンアンさんが作成したものです。

こんにちは。 NAVERクラウドプラットフォームです。今日は、yocto projectを活用してビルドサーバーを構築してみたいと思います。

Q. yocto projectとは?

A. 組込みリナックス動作のための統合ツールであり、自動ビルドやテスト支援及びライセンス管理、カスタムリナックスOS構成を簡単にできます。

Q. x64プラットフォームでの使い方を教えて下さい。

A. 私が提案できる一つの方法として、yoctoプロジェクトを活用しx64環境でISOフォーマット又は、 qcow2画像形態で構成できます。Iso形態は、一般的なベアメタルシステムだけでなく、VMでもブースティングの形で構成でき、qcow2画像形態を介して自分だけのケネルや自分だけのパッケージの形で簡単に構成可能です。

NAVERクラウドプラットフォームでビルドサーバーを構成し、簡単なx64プラットフォームで自分だけのISOファイルを構成する時間を設けてみましょう!

0. サーバーを構築します。

1. サーバーを構築するために、サーバー画像を選びます。私は、centos-7.3を選びました。

yocto projectでビルドできる環境を構築するに当たり、CentOS Packagesの方法も提供しています。

2. サーバーの仕様は、ビルドサーバーのためにvCPU 16個とメモリー16Gを選びました。

3. 元々構成しておいた認証キーを使う予定ですが、もしキーが無ければ、新しい認証キーの作成が可能です。

4. ACGルールに基づいて外部接近に必要なルールを設定することができます。私は基本ルールにします。

5. サーバー構築のために、最終レビューをしてからサーバー構築を押します。

6. サーバー構築後、運営中であることが確認できたら、外部からサーバー接続ができるように、ポートフォワーディングを指定します。

7. 現在、サーバー接続用の公認IPは指定されており、ポート番号によって簡単にサーバーへアプローチできます。

8. puttyで下の図のように、ポートフォワーディングを設定したポートでSSHに接続します。

9. 最初のサーバー構築の際には、管理者用の暗証番号を確認します。

10. 私は、認証キーを私のローカルディスクに保存しており、下の図のように確認をしてから暗証番号を確認します。

11. 確認された暗証番号でビルドサーバーに接続します。

12. Centosに現在のyoctoプロジェクトに必要なパッケージを設置します。

# yum install -y epel-release
# yum makecache
# yum install -y gawk make wget tar bzip2 gzip python unzip perl patch diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath socat perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue python34-pip xz which SDL-devel xterm
# yum install python34-setuptools -y
# easy_install-3.4 pip
# pip3 install GitPython jinja2

13. yoctoプロジェクトでgitを通じ現在コードをcloneし、3.0バージョンにcheckoutをします。

# mkdir /root/devroots/
# cd /root/devroots/
# git clone git://git.yoctoproject.org/poky
# git checkout tags/yocto-3.0 -b my-yocto-3.0

14. その後、”source oe-init-build-env”命令後でbuild環境の変数を適用します。

[root@yocto-30-build build]# cd ..
[root@yocto-30-build poky]# ls
bitbake build contrib documentation LICENSE LICENSE.GPL-2.0-only LICENSE.MIT meta meta-poky meta-selftest meta-skeleton meta-yocto-bsp oe-init-build-env README.hardware README.OE-Core README.poky README.qemu scripts
[root@yocto-30-build poky]# pwd
/root/devroots/poky
[root@yocto-30-build poky]# source oe-init-build-env
### Shell environment set up for builds. ###You can now run ‘bitbake <target>’Common targets are:
core-image-minimal
core-image-sato
meta-toolchain
meta-ide-support
You can also run generated qemu images with a command like ‘runqemu qemux86’Other commonly useful commands are:
— ‘devtool’ and ‘recipetool’ handle common recipe tasks
— ‘bitbake-layers’ handles common layer tasks
— ‘oe-pkgdata-util’ handles common target package tasks
[root@yocto-30-build build]# pwd
/root/devroots/poky/build
[root@yocto-30-build build]#

15. MACHINE ??= “qemux86–64” 注釈を付けます。MACHINE ?= “genericx86–64” 注釈を削除します。

[root@yocto-30-build build]# vim ./conf/local.conf

#
# There are also the following hardware board target machines included for
# demonstration purposes:
#
#MACHINE ?= “beaglebone-yocto”
#MACHINE ?= “genericx86”
MACHINE ?= “genericx86–64”
#MACHINE ?= “mpc8315e-rdb”
#MACHINE ?= “edgerouter”
#
# This sets the default machine to be qemux86–64 if no other machine is selected:
#MACHINE ??= “qemux86–64”

IMAGE_FSTYPES = “iso”

16. 現在、build初期にroot権限の使用者はbuildできないようになっているため、今私は、この権限をチェックするところを非活性化にしています。 “INHERIT += “sanity” 注釈を付けました。

# cd /root/devroots/poky/
# vim /meta/conf/sanity.conf

#INHERIT += “sanity”

17. 最小限のイメージビルドのために、bitbake core-image-minimalを入力します。

# cd /root/devroots/poky/build
# bitbake core-image-minimal

18. ビルドが完了したら、”/tmp/deploy/images/genericx86–64" 下のディレクトリからisoファイルを確認できます。

# cd /root/devroots/poky/build/tmp/deploy/images/genericx86-64
[root@yocto-30-build genericx86-64]# ls
bzImage core-image-minimal-genericx86-64-20200112053822.testdata.json core-image-minimal-initramfs-genericx86-64-20200112053822.rootfs.manifestbzImage--5.2.17+git0+b867b78b50_25b14cdf96-r0-genericx86-64-20200112053822.bin
core-image-minimal-genericx86-64.ext4 core-image-minimal-initramfs-genericx86-64-20200112053822.testdata.json
bzImage-genericx86-64.bin core-image-minimal-genericx86-64.iso core-image-minimal-initramfs-genericx86-64.cpio.gzcore-image-minimal.env core-image-minimal-genericx86-64.manifest core-image-minimal-initramfs-genericx86-64.manifestcore-image-minimal-genericx86-64-20200112053822.iso core-image-minimal-genericx86-64.qemuboot.conf core-image-minimal-initramfs-genericx86-64.qemuboot.confcore-image-minimal-genericx86-64-20200112053822.qemuboot.conf core-image-minimal-genericx86-64.testdata.json core-image-minimal-initramfs-genericx86-64.testdata.jsoncore-image-minimal-genericx86-64-20200112053822.rootfs.ext4 core-image-minimal-genericx86-64.wic grub-efi-bootx64.eficore-image-minimal-genericx86-64-20200112053822.rootfs.manifest core-image-minimal-genericx86-64.wic.bmap modules--5.2.17+git0+b867b78b50_25b14cdf96-r0-genericx86-64-20200112053822.tgzcore-image-minimal-genericx86-64-20200112053822.rootfs.wic core-image-minimal-initramfs-genericx86-64-20200112053822.qemuboot.conf modules-genericx86-64.tgzcore-image-minimal-genericx86-64-20200112053822.rootfs.wic.bmap core-image-minimal-initramfs-genericx86-64-20200112053822.rootfs.cpio.gz systemd-bootx64.efi

19. winscp ユティルを通じビルドサーバーに接続し、isoをダウンロードします。

20. isoファイルを持ってきます。

21. 私はVMware Workstationを使ってISOブースティングをするために、ダウンロードしたisoを選択します。

22. 確認後、Nextを押します。

23. 仮想マシンに対し、Linux / Other Linux 4.x or later kernel 64bitを選択します。

24. その後は、仮想化マシンの名前を入力し、Nextを押します。

25. ディスクのサイズは基本に設定します。

ISOブースティングなので、ディスクは使いません。

26. 最終の仮想マシンのレビューが終わったら、Finishを押します。

27. 当該VMをスタートさせます。

28. 下の図のように、ブートローダー上がってくると、ブースティング中であることが分かります。

今日は、NAVERクラウドプラットフォームのサーバー商品を通じ、yocto projectを用いてビルドサーバーを構築し、x64プラットフォームの自分だけのisoファイルを構成してみました。Yoctoは、リナックス開発環境でも自動ビルドやテスト支援、カスタムリナックスOSなど有効な統合ツールとして活用できます。

今日はここまでです。これからもまた良いコンテンツで伺いたいと思います。最後まで読んで頂いてありがとうございました。

--

--

NAVER CLOUD PLATFORM
NAVER CLOUD PLATFORM

We provide cloud-based information technology services for industry leaders from startups to enterprises.