building lineage os (devon/moto g32)
You need atleast 32G of RAM or don't even bother trying to build LineageOS.
Note
- Enable
multilib
repo in/etc/pacman.conf
. - run...
source: https://wiki.lineageos.org/devices/devon/build/
paru -S lineageos-devel
mkdir -p ~/android/lineage
cd ~/android/lineage
repo init -u https://github.com/LineageOS/android.git -b lineage-22.2 --git-lfs --no-clone-bundle
repo sync
repo sync will take a while..
Note
Note the output of breakfast devon
. It ends in an error.
The highlights I've added are indicating files being fetched and created:
03:14:39 Build sandboxing disabled due to nsjail error.
In file included from build/make/core/config.mk:406:
In file included from build/make/core/envsetup.mk:351:
build/make/core/product_config.mk:226: error: Cannot locate config makefile for product "lineage_devon".
03:14:39 dumpvars failed with: exit status 1
Device devon not found. Attempting to retrieve device repository from LineageOS Github (http://github.com/LineageOS).
Found repository: android_device_motorola_devon
Default revision: lineage-22.2
Checking branch info
Checking if device/motorola/devon is fetched from android_device_motorola_devon
Adding dependency: LineageOS/android_device_motorola_devon -> device/motorola/devon
Syncing repository to retrieve project.
Fetching: 100% (1/1), done in 1.363s
Checking out: 100% (1/1), done in 0.019s
repo sync has finished successfully.
Repository synced!
Looking for dependencies in device/motorola/devon
Default revision: lineage-22.2
Checking branch info
Adding dependencies to manifest
Checking if device/motorola/sm6225-common is fetched from android_device_motorola_sm6225-common
Adding dependency: LineageOS/android_device_motorola_sm6225-common -> device/motorola/sm6225-common
Syncing dependencies
Fetching: 100% (2/2), done in 2.218s
Checking out: 50% (1/2), done in 0.036s
Checking out: 50% (1/2), done in 0.000s
repo sync has finished successfully.
Looking for dependencies in device/motorola/sm6225-common
Default revision: lineage-22.2
Checking branch info
Default revision: lineage-22.2
Checking branch info
Adding dependencies to manifest
Checking if hardware/motorola is fetched from android_hardware_motorola
Adding dependency: LineageOS/android_hardware_motorola -> hardware/motorola
Checking if kernel/motorola/sm6225 is fetched from android_kernel_motorola_sm6225
Adding dependency: LineageOS/android_kernel_motorola_sm6225 -> kernel/motorola/sm6225
Syncing dependencies
Fetching: 100% (4/4), done in 3m4.599s
Updating files: 100% (74707/74707), done.
Checking out: 50% (2/4), done in 7.851s
Checking out: 50% (2/4), done in 0.017s
repo sync has finished successfully.
Looking for dependencies in hardware/motorola
hardware/motorola has no additional dependencies.
Looking for dependencies in kernel/motorola/sm6225
kernel/motorola/sm6225 has no additional dependencies.
Done
03:18:04 Build sandboxing disabled due to nsjail error.
In file included from build/make/core/config.mk:406:
In file included from build/make/core/envsetup.mk:351:
In file included from build/make/target/product/telephony_vendor.mk:21:
device/motorola/devon/device.mk:72: error: vendor/motorola/devon/devon-vendor.mk does not exist..
03:18:05 dumpvars failed with: exit status 1
03:18:06 Build sandboxing disabled due to nsjail error.
In file included from build/make/core/config.mk:406:
In file included from build/make/core/envsetup.mk:351:
In file included from build/make/target/product/telephony_vendor.mk:21:
device/motorola/devon/device.mk:72: error: vendor/motorola/devon/devon-vendor.mk does not exist..
03:18:06 dumpvars failed with: exit status 1
** Don't have a product spec for: 'lineage_devon'
** Do you have the right repo manifest?
Note
I use adb
binary from android-tools
arch package. I also booted devon
(moto g32) with a fresh lineageos os install without gapps, and enabled
adb-run-as-root in Settings
after the usual stuff (developer mode after
tapping build number 7 times). I think this information is crucial because
in a previous attempt, I used adb
that came with flutter but I'm not certain
I had enabled rooted debugging.
The same error is reported here:
https://gitlab.com/LineageOS/issues/android/-/issues/8240.
With adb connection to devon...
Note
Now you have ~/android/lineage/vendor/motorala
06:18:35 Build sandboxing disabled due to nsjail error.
Looking for dependencies in device/motorola/devon
Looking for dependencies in device/motorola/sm6225-common
Looking for dependencies in hardware/motorola
hardware/motorola has no additional dependencies.
Looking for dependencies in kernel/motorola/sm6225
kernel/motorola/sm6225 has no additional dependencies.
06:18:38 Build sandboxing disabled due to nsjail error.
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=15
LINEAGE_VERSION=22.2-20250529-UNOFFICIAL-devon
TARGET_PRODUCT=lineage_devon
TARGET_BUILD_VARIANT=userdebug
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv7-a-neon
TARGET_2ND_CPU_VARIANT=cortex-a9
HOST_OS=linux
HOST_OS_EXTRA=Linux-6.14.7-zen2-1-zen-x86_64-Arch-Linux
HOST_CROSS_OS=windows
BUILD_ID=BP1A.250505.005
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/motorola/sm6225-common hardware/motorola hardware/samsung vendor/qcom/opensource/usb/etc vendor/motorola/sm6225-common device/motorola/devon vendor/motorola/devon hardware/qcom-caf/sm8250 hardware/qcom-caf/bootctrl vendor/qcom/opensource/commonsys/display vendor/qcom/opensource/commonsys-intf/display vendor/qcom/opensource/display vendor/qcom/opensource/data-ipa-cfg-mgr-legacy-um vendor/qcom/opensource/dataservices hardware/qcom-caf/wlan
============================================
Note
- brunch devon = breakfast devon + mka bacon
- mka bacon -j8
webview compilation error¶
source: https://www.reddit.com/r/LineageOS/comments/11rnaoi/webview_wont_compile_after_the_recent_git_lfs
repo init --git-lfs
rm -rf external/chromium-webview/prebuilt/*
rm -rf .repo/projects/external/chromium-webview/prebuilt/*.git
rm -rf .repo/project-objects/LineageOS/android_external_chromium-webview_prebuilt_*.git
repo sync
patching with kernel kernelsu-next and susfs¶
Looking at the highlights from breakfast devon
command output in the earlier
section we see the kernel sources were fetched into kernel/motorola/sm6225
,
here it is for recap:
Checking if hardware/motorola is fetched from android_hardware_motorola
Adding dependency: LineageOS/android_hardware_motorola -> hardware/motorola
Checking if kernel/motorola/sm6225 is fetched from android_kernel_motorola_sm6225
Adding dependency: LineageOS/android_kernel_motorola_sm6225 -> kernel/motorola/sm6225
cd ~/android/lineage
cd kernel/motoral/sm6255
# source: https://kernelsu-next.github.io/webpage/pages/installation.html
# Downloads kernelsu-next patched for susfs
curl -LSs "https://raw.githubusercontent.com/rifsxd/KernelSU-Next/next-susfs/kernel/setup.sh" | bash -s next-susfs
# source: https://gitlab.com/simonpunk/susfs4ksu.git
# Download susfs4ksu
git clone --branch kernel-4.19 --single-branch --depth 1 https://gitlab.com/simonpunk/susfs4ksu.git
cd susfs4ksu
cp ./kernel_patches/50_add_susfs_in_kernel-4.19.patch ../
cp ./kernel_patches/fs/* ../fs/
cp ./kernel_patches/include/linux/* ../include/linux
cd ..
patch -p1 < 50_add_susfs_in_kernel-4.19.patch
# you should manually fix the patches don't work
Note
So far you should note that we downloaded kernelsu-next that was already patched for susfs. This is why we only applied the patches that were relevant to the kernal itself and not kernelsu-next.
now you need to modify the kernel mkconfig file.
vector@ArchLinuxR72700 ~/android/lineage $ find device/motorola/devon -name "*.mk" -exec grep -l "TARGET_KERNEL_CONFIG|KERNEL_DEFCONFIG" {} \;
device/motorola/devon/BoardConfig.mk
vector@ArchLinuxR72700 ~/android/lineage $ grep -i "TARGET_KERNEL_CONFIG|KERNEL_DEFCONFIG" device/motorola/devon/BoardConfig.mk
TARGET_KERNEL_CONFIG += vendor/ext_config/devon-default.config
The above two commands informed me the file to mod is vendor/ext_config/devon-default.config
inside the
kernel source.
To that file I add these two options:
Now this being a non-GKI kernel where kprobe didn't work, I had to manually mod the files as per the instructions here: https://kernelsu.org/guide/how-to-integrate-for-non-gki.html#manually-modify-the-kernel-source. I'm quoting them here anyway, but i recommend you refer the source.
diff --git a/fs/exec.c b/fs/exec.c
index ac59664eaecf..bdd585e1d2cc 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1890,11 +1890,14 @@ static int __do_execve_file(int fd, struct filename *filename,
return retval;
}
+#ifdef CONFIG_KSU
+extern bool ksu_execveat_hook __read_mostly;
+extern int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv,
+ void *envp, int *flags);
+extern int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr,
+ void *argv, void *envp, int *flags);
+#endif
static int do_execveat_common(int fd, struct filename *filename,
struct user_arg_ptr argv,
struct user_arg_ptr envp,
int flags)
{
+ #ifdef CONFIG_KSU
+ if (unlikely(ksu_execveat_hook))
+ ksu_handle_execveat(&fd, &filename, &argv, &envp, &flags);
+ else
+ ksu_handle_execveat_sucompat(&fd, &filename, &argv, &envp, &flags);
+ #endif
return __do_execve_file(fd, filename, argv, envp, flags, NULL);
}
diff --git a/fs/open.c b/fs/open.c
index 05036d819197..965b84d486b8 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -348,6 +348,8 @@ SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
return ksys_fallocate(fd, mode, offset, len);
}
+#ifdef CONFIG_KSU
+extern int ksu_handle_faccessat(int *dfd, const char __user **filename_user, int *mode,
+ int *flags);
+#endif
/*
* access() needs to use the real uid/gid, not the effective uid/gid.
* We do this by temporarily clearing all FS-related capabilities and
@@ -355,6 +357,7 @@ SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
*/
long do_faccessat(int dfd, const char __user *filename, int mode)
{
const struct cred *old_cred;
struct cred *override_cred;
struct path path;
struct inode *inode;
struct vfsmount *mnt;
int res;
unsigned int lookup_flags = LOOKUP_FOLLOW;
+ #ifdef CONFIG_KSU
+ ksu_handle_faccessat(&dfd, &filename, &mode, NULL);
+ #endif
if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
return -EINVAL;
diff --git a/fs/read_write.c b/fs/read_write.c
index 650fc7e0f3a6..55be193913b6 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -434,10 +434,14 @@ ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
}
EXPORT_SYMBOL(kernel_read);
+#ifdef CONFIG_KSU
+extern bool ksu_vfs_read_hook __read_mostly;
+extern int ksu_handle_vfs_read(struct file **file_ptr, char __user **buf_ptr,
+ size_t *count_ptr, loff_t **pos);
+#endif
ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
{
ssize_t ret;
+ #ifdef CONFIG_KSU
+ if (unlikely(ksu_vfs_read_hook))
+ ksu_handle_vfs_read(&file, &buf, &count, &pos);
+ #endif
+
if (!(file->f_mode & FMODE_READ))
return -EBADF;
if (!(file->f_mode & FMODE_CAN_READ))
diff --git a/fs/stat.c b/fs/stat.c
index 376543199b5a..82adcef03ecc 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -148,6 +148,8 @@ int vfs_statx_fd(unsigned int fd, struct kstat *stat,
}
EXPORT_SYMBOL(vfs_statx_fd);
+#ifdef CONFIG_KSU
+extern int ksu_handle_stat(int *dfd, const char __user **filename_user, int *flags);
+#endif
+
/**
* vfs_statx - Get basic and extra attributes by filename
* @dfd: A file descriptor representing the base dir for a relative filename
@@ -170,6 +172,7 @@ int vfs_statx(int dfd, const char __user *filename, int flags,
int error = -EINVAL;
unsigned int lookup_flags = LOOKUP_FOLLOW | LOOKUP_AUTOMOUNT;
+ #ifdef CONFIG_KSU
+ ksu_handle_stat(&dfd, &filename, &flags);
+ #endif
if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT |
AT_EMPTY_PATH | KSTAT_QUERY_FLAGS)) != 0)
return -EINVAL;
Note
Even The instructions above are for kernelsu, but it is the same for kernelsu-next.
The above files are in the same fs
we earlier moved the susfs patches into.
Finally.
Compile the kernel with brunch devon
at lineage os source to build the kernel
and the kernel output will be at $OUT/boot.img
which you can easily flash
with fastboot flash boot boot.img
after booting up¶
I followed this gist by github userid TheUnrealZaka.
https://gist.github.com/TheUnrealZaka/042040a1700ad869d54e781507a9ba4f
For chatgpt integrity check: