2019年7月1日 星期一

Cross compile Avahi

Introduction

In a computer network, a link-local address is a network address that is valid only for communications within the network segment (link) or the broadcast domain that the host is connected to.
Link-local addresses are not guaranteed to be unique beyond a single network segment. Routers therefore do not forward packets with link-local addresses.
For protocols that have only link-local addresses, such as Ethernet, hardware addresses assigned by manufacturers in networking elements are unique, consisting of a vendor identification and a serial identifier.
Link-local addresses for IPv4 are defined in the address block 169.254.0.0/16 in CIDR notation. In IPv6, they are assigned the address block fe80::/10.

prepare

  • git 只用來從github copy檔案,可以用自己習慣的方式像是wget
  • automake 必要
  • gcc-arm-linux-gnueabihf cross compiler,視自己需求決定
  • libdaemon 必要,須準備ARM的share object file (我是用gentoo 的 ARM package manager 產生的)

build

先去下載source code,然後執行autogen.sh 
理論上會失敗停止,但沒關係,接著用configure指令 將設定代入,可以看到我關掉很多東西
(因為我不熟這個autoconf的流程,所以先用autogen.sh幫我產生configure檔案再去修改)
git clone https://github.com/lathiat/avahi.git
cd avahi
./autogen.sh
./configure --prefix=/usr \
--host=arm-linux-gnueabihf \
--disable-python \
--disable-qt3 \
--disable-qt4 \
--sysconfdir=/etc \
--disable-mono \
--disable-monodoc \
--disable-core-docs \
--with-systemdsystemunitdir=no \
--disable-doxygen \
--disable-xmltoman \
--disable-manpages \
--disable-gtk \
--disable-gtk3 \
--disable-pygobject \
--disable--gobject \
--with-distro=none \
--with-xml=none \
--disable-nls \
--disable-dbus \
--disable-libtool-lock \
--disable-gdbm \
--with-autoipd-user=root \
--with-autoipd-group=root
修改 avahi\avahi-autoipd\Makefile
找到 LIBDAEMON_LIBS=-ldaemon
修改成 LIBDAEMON_LIBS=-L/usr/arm-linux-gnueabihf/lib -ldaemon (簡單說你要讓Makefile找到ARM的libdaemon)
將ARM的 libdaemon.so 放入 /usr/arm-linux-gnueabihf/lib
因為我只需要autoipd,所以直接在 avahi/avahi-autoipd 裡面 make
如果出現找不到libdaemon.so.X ,就去 /usr/arm-linux-gnueabihf/lib 建symbolic link 將libdaemon.so 指向他要的檔案 

deploy

將檔案放到對應的ARM rootfs 位置,並新增需要的目錄
cp avahi/avahi-autoipd/avahi-autoipd /root/bbb_rootfs/usr/bin
mkdir /root/bbb_rootfs/etc/avahi
cp avahi/avahi-autoipd/avahi-autoipd.action /root/bbb_rootfs/etc/avahi
chmod +x /root/bbb_rootfs/etc/avahi/avahi-autoipd.action
mkdir -p /root/bbb_rootfs/usr/var/lib/avahi-autoipd
cp /usr/arm-linux-gnueabihf/lib/libdaemon.so /root/bbb_rootfs/usr/lib

runtime

先確認有沒有root這個group,若沒有就新增
為了讓 avahi-autoipd.action 運作,要在ARM裝net-tools 或 iproute2
如果出現找不到libdaemon,一樣去建symbolic link

echo root:x:0:root >> ./etc/group
avahi-autoipd --help
avahi-autoipd eth0
若出現 avahi-autoipd.action 找不到指令
請先確認 avahi-autoipd.action 的第一行,bash 是否是跟ARM上面的一樣
例如 busybox 可能是 ash

沒有留言:

張貼留言

NoSQL Redis intro

Redis是一個使用ANSI C編寫的開源、支援網路、基於記憶體、可選永續性的鍵值對儲存資料庫。 支援rdb 及aof 兩種儲存方式 From  https://zh.wikipedia.org/wiki/Redis Redis 目前擁有兩種資料...