參考資料:
https://sailfishos.org/wiki/Application_SDK
https://github.com/Karry/osmscout-sailfish/wiki/Howto-build-for-Sailfish-OS
https://katastrophos.net/andre/blog/2014/03/29/running-sailfishos-build-engine-outside-virtualbox-vm/
步驟如下:
1. 開啟VirtualBox(Sailfish OS Build Engine)
2. 登入ssh並且建立一個新使用者(擁有root權限)
3. 確定權限(xxx是建立的使用者名稱)
$ ssh -p 2222 -i /home/xxx/SailfishOS/vmshare/ssh/private_keys/engine/root root@localhost
4. 複製系統到本地端
$ cd $ su # mkdir /opt/sailfishos-buildengine # rsync --numeric-ids -xazuv -e "ssh -p 2222 -i /home/xxx/SailfishOS/vmshare/ssh/private_keys/engine/root" root@localhost:/ /opt/sailfishos-buildengine
5. 建立chroot腳本(/opt/run-sailfishos-buildengine.sh)
#!/bin/bash USER=xxx USERDIR=/home/$USER SDK=/opt/SailfishOS BUILDENGINE=/opt/sailfishos-buildengine if [ $EUID -ne 0 ]; then echo "This script must be run as root." 1>&2 exit 1 fi if cmp -s /proc/$PPID/mountinfo /proc/self/mountinfo; then exec unshare -m -- "$0" "$@" echo "$0 must be run in private namespace." exit 1 fi cleanup() { umount -l $BUILDENGINE/dev/pts umount -l $BUILDENGINE/dev umount -l $BUILDENGINE/proc umount -l $BUILDENGINE/sys umount -l $BUILDENGINE/run umount -l $BUILDENGINE/home/mersdk/share umount -l $BUILDENGINE/home/src1 umount -l $BUILDENGINE/etc/ssh/authorized_keys umount -l $BUILDENGINE/host_targets umount -l $BUILDENGINE/etc/mersdk/share } trap "cleanup > /dev/null 2>&1; exit" INT QUIT TERM EXIT mount --make-slave "$(df -P "$BUILDENGINE" | tail -1 | awk '{print $NF}')" mount --bind /dev "$BUILDENGINE/dev" mount --bind /dev/pts "$BUILDENGINE/dev/pts" mount --bind /proc "$BUILDENGINE/proc" mount --bind /sys "$BUILDENGINE/sys" mount --bind /run "$BUILDENGINE/run" mount --bind "$USERDIR" "$BUILDENGINE/home/mersdk/share" mount --bind "$USERDIR" "$BUILDENGINE/home/src1" mount --bind "$SDK/mersdk/ssh" "$BUILDENGINE/etc/ssh/authorized_keys" mount --bind "$SDK/mersdk/targets" "$BUILDENGINE/host_targets" mount --bind "$SDK/vmshare" "$BUILDENGINE/etc/mersdk/share" # Rewrite user id and group id entries to match host system's users updateConfigs() { sed -i -e "s/$1:x:$2:100000:/$1:x:$(id -u $USER):$(id -g $USER):/" "$3/passwd" sed -i -e "s/$1:x:100000:/$1:x:$(id -g $USER):/" "$3/group" cp /etc/resolv.conf "$3/" } updateConfigs mersdk 1001 "$BUILDENGINE/etc" updateConfigs nemo 100000 "$BUILDENGINE/srv/mer/targets/SailfishOS-armv7hl/etc" updateConfigs nemo 100000 "$BUILDENGINE/srv/mer/targets/SailfishOS-i486/etc" cat > "$BUILDENGINE/runmersdkengine.sh" << CONTENT #!/bin/bash cleanup() { pkill -KILL -f "/usr/bin/ruby /usr/bin/puma -p 8080 -t 1:1 -e production" } trap "cleanup; exit" INT QUIT TERM EXIT # Fix up permissions to point to new uid/gid of mersdk mkdir -p /home/deploy/installroot chown -R mersdk.mersdk /home/deploy/installroot chown -R mersdk.mersdk /srv/mer/targets/* find /home/mersdk | grep -v "/home/mersdk/share" | xargs chown mersdk.mersdk # Run web server of build engine as mersdk in background: su mersdk -c "cd /usr/lib/sdk-webapp-bundle; /usr/bin/ruby /usr/bin/puma -p 8080 -t 1:1 -e production" & # Run SSH Server of build engine as root: /usr/sbin/sshd -p 2222 -D -e -f /etc/ssh/sshd_config_engine CONTENT chroot "$BUILDENGINE" sh /runmersdkengine.sh