[Galaxy S II General] jackq:
I searched and reading a lot but can't find properly guide how to use miui patchrom for jellybean roms. So i decided share what i've found and put all in one guide.

1. First of all you need linux on your machine. I use kubuntu, installed from windows (wubi) ->http://www.kubuntu.org/getkubuntu/download

2. Now you need SDK tools for linux http://developer.android.com/sdk/index.html

-download and unzip it to for egz home/your_username/android-sdk-linux

-set PATH for tools and platform-tools folders

export PATH=/home/your_username/android-sdk-linux/platform-tools:/home/your_username/android-sdk-linux/tools:$PATH

On x64 systems you are required to install some 32-bit libraries so in a terminal write:

sudo apt-get install ia32-libs

3. Download ROM which you want to patch with miui patchrom, must be deodexed and rooted. For us it must be jellybean ROM for egz 4.1.2. I suggest to use CM or AOSP based roms because stock sammy roms have a lot of differences and it's not so easy to port them. After downloading your ROM base rename it to something short and easy i use stock.zip.

In home create folder i use patchrom folder in this folder create for egz stock folder and put downloaded rom to it.

4. Download from MiCode github all necessary files https://github.com/MiCode we need:

https://github.com/MiCode/patchrom_tools/archive/jellybean.zip tools

https://github.com/MiCode/patchrom_miui/archive/jellybean.zip miui

https://github.com/MiCode/patchrom_i9100/archive/jellybean.zip i9100

https://github.com/MiCode/patchrom_build/archive/jellybean.zip build

https://github.com/MiCode/patchrom_android/archive/jellybean.zip android

all zips for jellybean, why downloading zips? because for me repo don't download all files, that way is much easiest.

Unzip all files to your stock folder which you create in step 3. Rename all folders by this way patchrom_tools_jellybean becomes tools, patchrom_miui_jellybean becomes miui ...

5. In i9100 folder you can find makefile its first of configuring files which you need to copy to stock folder and edit it.

This is my makefile, you should edit using this explanations:

'local-zip-file' = Name of your original ROM zip

'local-out-zip-file' = Name for your finished MIUI rom

'local-modified-apps' = Apps that will be modified to fit in with the framework. They need to be modified because they contact with the system

'local-miui-apps' = MIUI Apps that will be integrated into the zip

'local-remove-apps' = Apps that will be removed from the original ROM

'local-pre-zip' = Refers to codeblock that should be executed before the zip is done.

'local-after-zip' = Refers to codeblock executed after the zip is completed

'local-zip-misc' = The codeblock just described at 'local-pre-zip'. It adds some Google Apps and a buid.prop

'local-test' = Another codeblock

#
# Makefile for i9100
#
PORT_BUILD=/home/jack/patchrom/build

PORT_ROOT=/home/jack/patchrom

# The original zip file, MUST be specified by each product
local-zip-file := stock.zip

# The output zip file of MIUI rom, the default is porting_miui.zip if not specified
local-out-zip-file := MIUI_i9100.zip

# the location for local-ota to save target-file
local-previous-target-dir := ~/workspace/ota_base/i9100_4.1

# All apps from original ZIP, but has smali files chanded
local-modified-apps := LogsProvider Phone MediaProvider Settings

local-modified-jars :=

# All apks from MIUI
local-miui-removed-apps := MediaProvider Stk

local-miui-modified-apps := MiuiHome Settings Phone Mms ThemeManager MiuiSystemUI

# Config density for co-developers to use the aaps with HDPI or XHDPI resource,
# Default configrations are HDPI for ics branch and XHDPI for jellybean branch
local-density := HDPI

include phoneapps.mk

# To include the local targets before and after zip the final ZIP file,
# and the local-targets should:
# (1) be defined after including porting.mk if using any global variable(see porting.mk)
# (2) the name should be leaded with local- to prevent any conflict with global targets
local-pre-zip := local-pre-zip-misc
local-after-zip:= local-put-to-phone

# The local targets after the zip file is generated, could include 'zip2sd' to
# deliver the zip file to phone, or to customize other actions

include $(PORT_BUILD)/porting.mk

# To define any local-target
updater := $(ZIP_DIR)/META-INF/com/google/android/updater-script
pre_install_data_packages := $(TMP_DIR)/pre_install_apk_pkgname.txt
local-pre-zip-misc:
cp other/spn-conf.xml $(ZIP_DIR)/system/etc/spn-conf.xml
cp other/build.prop $(ZIP_DIR)/system/build.prop
#cp stockrom/system/app/FFFFFFFF000000000000000000000001.drbin $(ZIP_DIR)/system/app
#cp -r stockrom/system/app/mcRegistry $(ZIP_DIR)/system/app
rm -rf $(ZIP_DIR)/system/csc
rm -rf $(pre_install_data_packages)
for apk in $(ZIP_DIR)/data/media/preinstall_apps/*.apk; do\
$(AAPT) d --values resources $$apk | grep 'id=127 packageCount' | sed -e "s/^.*name=//" >> $(pre_install_data_packages);\
done
more $(pre_install_data_packages) | wc -l > $(ZIP_DIR)/system/etc/enforcecopyinglibpackages.txt
more $(pre_install_data_packages) >> $(ZIP_DIR)/system/etc/enforcecopyinglibpackages.txt

out/framework2.jar : out/framework.jar

%.phone : out/%.jar
[MENTION=279333]ECHO[/MENTION] push -- to --- phone
adb remount
adb push $< /system/framework
adb shell chmod 644 /system/framework/$*.jar
#adb shell stop
#adb shell start
#adb reboot

%.sign-plat : out/%
#%.sign-plat : /home/gexudong/libra.jbmiui/out/target/product/maguro/system/app/%
java -jar $(TOOL_DIR)/signapk.jar $(PORT_ROOT)/build/security/platform.x509.pem $(PORT_ROOT)/build/security/platform.pk8 $< $<.signed
[MENTION=279333]ECHO[/MENTION] push -- to --- phone
adb remount
adb push $<.signed /system/app/$*
adb shell chmod 644 /system/app/$*

So, you have to change:

local-zip-file := stock.zip name of your base rom

PORT_BUILD=/home/jack/patchrom/build to your patch for build folder

PORT_ROOT=/home/jack/patchrom to your root folder

After edit in makefile and save it in patchrom/stock folder you sholud copy from patchrom/build folder these files: porting.mk and phoneapps.mk

you can edit phoneapps.mk too add or delete files which you want.

File structure must look like this:

home

-your_username

-android-sdk-linux:

(-extras

-platform-tools

-platforms

-system-images

-tools)

-patchrom:

(-android

-build

-i9100

-miui

-stock (including: stock.zip - your base rom, makefile edited by you, phoneapps.mk edited by you, porting.mk - copied from build folder)

-tools)

6. Ok, files is prepared, now we can start. Open console and type:

cd patchrom - go to patchrom folder

cd stock - go to stock folder

cd .. - go back

make workspace - this command create temp folder in stock folder, and decompile all necessary files from stock.zip and from miui patchrom, it decompile also files which you add in makefile 'local-modified-apps'

Now in temp you have 5 folders, in reject folder you can resolve any conflicts to prepare necessary files for miui rom.

7. After fixing problems with smali type in console

make firstpatch

this command will apply all rej changes and miui patch for your decompiled files.

8. In console type:

source build/envsetup.sh
cd stock
make zipfile

Thats all.

If you have problems google it ;)

Don't ask me for anything, use your brain! :p