Setup baserock
Obtain a Baserock x86_64 VM and log into it. The VM should at least have 4G of RAM, otherwise it may get aborted during building.
Upgrade it to devel Baserock
vi setup-crossboot.sh
Add the following. One oddity is that the terminology between the kernel and Baserock is inconsistent. In the kernel this architecture is known as aarch64, whereas in Baserock it's called armv8l64.
#!/bin/bash
BASEROCK_VERSION='14.29'
MY_FULL_NAME="Citizen Five"
EMAIL_ADDRESS=c5@domain
CONF_FILE=/src/morph.conf
TROVE='my-trove.domain'
START_ARCH='x86_64'
TARGET_ARCH='armv8l64'
TARGET_ARCH_KERNEL_NAME='aarch64'
MORPHLIB=/usr/lib/python2.7/site-packages/morphlib/__init__.py
MORPHLIB2=/src/morph/morphlib/__init__.py
MORPHLIB_UTIL=/src/morph/morphlib/util.py
LINUXHEADERS=strata/build-essential/stage2-linux-api-headers.morph
DEV_BRANCH="baserock/tiagogomes/armv8l64"
if [ ! -d /src ]; then
mkdir /src
if [ -b /dev/sdb ]; then
mkfs.btrfs -L src /dev/sdb
echo 'LABEL=src /src btrfs defaults 0 2' >> /etc/fstab
reboot
fi
fi
btrfs filesystem resize max /
echo '[config]' > $CONF_FILE
echo 'log = /src/morph.log' >> $CONF_FILE
echo 'log-max = 200M' >> $CONF_FILE
echo 'cachedir = /src/cache' >> $CONF_FILE
echo 'tempdir = /src/tmp' >> $CONF_FILE
#echo "trove-host = $TROVE" >> $CONF_FILE
ln -sv $CONF_FILE /etc/morph.conf
cd /src
git config --global user.name "$MY_FULL_NAME"
git config --global user.email "$EMAIL_ADDRESS"
git config --global push.default simple
git clone git://git.baserock.org/baserock/baserock/definitions --branch baserock-$BASEROCK_VERSION
cd definitions
echo 'name: upgrade-devel' > devel-system-$START_ARCH-generic.morph
echo 'kind: cluster' >> devel-system-$START_ARCH-generic.morph
echo 'systems:' >> devel-system-$START_ARCH-generic.morph
echo '- morph: systems/devel-system-$START_ARCH-generic.morph' >> devel-system-$START_ARCH-generic.morph
echo ' deploy:' >> devel-system-$START_ARCH-generic.morph
echo ' self:' >> devel-system-$START_ARCH-generic.morph
echo ' type: extensions/ssh-rsync' >> devel-system-$START_ARCH-generic.morph
echo ' location: root@127.0.0.1' >> devel-system-$START_ARCH-generic.morph
# switch to the development branch
if [ $DEV_BRANCH ]; then
git stash
git checkout $DEV_BRANCH
fi
morph --verbose build devel-system-$START_ARCH-generic.morph
cd /src
git clone git://git.baserock.org/delta/linux.git
cd definitions
git checkout -b crossboot
if [ ! -f systems/cross-bootstrap-system-$TARGET_ARCH-generic.morph ]; then
echo "arch: $TARGET_ARCH" > systems/cross-bootstrap-system-$TARGET_ARCH-generic.morph
echo 'description: A system that produces the minimum needed to build a devel system' >> systems/cross-bootstrap-system-$TARGET_ARCH-generic.morph
echo 'kind: system' >> systems/cross-bootstrap-system-$TARGET_ARCH-generic.morph
echo "name: cross-bootstrap-system-$TARGET_ARCH-generic" >> systems/cross-bootstrap-system-$TARGET_ARCH-generic.morph
echo 'strata:' >> systems/cross-bootstrap-system-$TARGET_ARCH-generic.morph
echo '- morph: strata/build-essential.morph' >> systems/cross-bootstrap-system-$TARGET_ARCH-generic.morph
echo '- morph: strata/core.morph' >> systems/cross-bootstrap-system-$TARGET_ARCH-generic.morph
echo '- morph: strata/cross-bootstrap.morph' >> systems/cross-bootstrap-system-$TARGET_ARCH-generic.morph
git add systems/cross-bootstrap-system-$TARGET_ARCH-generic.morph
git commit -a -m"Add a cross bootstrap morph for $TARGET_ARCH"
fi
# add the target architecture if needed
if ! grep -q "$TARGET_ARCH" $MORPHLIB; then
sed -i "s/'x86_64',/'x86_64','$TARGET_ARCH',/g" $MORPHLIB
fi
if ! grep -q "$TARGET_ARCH" $LINUXHEADERS; then
sed -i "s/ARCH=\"x86_64\" ;;/ARCH=\"x86_64\" ;;\n $TARGET_ARCH)\n ARCH=\"$TARGET_ARCH_KERNEL_NAME\" ;;/g" $LINUXHEADERS
if [ ! "$?" = "0" ]; then
exit 6826
fi
fi
# upgrade morph
cd /src
git clone git://git.baserock.org/baserock/baserock/morph
echo '#!/bin/sh' > /usr/bin/morph
echo 'morphpath=/src/morph' >> /usr/bin/morph
echo 'PYTHONPATH="$morphpath" "$morphpath/morph" "$@"' >> /usr/bin/morph
chmod +x /usr/bin/morph
# add the architecture to morphlib
if ! grep -q "$TARGET_ARCH" $MORPHLIB2; then
sed -i "s/'x86_64',/'x86_64','$TARGET_ARCH',/g" $MORPHLIB2
fi
if ! grep -q "$TARGET_ARCH_KERNEL_NAME" $MORPHLIB_UTIL; then
sed -i "s/: 'x86_64',/: 'x86_64',\n '$TARGET_ARCH_KERNEL_NAME': '$TARGET_ARCH',/g" $MORPHLIB_UTIL
fi
cd /src/definitions
morph cross-bootstrap -v $TARGET_ARCH file:///src/definitions HEAD systems/cross-bootstrap-system-$TARGET_ARCH-generic.morph
exit 0
Common error in /src/morph/morphlib/plugins/cross-bootstrap_plugin.py:
ERROR: Nothing to cross-compile. Only chunks built in 'bootstrap' mode can be cross-compiled.
Save, then run.
chmod +x setup-crossboot.sh
./setup-crossboot.sh
Note: 8G RAM or more on the VM is recommended to run the cross-bootstrap, if the RAM is not big enough, the VM may be aborted during the process.
Native build bootstrap system.
Copy the tarball to a armv8l64 VM, extract the tarball onto a top level of a disk.On the arm VM,
tar -xvf /path/to/store/tarball /path/to/extracted/tarball
chroot into the fs:
chroot /path/to/extracted/tarball /bin/sh
run native-bootstrap script:
./native-bootstrap
Note: it will take quite long to run this script, and it won't keep the progress if it has been interrupted. So make sure you won't interrupt it during running. If it does happen, run:
rm -r /*.dist
to clear directory, and re-run the native-bootstrap scripte.
Prepare bootstrap system to build a devel-system of baserock.
Morph uses linux-user-chroot when building, you should be able to run this if it works:
/path/to/extracted/tarball/usr/bin/linux-user-chroot /path/to/extracted/tarball /bin/sh
Mount some special filesystems to be used inside the chroot
cd /path/to/uncompressed/tarball mount -t proc proc proc/ mount -t sysfs sys sys/ mount -o bind /dev dev/ mount -o bind /tmp tmp/
chroot into it
chroot . /bin/sh PATH=/bin:/usr/bin:/sbin:/usr/sbin LD_LIBRARY_PATH=/lib:/lib64 ldconfig
Build a devel system
Now you are ready to start using baserock to build and deploy a devel system.
Note: I didn't meet problem on building system, but when deploying, it reported mkfs.btrfs, btrfs and extlinux are missing in bootstarp system. This may be fixed in the future, for the time beings, copy those binaries from host OS will work around it.