I am on Ubuntu Server 12.04 x86_64 and I need to build Android CyanogenMod 7.2 kernel module. My phone has custom ROM and a patched kernel:

adb shell cat /proc/version


Linux version (subbotin@avs234) (gcc version 4.4.0 (GCC) ) #2 PREEMPT Sun Mar 13 14:55:50 MSK 2011

I have this variable setup in addition to toolchain variables etc.

export LOCALVERSION="-cyanogenmod-gf3345ef-dirty (subbotin@avs234)"

When I run make (note that on Ubuntu bash is dash) I get the following:

CHK    include/linux/version.h
/bin/sh: 1: Syntax error: "(" unexpected (expecting ")")
make: ***[include/generated/utsrelease.h] Error 2

However, if I remove "(subbotin@avs234)" the kernel compiles just fine. I need a full vermagic string since I suspect that this kernel module wouldn't load because of difference in the version string. What is the problem with parentheses?

A more detailed description: The device is HTC Desire (bravo) GSM and the application is EDS Lite (http://play.google.com/store/apps/details?id=com.sovworks.edslite). I partially followed this http://oldwiki.cyanogenmod.org/wiki/Building_Kernel_from_source and this is a kernel module compilation guide http://www.sovworks.com/details.html#compileModule. In the latter link it is mentioned that vermagic string should probably match completely. When I try to load this module from the application mount menu I get 'failed loading kernel module'

#get repo tool
mkdir -p ~/bin 
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo 
chmod a+x ~/bin/repo 

#clone repo for cm-kernel
mkdir -p ~/Android/kernel 
cd ~/Android/kernel 
git clone git://github.com/CyanogenMod/cm-kernel.git 
cd cm-kernel

#pull the kernel configuration from the device
#my config file is here: http://pastebin.com/aHA2mETG
adb pull /proc/config.gz ~/Android/kernel/cm-kernel
cd ~/Android/kernel/cm-kernel
gunzip config.gz
sed 's/CONFIG_LOCALVERSION\([[:alnum:][:punct:]]\)*//' config > .config
cp config .config

#toolchain from http://developer.android.com/sdk/index.html#download (sdk tools)

export CROSS_COMPILE=~/Android/Toolchain/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
export CCOMPILER=~/Android/Toolchain/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
export ARCH=arm
export SUBARCH=arm
export LOCALVERSION="-cyanogenmod-gf3345ef-dirty (subbotin@avs234)"
make oldconfig

#Answer "no" CONFIG_LOCALVERSION_AUTO (the second prompt) request.

#download EDS kernel module src http://www.sovworks.com/downloads.html
#extract to ~/Android/km
cd ~/km
make -C ~/Android/kernel/cm-kernel\
 ARCH=arm CROSS_COMPILE=~/Android/Toolchain/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-\
 SUBDIRS=~/Android/km modules

#if LOCALVERSION="-cyanogenmod-gf3345ef-dirty" then vermagic string is as in the following
modinfo eds.ko
vermagic: preempt mod_unload ARMv7 

upd: just noticed that the stable version of currently installed kernel (which is 3) is not equal to the built kernel stable version (6). Not sure if they are compatible - maybe the problem is with installed kernel version string after all?

  • 2
    There are probably missing quote marks somewhere in the build scripts. Please link to the source archive or repository that you downloaded and tell us exactly what environment variables you set and what commands you ran. – Gilles 'SO- stop being evil' Jul 19 '13 at 23:51
  • Minor correction: bash is always bash, but sh is linked to dash, whereas on some systems (including older Ubuntu) it is a link to bash. For what it's worth, invoking bash as sh disables many bashisms, albeit not all of them. – tripleee Jul 20 '13 at 16:25

However, if I remove "(subbotin@avs234)" the kernel compiles just fine.

You don't need this in the LOCALVERSION. "subbotin@avs234" is just the one that compiled the kernel (user@host). It's not part of the version string nor needed for anything related to the compilation of the kernel.

  • Marking this as an answer since I gave up trying to do what I intended back when I created the question and because this answers the original question about parentheses. – Dmitrii S. Jul 6 '14 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.