LoginSignup
0
1

More than 5 years have passed since last update.

[メモ] Vagrant: Raspbian(armhf)向けdebパッケージをx86_64のVMマシンでビルド(SBUILD使用)

Posted at

概要

環境

  • ホスト
    • Windows 7 64bit
    • Vagrant 1.9.1
    • VirtualBox 5.1.12

手順

  1. 適当なフォルダに、↓のVagrantfileを作成
    - aptキャッシュサーバがあれば、その辺も編集
  2. vagrant up
    待つ
  3. ログイン:
    vagrant ssh
  4. 呪文を唱えて待つ:
    mk-sbuild --arch=armhf jessie
  5. 準備された環境へログイン:
    sudo sbuild-shell jessie-armhf
  6. 普段どおり、debのビルドする

    例_htop
    PACKAGE_NAME=htop
    #
    mkdir -p /home/pi/build
    cd /home/pi/build
    #
    #apt-get update
    apt-get build-dep -y ${PACKAGE_NAME} 
    apt-get source -b ${PACKAGE_NAME}
    #
    # ls -l *.deb
    # -rw-r--r-- 1 root root 68132 Jan 12 23:22 htop_1.0.3-1_armhf.deb
    

Vagrantfile

Vagrantfile
# Vagrantfile

VB_NAME="Raspbian Package Build(sbuild)"
VM_MEMORY=1024
VM_CORES=2

Vagrant.configure("2") do |config|
    config.vm.box = "bento/ubuntu-16.04"
    #config.vm.network "public_network", bridge: 'Intel(R) Ethernet Connection I217-LM'
    config.vm.provider "virtualbox" do |vb|
        #   vb.gui = true
        vb.name = VB_NAME
        vb.memory = VM_MEMORY
        vb.cpus = VM_CORES
    end

    config.vm.provision "shell", inline: <<-SHELL
        #whoami # => root
        #echo 'Acquire::http::Proxy "http://apt-cache-server:3142";' | tee /etc/apt/apt.conf.d/02proxy
        #
        # Install: raspbian-archive-keyring.gpg
        wget http://archive.raspbian.org/raspbian/pool/main/r/raspbian-archive-keyring/raspbian-archive-keyring_20120528.2_all.deb -qO /tmp/raspbian-archive-keyring_20120528.2_all.deb
        dpkg -i /tmp/raspbian-archive-keyring_20120528.2_all.deb
        rm -f /tmp/raspbian-archive-keyring_20120528.2_all.deb
        #
        apt -q update -q
        #DEBIAN_FRONTEND=noninteractive apt-get -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
        #
        apt-get -q install -q -y ubuntu-dev-tools sbuild schroot debootstrap qemu-user-static
    SHELL

    config.vm.provision "shell", privileged: false, inline: <<-SHELL
        #whoami # => vagrant 
        echo "# Generated by /usr/bin/select-editor" > $HOME/.selected_editor
        echo "SELECTED_EDITOR=\"/usr/bin/vim.basic\"" >> $HOME/.selected_editor
        cat <<EOF > $HOME/.sbuildrc
# *** VERIFY AND UPDATE \\\$mailto and \\\$maintainer_name BELOW ***

# Mail address where logs are sent to (mandatory, no default!)
\\\$mailto = 'vagrant';

# Name to use as override in .changes files for the Maintainer: field
#\\\$maintainer_name='vagrant <vagrant@localhost>';

# Directory for chroot symlinks and sbuild logs.  Defaults to the
# current directory if unspecified.
#\\\$build_dir='/home/vagrant/ubuntu/build';

# Directory for writing build logs to
\\\$log_dir="/home/vagrant/ubuntu/logs";

# don't remove this, Perl needs it:
1;
EOF
        cat <<EOF > $HOME/.mk-sbuild.rc
DEBOOTSTRAP_KEYRING=/usr/share/keyrings/raspbian-archive-keyring.gpg
DEBOOTSTRAP_MIRROR=http://archive.raspbian.org/raspbian
EOF
        # 1st time
        mk-sbuild --arch=armhf jessie
    SHELL
end

その他

  1. gcc : Target: arm-linux-gnueabihf
# gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.9/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Raspbian 4.9.2-10' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-armhf/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-armhf --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-armhf --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.9.2 (Raspbian 4.9.2-10)
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1