Created
December 19, 2011 23:01
-
-
Save jyio/1499318 to your computer and use it in GitHub Desktop.
build the CyanogenMod 9 preview for NOOK Color
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Copyright (c) 2011 Jiang Yio, http://inportb.com/ | |
## | |
## Permission is hereby granted, free of charge, to any person obtaining | |
## a copy of this software and associated documentation files (the | |
## "Software"), to deal in the Software without restriction, including | |
## without limitation the rights to use, copy, modify, merge, publish, | |
## distribute, sublicense, and/or sell copies of the Software, and to | |
## permit persons to whom the Software is furnished to do so, subject to | |
## the following conditions: | |
## | |
## The above copyright notice and this permission notice shall be | |
## included in all copies or substantial portions of the Software. | |
## | |
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
## NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
## LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
## OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
## WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
## ==========[ QUICKSTART ]========== | |
## Thanks to the generosity of FatTire, dalingrin, and other CyanogenMod | |
## hackers, we are now able to enjoy this CyanogenMod 9 preview. This | |
## Makefile maintains an environment for compiling CyanogenMod for the | |
## Barnes & Noble NOOK Color. The shell scripts included are based on | |
## FatTire's instructions, which you are encouraged to read before you | |
## continue | |
## <https://docs.google.com/document/d/19f7Z1rxJHa5grNlNFSkh7hQ0LmDOuPdKMQUg8HFiyzs/edit> | |
## | |
## And until FatTire says otherwise, please do NOT distribute the update | |
## packages that you generate. We're in education mode here, so let's | |
## learn together. We wouldn't want the public repository to close now, | |
## would we? :P | |
## | |
## By following these instructions and/or using this set of files, you | |
## proceed at your own risk. Under no circumstances would you hold | |
## FatTire or Jiang Yio responsible for any negative consequences. | |
## | |
## IF YOU ALREADY HAVE A WORKING ENVIRONMENT IN ~/bin AND ~/android -- | |
## This Makefile is for you, too. Just drop it in ~/android and do | |
## make commonconfig | |
## make init | |
## You also need to have rsync installed. There is no need to work from | |
## scratch. | |
## | |
## IF YOU ARE STARTING FROM THE BEGINNING -- | |
## Firstly, create a directory where you want all the files to go. | |
## Then, put this file (Makefile) inside the directory, open a terminal | |
## window, and navigate to the directory. | |
## | |
## If you already have GNU Make, you could install the other required | |
## software on Debian/Ubuntu by running | |
## sudo make apt | |
## | |
## Otherwise, you could install build-essential first, then see the | |
## previous paragraph. Alternatively, you could install the software | |
## yourself | |
## git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev | |
## libwxgtk2.6-dev squashfs-tools build-essential zip curl rsync | |
## libncurses5-dev zlib1g-dev sun-java6-jdk pngcrush schedtool | |
## On 64-bit systems, you'd also need | |
## g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline6-dev | |
## On Ubuntu 10.10, you need to enable the partner repository for | |
## sun-java6-jdk | |
## sudo add-apt-repository 'deb http://archive.canonical.com/ maverick partner' | |
## | |
## By default, this script tries to keep everything in your working | |
## directory. If you want the ~/bin and ~/android "standard", run | |
## make commonconfig | |
## | |
## Now that you have all the required software, you could initialize | |
## your working directory | |
## make init | |
## | |
## After answering a couple of questions, you should be ready to fetch | |
## the code. This takes a while, so it might be time to plan a nap or a | |
## coffee break. Wait for it | |
## make sync | |
## | |
## Get out your NOOK Color and connect it to your computer using USB. | |
## You would now obtain some proprietary bits from your device | |
## make vendor | |
## If you see errors, you might need to reconfigure adb. Perhaps an | |
## easier (but less secure) way is to start the adb service as root | |
## sudo make adb | |
## and try again. | |
## | |
## You are now ready for the actual build process. This might take a few | |
## hours (depending on your hardware), so plan ahead: | |
## make build | |
## | |
## That's it! You could now wipe your device and copy the files over, | |
## according to FatTire's tutorial, where $OUT is | |
## system/out/target/product/encore | |
## and skip the next two paragraphs. Or, you could continue reading and | |
## make your own update.zip package. | |
## | |
## You would now make a snapshot, so you could roll back to an older | |
## build if you need to: | |
## make snapshot | |
## This is actually required for the next step. The snapshots are | |
## incremental, so they don't use too much space unless there is a lot | |
## of new content. Since the feature is implemented using hard links, it | |
## is safe to remove any snapshot except for "current". Snapshots are | |
## stored within the snapshot directory. | |
## | |
## Then, simply build your package | |
## make package CLEAN=1 | |
## If you want a signed package, do | |
## make package CLEAN=1 SIGN=1 | |
## and if you want to package a snapshotted build, do something like | |
## make package NAME=update-cm-9.0-encore-2011-12-19-00-54-13 | |
## The options CLEAN, SIGN, and NAME may be combined in any way. | |
## | |
## To get the latest source code, simply sync | |
## make sync | |
## and build | |
## make build | |
## | |
## Good luck! | |
## ==========[ QUICKSTART ]========== | |
## ==========[ HACKS ]========== | |
## - adds stddef.h to linker.cpp per FatTire's instructions | |
## ==========[ HACKS ]========== | |
## ==========[ CONFIGURE ]========== | |
## To configure this script, first run | |
## make config | |
## then edit the resulting config.mk | |
## file. | |
## ==========[ CONFIGURE ]========== | |
USER_HOME := ${HOME} | |
HOME := | |
ifneq ($(wildcard config.mk),) | |
include config.mk | |
endif | |
ifndef HOME | |
HOME := $(shell pwd) | |
endif | |
ifndef WORKDIR | |
WORKDIR := $(shell pwd) | |
endif | |
ifndef BINDIR | |
BINDIR := ${WORKDIR}/bin | |
endif | |
ifndef SNAPSHOT | |
SNAPSHOT := ${WORKDIR}/snapshot | |
endif | |
ifndef SIGNDIR | |
SIGNDIR := ${WORKDIR}/sign | |
endif | |
ifndef BIN_SIGNAPK | |
BIN_SIGNAPK := ${SIGNDIR}/signapk.jar | |
endif | |
ifndef KEY_SYSTEM_PEM | |
KEY_SYSTEM_PEM := ${SIGNDIR}/testkey.x509.pem | |
endif | |
ifndef KEY_SYSTEM_PK8 | |
KEY_SYSTEM_PK8 := ${SIGNDIR}/testkey.pk8 | |
endif | |
ifndef SERIES | |
SERIES := update-cm-9.0-encore | |
endif | |
ifndef USE_CCACHE | |
USE_CCACHE := 1 | |
endif | |
## ==========[ STOP ]========== | |
## No modification is necessary beyond this point. | |
## ==========[ STOP ]========== | |
PATH := ${WORKDIR}/system/out/host/linux-x86/bin:${BINDIR}:${PATH} | |
SYSTEM := ${WORKDIR}/system | |
OUTDIR := ${SYSTEM}/out/target/product/encore | |
NOW := $(shell date -u +%Y-%m-%d-%H-%M-%S) | |
## installs packages using apt-get, including the infamous sun-java6-jdk | |
apt: | |
echo deb http://ppa.launchpad.net/sun-java-community-team/sun-java6/ubuntu maverick main \ | |
> /etc/apt/sources.list.d/sun-java-community-team-sun-java6-maverick.list | |
gpg --ignore-time-conflict --no-options --no-default-keyring \ | |
--secret-keyring /tmp/tmp.NGjm2jWbTx --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg \ | |
--primary-keyring /etc/apt/trusted.gpg --keyserver hkp://keyserver.ubuntu.com:80/ \ | |
--recv 7E38C0AE69286BF825C037D8D8D75E403EBCE749 | |
apt-get update | |
apt-get -y install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools \ | |
build-essential zip curl rsync libncurses5-dev zlib1g-dev sun-java6-jdk pngcrush schedtool | |
if [ `getconf LONG_BIT` = '64' ]; then apt-get -y install g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline6-dev; fi | |
## restarts the adb service | |
adb: | |
adb kill-server | |
adb start-server | |
## initializes working environment | |
init: | |
rm -rf ${WORKDIR}/sign.tgz ${WORKDIR}/update-lite.tgz | |
mkdir -p ${BINDIR} ${SIGNDIR} ${SYSTEM} ${SNAPSHOT}/current | |
ifneq ($(wildcard ${BINDIR}/repo),) | |
@echo ${BINDIR}/repo exists: not fetching | |
else | |
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ${BINDIR}/repo | |
chmod a+x ${BINDIR}/repo | |
endif | |
ifneq ($(wildcard ${BINDIR}/adb),) | |
@echo ${BINDIR}/adb exists: not fetching | |
else | |
curl http://dl.dropbox.com/u/1213413/cm9/adb > ${BINDIR}/adb | |
chmod a+x ${BINDIR}/adb | |
endif | |
curl http://dl.dropbox.com/u/1213413/cm9/sign.tgz > ${WORKDIR}/sign.tgz | |
tar pkzxvf ${WORKDIR}/sign.tgz -C ${SIGNDIR} | |
curl http://dl.dropbox.com/u/1213413/cm9/update-lite.tgz > ${WORKDIR}/update-lite.tgz | |
tar pkzxvf ${WORKDIR}/update-lite.tgz -C ${SNAPSHOT}/current | |
rm ${WORKDIR}/sign.tgz ${WORKDIR}/update-lite.tgz | |
ifneq ($(wildcard ${HOME}/.android/adb_usb.ini),) | |
if ! grep -q "0x2080" ${HOME}/.android/adb_usb.ini; then echo 0x2080 >> ${HOME}/.android/adb_usb.ini; fi | |
else | |
mkdir -p ${HOME}/.android | |
echo 0x2080 > ${HOME}/.android/adb_usb.ini | |
endif | |
ifneq ($(wildcard ${SYSTEM}/.repo),) | |
@echo ${SYSTEM}/.repo exists: skipping repo init | |
else | |
cd ${SYSTEM}; repo init -u git://github.com/CyanogenMod/android.git -b ics | |
endif | |
curl http://pastebin.com/raw.php?i=FrFJmVtJ > ${SYSTEM}/.repo/local_manifest.xml | |
## removes old files and allows init to start from scratch | |
it_or_break_it: | |
rm -rf ${BINDIR}/repo ${BINDIR}/adb ${SIGNDIR} ${SYSTEM}/.repo ${SNAPSHOT}/current | |
## fetches vendor-specific files from device and gets some prebuilt CyanogenMod files | |
vendor: | |
ifdef ARCHIVE | |
mkdir -p ${SYSTEM}/vendor/bn/encore/proprietary | |
tar pzxvf ${ARCHIVE} -C ${SYSTEM}/vendor/bn/encore/ | |
cd ${SYSTEM}/device/bn/encore; ./setup-makefiles.sh | |
else | |
cd ${SYSTEM}/device/bn/encore; ./extract-files.sh | |
endif | |
cd ${SYSTEM}/vendor/cm; ./get-prebuilts | |
## updates to the latest source code | |
sync: | |
ifdef J | |
cd ${SYSTEM}; repo sync -j${J} | |
else | |
cd ${SYSTEM}; repo sync -j16 | |
endif | |
ifneq ($(wildcard ${SYSTEM}/external/mesa3d/src/glsl/linker.cpp),) | |
if ! grep -q "<stddef.h>" ${SYSTEM}/external/mesa3d/src/glsl/linker.cpp; then \ | |
sed -i '1i #include <stddef.h>' ${SYSTEM}/external/mesa3d/src/glsl/linker.cpp; \ | |
fi | |
endif | |
## builds the project | |
build: | |
ifdef J | |
USE_CCACHE=${USE_CCACHE} bash -c 'cd ${SYSTEM}; . build/envsetup.sh; lunch cm_encore-userdebug; schedtool -B -n 1 -e ionice -n 1 make -j${J}' | |
else | |
USE_CCACHE=${USE_CCACHE} bash -c 'cd ${SYSTEM}; . build/envsetup.sh; lunch cm_encore-userdebug; mka' | |
endif | |
cd ${OUTDIR}; ./ramdisk_tools.sh | |
## makes bacon ;) | |
bacon: | |
ifdef J | |
USE_CCACHE=${USE_CCACHE} bash -c 'cd ${SYSTEM}; . build/envsetup.sh; lunch cm_encore-userdebug; schedtool -B -n 1 -e ionice -n 1 make bacon -j${J}' | |
else | |
USE_CCACHE=${USE_CCACHE} bash -c 'cd ${SYSTEM}; . build/envsetup.sh; lunch cm_encore-userdebug; mka bacon' | |
endif | |
rm -f update-cm-9.0.0-RC0-NookColor-KANG-signed.zip | |
ln ${OUTDIR}/update-cm-9.0.0-RC0-NookColor-KANG-signed.zip ./ | |
## makes a snapshot of the binaries | |
snapshot: rsync | |
rsync -av ${OUTDIR}/kernel ${SNAPSHOT}/current/kernel | |
rsync -av ${OUTDIR}/ramdisk-internal.img ${SNAPSHOT}/current/ramdisk.img | |
rsync -av --delete --force ${OUTDIR}/system/ ${SNAPSHOT}/current/system/ | |
cp -rl ${SNAPSHOT}/current ${SNAPSHOT}/${SERIES}-${NOW} | |
## removes packaging intermediates | |
clean: | |
rm -rf ${SNAPSHOT}/update-*-unsigned.zip ${SNAPSHOT}/update-*-signed.zip ${SNAPSHOT}/update | |
## removes all packages and snapshots | |
purge: | |
rm -rf ${SNAPSHOT}/update-* ${SNAPSHOT}/update ${SNAPSHOT}/current/kernel ${SNAPSHOT}/current/ramdisk.img ${SNAPSHOT}/current/system | |
## prepares a package | |
package: zip | |
ifndef NAME | |
$(eval NAME := ${SERIES}-${NOW}) | |
endif | |
rm -rf ${SNAPSHOT}/update | |
rm -f ${NAME}-unsigned.zip ${NAME}.zip ${SNAPSHOT}/update | |
cp -rl ${SNAPSHOT}/current ${SNAPSHOT}/update | |
find ${SNAPSHOT}/update -type l -exec rm -f {} \; | |
cd ${SNAPSHOT}/update; zip -r9 ../${NAME}-unsigned.zip . | |
rm -rf ${SNAPSHOT}/update | |
ifdef SIGN | |
rm ${SNAPSHOT}/${NAME}-signed.zip | |
java -jar ${BIN_SIGNAPK} ${KEY_SYSTEM_PEM} ${KEY_SYSTEM_PK8} \ | |
${SNAPSHOT}/${NAME}-unsigned.zip ${SNAPSHOT}/${NAME}-signed.zip | |
zipalign -fv 4 ${SNAPSHOT}/${NAME}-signed.zip ${SNAPSHOT}/${NAME}.zip | |
else | |
zipalign -fv 4 ${SNAPSHOT}/${NAME}-unsigned.zip ${SNAPSHOT}/${NAME}.zip | |
endif | |
ifdef CLEAN | |
rm -f ${SNAPSHOT}/${NAME}-unsigned.zip ${SNAPSHOT}/${NAME}-signed.zip | |
endif | |
## emits a configuration file containing the currently-active options | |
config: | |
echo HOME := ${HOME} > config.mk | |
echo WORKDIR := ${WORKDIR} >> config.mk | |
echo BINDIR := ${BINDIR} >> config.mk | |
echo SNAPSHOT := ${SNAPSHOT} >> config.mk | |
echo SIGNDIR := ${SIGNDIR} >> config.mk | |
echo BIN_SIGNAPK := ${BIN_SIGNAPK} >> config.mk | |
echo KEY_SYSTEM_PEM := ${KEY_SYSTEM_PEM} >> config.mk | |
echo KEY_SYSTEM_PK8 := ${KEY_SYSTEM_PK8} >> config.mk | |
echo SERIES := ${SERIES} >> config.mk | |
echo USE_CCACHE := ${USE_CCACHE} >> config.mk | |
## emits a configuration file conforming to the ~/bin and ~/android "standard" | |
commonconfig: | |
echo HOME := ${USER_HOME} > config.mk | |
echo WORKDIR := ${USER_HOME}/android >> config.mk | |
echo BINDIR := ${USER_HOME}/bin >> config.mk | |
## makes sure programs exist | |
rsync: | |
@which rsync > /dev/null | |
zip: | |
@which zip > /dev/null |
So, you prefer antfiles?
UGH. >.>
You should git repo this instead of gisting this
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ugh.