Jump to content

User:Alexeymin/Kernel development in chroot using abuild: Difference between revisions

From postmarketOS Wiki
Created page with "=== Are you tired of the fact that every time you build your kernel in pmbootstrap it starts biulding it from scratch? Does it take too much time? and envkernel does not work/..."
 
mNo edit summary
Line 24: Line 24:
  su pmos
  su pmos
  export HOME=/home/pmos
  export HOME=/home/pmos
  cd
  cd /home/pmos/build  # the directory where APKBUILD file is


You can restart all your build from the beginning with this:
You can restart all your build from the beginning with this:
Line 42: Line 42:
OR manually
OR manually


cd /home/pmos/build/src  # or whatever the directory after unpacking kernel archive would be
  make ARCH=arm64 CROSS_COMPILE=aarch64-alpine-linux-musl- defconfig
  make ARCH=arm64 CROSS_COMPILE=aarch64-alpine-linux-musl- defconfig
  make ARCH=arm64 CROSS_COMPILE=aarch64-alpine-linux-musl- menuconfig
  make ARCH=arm64 CROSS_COMPILE=aarch64-alpine-linux-musl- menuconfig

Revision as of 15:28, 29 November 2019

Are you tired of the fact that every time you build your kernel in pmbootstrap it starts biulding it from scratch? Does it take too much time? and envkernel does not work/broken? Then this is for you!

Prepare config and chroots:

pmbootstrap -y zap
pmbootstrap init    # for your device

Start building your kernel but cancel early; download all source and checksum; wait until it and starts build, this way we'll have all sources unpacked and placed where needed, and dependencies prepared:

pmbootstrap checksum linux-your-kernel
pmbootstrap build --force --arch aarch64 linux-your-kernel
^C  # press Ctrl+C as soon as pmbootstrap log starts to show building process

Switch to native chroot:

pmbootstrap chroot

In native chroot verify that all deps are installed (this is run as root user inside chroot):

apk add abuild build-base ccache git devicepkg-dev mkbootimg postmarketos-base ccache-cross-symlinks gcc-aarch64 g++-aarch64 crossdirect ncurses-dev bash bc bison elfutils-dev flex gmp-dev installkernel linux-headers openssl-dev perl sed

The following build commands (make or abuild invocations) are run in native chroot as pmos user!

su pmos
export HOME=/home/pmos
cd /home/pmos/build   # the directory where APKBUILD file is

You can restart all your build from the beginning with this:

cd /home/pmos/build   # the directory where APKBUILD file is
rm -rf src
abuild fetch verify unpack prepare

Build (repeat multiple times during development): this does not restart full kernel build every time

export ARCH=arm64
export CARCH=aarch64
export CROSS_COMPILE=aarch64-alpine-linux-musl-
export CC=aarch64-alpine-linux-musl-gcc
abuild -df build

OR manually

cd /home/pmos/build/src   # or whatever the directory after unpacking kernel archive would be
make ARCH=arm64 CROSS_COMPILE=aarch64-alpine-linux-musl- defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-alpine-linux-musl- menuconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-alpine-linux-musl- -j9
make ARCH=arm64 mrproper

If you want to build as package:

abuild package   # or
abuild rootpkg   # (?) not tested yet

Hope it helps!