[
  {
    "path": ".gitignore",
    "content": "/build\n/run.conf\n"
  },
  {
    "path": "LOG.txt",
    "content": " ####################################\n  Lanchon REPIT\n  A Data-Sparing Repartitioning Tool\n  Version: 2016-04-06\n  Device: i9100\n  Copyright 2016, Lanchon (GPLv3)\n ####################################\n\n=====  PRELIMINARY CHECKS  =====\ninfo: valid package names: <prefix>[-(system|data|sdcard|preload)=<conf>]...<suffix>\ninfo: valid partition <conf> values: [<size-in-GiB>|same|min|max][+[keep|wipe][+[ext4|vfat|f2fs|swap|raw]]]\n\n-----  DEFAULTS  -----\nsystem = size:same + content:keep + fs:ext4\ndata = size:same + content:keep + fs:ext4\nsdcard = size:same + content:keep + fs:vfat\npreload = size:same + content:keep + fs:ext4\n\ninfo: parsing package name\n\n-----  CONFIGURATION  -----\nsystem = size:1.0 + content:keep + fs:ext4\ndata = size:6 + content:keep + fs:ext4\nsdcard = size:max + content:keep + fs:vfat\npreload = size:min + content:wipe + fs:ext4\n\ninfo: disabling swap\ninfo: unmounting all partitions\ninfo: rereading partition table\n\n=====  PREPARATION  =====\ninfo: determining usable sector range of block device\ninfo: checking existing partitions\n#####  processing heap 'main'\ninfo: checking existing partition layout\ninfo: current size: partition #9 'system' (FACTORYFS): 768 MiB\ninfo: current size: partition #10 'data' (DATAFS): 512 MiB\ninfo: current size: partition #11 'sdcard' (UMS): 13064 MiB\ninfo: current size: partition #12 'preload' (HIDDEN): 512 MiB\ninfo: checking new partition layout\ninfo: new size: partition #9 'system' (FACTORYFS): 1024 MiB\ninfo: new size: partition #10 'data' (DATAFS): 6144 MiB\ninfo: new size: partition #11 'sdcard' (UMS): 7680 MiB\ninfo: new size: partition #12 'preload' (HIDDEN): 8 MiB\n\n=====  DRY-RUN  =====\n#####  processing heap 'main'\n-----  analyzing partition #9 'system' (FACTORYFS)\ninfo: partition #9 'system' (FACTORYFS) will expand into storage area currently used by partition #10 'data' (DATAFS)\ninfo: deferring processing of partition #9 'system' (FACTORYFS) until required space is freed\n-----  analyzing partition #10 'data' (DATAFS)\ninfo: partition #10 'data' (DATAFS) will expand into storage area currently used by partition #11 'sdcard' (UMS)\ninfo: deferring processing of partition #10 'data' (DATAFS) until required space is freed\n-----  analyzing partition #11 'sdcard' (UMS)\ninfo: partition #11 'sdcard' (UMS) will expand into storage area currently used by partition #12 'preload' (HIDDEN)\ninfo: deferring processing of partition #11 'sdcard' (UMS) until required space is freed\n-----  analyzing partition #12 'preload' (HIDDEN)\n*****  processing partition #12 'preload' (HIDDEN)\ninfo: will format the partition in ext4 and trim it\n*****  processing partition #11 'sdcard' (UMS)\ninfo: will move/resize the vfat partition\ninfo: checking the file system\nfsck.fat 3.0.28 (2015-05-16)\n/dev/block/mmcblk0p11: 62 files, 286825/3337853 clusters\n*****  processing partition #10 'data' (DATAFS)\ninfo: will move the ext4 partition\nWARNING: moving a big ext4 partition can take a very long time; it requires copying the complete partition, including its free space\ninfo: will resize the ext4 partition\ninfo: checking and trimming the file system\n/dev/block/mmcblk0p10: 797/32768 files (10.7% non-contiguous), 90304/131068 blocks\n*****  processing partition #9 'system' (FACTORYFS)\ninfo: will resize the ext4 partition\ninfo: checking and trimming the file system\nsystem: 1833/49152 files (0.0% non-contiguous), 117150/196608 blocks\n\n=====  EXECUTION  =====\n#####  processing heap 'main'\n-----  analyzing partition #9 'system' (FACTORYFS)\ninfo: partition #9 'system' (FACTORYFS) will expand into storage area currently used by partition #10 'data' (DATAFS)\ninfo: deferring processing of partition #9 'system' (FACTORYFS) until required space is freed\n-----  analyzing partition #10 'data' (DATAFS)\ninfo: partition #10 'data' (DATAFS) will expand into storage area currently used by partition #11 'sdcard' (UMS)\ninfo: deferring processing of partition #10 'data' (DATAFS) until required space is freed\n-----  analyzing partition #11 'sdcard' (UMS)\ninfo: partition #11 'sdcard' (UMS) will expand into storage area currently used by partition #12 'preload' (HIDDEN)\ninfo: deferring processing of partition #11 'sdcard' (UMS) until required space is freed\n-----  analyzing partition #12 'preload' (HIDDEN)\n*****  processing partition #12 'preload' (HIDDEN)\ninfo: deleting current partition\ninfo: creating new partition\ninfo: naming the partition\ninfo: rereading partition table\ninfo: formatting the partition in ext4 and trimming it\n\nWarning: the fs_type small is not defined in mke2fs.conf\n\n*****  processing partition #11 'sdcard' (UMS)\ninfo: moving/resizing the vfat partition\ninfo: note that the error 'unable to satisfy all constraints on the partition' usually means that the new desired partition size would be too small to hold the files already stored in the partition.\ninfo: rereading partition table\ninfo: checking the file system\nfsck.fat 3.0.28 (2015-05-16)\n/dev/block/mmcblk0p11: 62 files, 286825/1962238 clusters\n*****  processing partition #10 'data' (DATAFS)\ninfo: moving the ext4 partition\ninfo: ensure that the destination partition can be created before starting the move\ninfo: deleting current partition\ninfo: creating new partition\ninfo: naming the partition\ninfo: rereading partition table\ninfo: deleting the partition to workaround dd's 4 GiB wraparound bug\ninfo: moving data towards the end of the disk\n\n-----  moving 256 MiB chunk: 1192 MiB -> 1448 MiB\ninfo: creating a temporary partition to read chunk at device offset 1192 MiB\ninfo: rereading partition table\ninfo: reading data\n524288+0 records in\n524288+0 records out\n268435456 bytes (256.0MB) copied, 6.977768 seconds, 36.7MB/s\ninfo: deleting the temporary partition\ninfo: creating a temporary partition to write chunk at device offset 1448 MiB\ninfo: rereading partition table\ninfo: writing data\n524288+0 records in\n524288+0 records out\n268435456 bytes (256.0MB) copied, 136.736488 seconds, 1.9MB/s\ninfo: deleting the temporary partition\n\n-----  moving 256 MiB chunk: 936 MiB -> 1192 MiB\ninfo: creating a temporary partition to read chunk at device offset 936 MiB\ninfo: rereading partition table\ninfo: reading data\n524288+0 records in\n524288+0 records out\n268435456 bytes (256.0MB) copied, 7.215978 seconds, 35.5MB/s\ninfo: deleting the temporary partition\ninfo: creating a temporary partition to write chunk at device offset 1192 MiB\ninfo: rereading partition table\ninfo: writing data\n524288+0 records in\n524288+0 records out\n268435456 bytes (256.0MB) copied, 134.066894 seconds, 1.9MB/s\ninfo: deleting the temporary partition\n\ninfo: creating the final partition\ninfo: naming the partition\ninfo: rereading partition table\ninfo: checking and trimming the file system\n/dev/block/mmcblk0p10: 797/32768 files (10.7% non-contiguous), 90304/131068 blocks\ninfo: enlarging the partition entry\ninfo: deleting current partition\ninfo: creating new partition\ninfo: naming the partition\ninfo: rereading partition table\ninfo: creating a temporary partition to wipe the crypto footer due to dd's 4 GiB wraparound bug\ninfo: deleting current partition\ninfo: creating new partition\ninfo: naming the partition\ninfo: rereading partition table\ninfo: wiping the crypto footer\n32+0 records in\n32+0 records out\n16384 bytes (16.0KB) copied, 0.010336 seconds, 1.5MB/s\ninfo: recreating the original partition\ninfo: deleting current partition\ninfo: creating new partition\ninfo: naming the partition\ninfo: rereading partition table\ninfo: enlarging the ext4 file system\nresize2fs 1.42.9 (28-Dec-2013)\nResizing the filesystem on /dev/block/mmcblk0p10 to 1572860 (4k) blocks.\nThe filesystem on /dev/block/mmcblk0p10 is now 1572860 blocks long.\n\ninfo: checking and trimming the file system\n/dev/block/mmcblk0p10: Inode 7, i_size is 1610670080, should be 1610690560.  FIXED.\n/dev/block/mmcblk0p10: 797/393216 files (10.7% non-contiguous), 114845/1572860 blocks\ninfo: file system errors in partition #10 'data' (DATAFS) were fixed\n*****  processing partition #9 'system' (FACTORYFS)\ninfo: enlarging the partition entry\ninfo: deleting current partition\ninfo: creating new partition\ninfo: naming the partition\ninfo: rereading partition table\ninfo: enlarging the ext4 file system\nresize2fs 1.42.9 (28-Dec-2013)\nResizing the filesystem on /dev/block/mmcblk0p9 to 262144 (4k) blocks.\nThe filesystem on /dev/block/mmcblk0p9 is now 262144 blocks long.\n\ninfo: checking and trimming the file system\nsystem: 1833/65536 files (0.0% non-contiguous), 118211/262144 blocks\ninfo: flushing buffers\n\n=====  SUCCESS  =====\n\n[OK]\n"
  },
  {
    "path": "README-CHEF-KOCH.md",
    "content": "## The CHEF-KOCH Incident (And XDA's Response)\n\nthe following information remains online because, to this date, CHEF-KOCH has not publicly acknowledged his act\nof plagiarism. our latest exchange can be found [here](https://github.com/Lanchon/REPIT/issues/37).\n\n<br>\n\n> **AND WHAT IS THIS?**\n>\n> what follows is text originally posted by me on XDA. the strange incident that was the subject of this post was\ninvestigated by moderators from both of the involved sites and found to be as i described it. as a result, proper\ncorrective measures were implemented.\n>\n> unfortunately this post was later surreptitiously deleted by XDA moderator\n[The_Merovingian](http://forum.xda-developers.com/member.php?u=5302753), an action that precipitated my departure\nfrom the XDA community as a developer. i no longer consider XDA a viable medium for hosting my work.\n>\n> the post is now reproduced here for record keeping in the form in which it was when it was deleted from XDA by\nThe_Merovingian on February 23, 2016.\n\n> **UPDATE:** as a sort of retaliation for my moving REPIT out of XDA, The_Merovingian closed down\n[the REPIT thread](http://forum.xda-developers.com/galaxy-s2/orig-development/tool-lanchon-repit-data-sparing-t3311747)\n([via Wayback Machine](https://web.archive.org/web/20160226151111/http://forum.xda-developers.com/galaxy-s2/orig-development/tool-lanchon-repit-data-sparing-t3311747)).\nthis was unfortunate because the thread got 30 pages of posts in its 2 weeks of existence, and probably was\nthe second most active thread in the S2 forum. all this traffic then went on to spam the official i9100 CM13 thread,\nalready drowning in off-topic noise; it was a mess.\n>\n> clearly XDA members needed a place to discuss REPIT but XDA did not really care about this. \nThe_Merovingian told me that i needed to \"remove\n[the rant](http://forum.xda-developers.com/galaxy-s2/orig-development/tool-lanchon-repit-data-sparing-t3311747/post65239832)\"\nin order for the thread to be reopened. i reached out to the XDA moderation committee asking for the\nofficial position on whether \"DUE TO IRRECONCILABLE DIFFERENCES\" constituted an unacceptable rant on XDA.\ni am still waiting for a response... :)\n>\n> censorship attempts typically backfire on the internet. what was to be a post on a forum is now inextricably\nlinked to the history of an open source project in its git repo, cloned by anyone needing the tool's tree.\n>\n> After all is said and done, all the trouble caused and the time lost, i have but one personal message\nto The_Merovingian, and it is this: the matrix is a silly franchise.\n\n<br>\n\n_we interrupt your regular programming to bring you this breaking news..._\n\n### _\"CHEF-KOCH\" IS A THIEF !!!_\n\n> **UPDATE:** moderators from both [the german forum](http://www.android-hilfe.de/) and xda collaborated to resolve this\nissue. they were alerted by some forum members who are active in both communities (and again i thank you guys for\nthat, you know who you are). after a swift investigation, and just two days after this silliness started, they\nremoved all offending content from the german site and placed a link to this thread in its place. i am very grateful\nto all the parties that quickly put this issue to rest.\n\n> **2ND UPDATE:** i was told that this guy's account at the german site was terminated; the reasons for this are unknown\nto me. and user [the.gangster](http://forum.xda-developers.com/member.php?u=6560258) was put in charge of the\nrepartition thread there. thank you for taking over!\n\n> **3RD UPDATE:** i privately told the.gangster a few days ago when this guy was banned from the german site that i\nwanted to remove the guy's contact details from this post and let bygones be bygones. unfortunately this guy is\nrelentless: he can no longer post, but still he added text files on his MEGA instead accusing **me** of stealing\nand other nonsense. well, so be it: this info stays online forever, and so do his contact details. i removed the\nfowl language to comply with XDA requirements and the rest stays.\n\n_it is unbelievable!!! this_ [epithet removed] _took my just-published software, removed the license, removed my\nname, removed the copyright, added himself as the author, and republished it in a\n[german forum](http://www.android-hilfe.de/thema/how-to-vergroesserung-der-datenpartition-mittels-bearbeitetem-pit-file-teil-2.751812/)\nas his own work. (here is the same link\n[via Wayback Machine](https://web.archive.org/web/20160213014929/http://www.android-hilfe.de/thema/how-to-vergroesserung-der-datenpartition-mittels-bearbeitetem-pit-file-teil-2.751812/),\nin case the_ [epithet removed] _decides to delete his post.) when i dated one of my zips in its name, he copied\nthat too, except that he rewinded the date by one day. but he forgot to fake the modification time of the files\ninside the zip; and of course the upload date in MEGA is the real one. he also republished the older v0.1 unfinished\nrelease i did to help people in a tight spot with CM13, even though that release **was not free software**. (it was\nspecifically **not** licensed as free software to avoid copies of the unfinished work spreading around; however the\ncurrent version is GPLv3.) he also stole\n[Flashize](http://forum.xda-developers.com/android/software-hacking/tool-flashize-shell-scripts-flashable-t3313605),\nanother tool i published these days._\n\n_the plagiarized files are currently published [here](https://mega.nz/#F!cMNShQLa!5lXzEuluHX9jd9Bv3B_h8Q), but might\nbe removed anytime. a copy of all files was\n[uploaded to post #3](http://forum.xda-developers.com/galaxy-s2/orig-development/tool-lanchon-repit-data-sparing-t3311747/post65239837)_\n[now also surreptitiously deleted from XDA! rehosted [here](https://www.androidfilehost.com/?w=files&flid=50817)]\n_for record keeping._\n\n_i did delete my old published v0.1 files from xda, but fortunately i did not delete some customized versions of\nv0.1 that i produced on request that are still available\n[here](http://forum.xda-developers.com/galaxy-s2/orig-development/tool-lanchon-repit-data-sparing-t3311747/post65252583)\nand [here](http://forum.xda-developers.com/galaxy-s2/orig-development/tool-lanchon-repit-data-sparing-t3311747/post65252738).\nmost importantly, i\n[announced](http://forum.xda-developers.com/galaxy-s2/development-derivatives/rom-cyanogenmod-13-t3223808/post65201096)\nthat i was working on a partitioning tool and 6 hours later\n[published](http://forum.xda-developers.com/galaxy-s2/development-derivatives/rom-cyanogenmod-13-t3223808/post65206132)\nthe full complex log of a working, pre-release version of the application. that was 3 full days before the_\n[epithet removed] _published \"his\" software... lol._\n\n#### _WHO IS THIS \"CHEF-KOCH\"_ [epithet removed] _THIEF ANYWAY ???_\n\n[rant removed.]\n\n_it is very unlikely that this is the only time he has done this, and i can tell you this is very demotivating for\na developer. so protect your developers by helping them expose this clown in case they happen to cross paths with him.\nalso, his clients and/or employers better know what kind of \"work\" this guy does._\n\n_android-hilfe.de: [CHEF-KOCH](http://www.android-hilfe.de/members/chef-koch.97407/)\n<br>xda-developers.com: [CHEF-KOCH](http://forum.xda-developers.com/member.php?u=4415879)\n<br>github.com: [CHEF-KOCH](https://github.com/CHEF-KOCH)\n<br>google.com: [Nvinside@gmail.com](mailto:Nvinside@gmail.com)_\n\n_he has this info on GitHub:\n<br>InfoSec Institute/nVidia EU\n<br>http://www.infosecinstitute.com/\n<br>Lausanne_\n"
  },
  {
    "path": "README.md",
    "content": "## Lanchon REPIT\n### A Device-Only Data-Sparing Repartitioning Tool For Android\n\n#### [CHANGELOG] - [DEVICES] - [DOWNLOADS] - [GALAXY S2] - [XDA THREAD]\n\n[CHANGELOG]:  https://github.com/Lanchon/REPIT/releases\n[DEVICES]:    #device-specific-information\n[DOWNLOADS]:  https://www.androidfilehost.com/?w=files&flid=49911\n[GALAXY S2]:  #the-galaxy-s2-family\n[XDA THREAD]: http://forum.xda-developers.com/android/software-hacking/tool-lanchon-repit-data-sparing-t3358036\n\nPowered by [Flashize](https://github.com/Lanchon/Flashize).\n\n<br>\n\n## General Information (All Devices)\n\n#### WHAT IS THE PROBLEM ?\n\nmany older devices, especially the ones originally released before emulated storage was available, were partitioned by the OEM in ways that hinder the installation and use of newer Android versions. for example, the Galaxy S2 GT-I9100 comes with a 0.5 GiB /system partition that is unable to fit CM 13.0 and Open GApps, even if you choose the pico version. though its flash is typically a generous 16 GiB, the stock /data partition is only 2 GiB which means that with today's ART you run out of space to install applications in no time. it also comes with a 0.5 GiB /preload partition that goes unused on custom ROMs.\n\npeople have typically solved this by repartitioning. on Samsung devices this is a tricky process that involves the use of download mode, a Windows PC, Windows device drivers that support the device's download mode, a 'pirated' proprietary PC software called Odin, the right PIT and other files, and correct configuration. (a free software alternative to Odin called Heimdall works on many devices and is cross platform and supports Linux PCs, but the rest of the hurdles remain.) the procedure has potential for hard-bricking if the wrong files are flashed. after repartitioning, all affected partitions must be reflashed or formatted anew, a procedure that many get wrong. and of course, all data in the affected partitions gets wiped (typically the complete device) making this an ultra-inconvenient affair.\n\n#### WHAT IS REPIT ?\n\nREPIT is a simple, safe, device-only, data-sparing, and easily portable repartitioning tool for Android devices:\n\n- device-only: just flash a zip file in recovery to repartition the device.\n- simple: rename the zip file before flashing to configure your choice of partition sizes, file systems, wipes, etc.\n- safe:\n  - a correctly ported REPIT can never hard-brick your device.\n  - before starting, REPIT checks for the existence of all the tools that will be needed for the task at hand, verifies that the current partition layout passes several sanity checks, checks and fixes all the involved file systems, and verifies that the new partition layout will meet its sanity checks too. REPIT performs a dry-run of the complete repartitioning process to detect possible problems early on.\n  - if REPIT fails, it will nonetheless try to restore your device to a working in-between state. you can solve the blocking issue and REPIT again towards your goal, or otherwise REPIT back to your original configuration. (keeping the in-between state is not recommended as it usually involves 'wasted' unpartitioned space.)\n  - my estimate is that between 500 to 1000 users already used REPIT for 'major' changes on the i9100 and no incidents of data loss were reported. (note: these are very stale numbers dating from March 2016, when REPIT was still in its infancy.)\n- easily portable: a simple configuration file is all that is needed to port REPIT to a new device.\n\nyou can look at [the log of a demo run](https://raw.githubusercontent.com/Lanchon/REPIT/master/LOG.txt) to get a feel for what REPIT can do. in this run on a Galaxy S2 it grows the /system and /data ext4 partitions to 1 and 6 GiB respectively, it wipes and shrinks the unused /preload partition to a minimum size, and it adjusts the size of the internal /sdcard vfat partition to occupy whatever space is left. REPIT plans, orders and undertakes a safe series of partition resize and move operations to reach its goal, all the while keeping and eye on details such as alignments and retaining the data present in the /system, /data and /sdcard partitions.\n\n#### LIMITATIONS\n\n- REPIT **requires TWRP 2 or TWRP 3.** some recoveries unnecessarily hold device or partition locks during flashing, which prevents all repartitioning tools from working (parted, fdisk, gdisk, and of course REPIT). unfortunately the recoveries bundled with CM 11, 12.0, 12.1 and 13.0 display this issue and are incompatible. recent TWRP 2.8.7.* and 3.0.0.* recoveries comply with this requirement, but only when flashing zips from /tmp. (REPIT will automatically copy itself to /tmp if it detects locks, to help you relaunch from there.)\n- REPIT **does not support encrypted phones.**\n- REPIT **will cause data loss** if the repartitioning process is externally interrupted. **plug into a power source!**\n\n#### HOW TO REPIT\n\n1. if you think your data is invaluable then treat it as such: **make a backup!**\n2. get TWRP running on your device.\n3. make sure your battery is mostly charged.\n4. get the zip for your device from the link below.\n5. **rename it to express your desired configuration** (see below).\n6. **PLUG INTO A POWER SOURCE.** this operation might take a long time and **must not be interrupted.**\n7. flash the zip locally on the phone. (if you want to sideload instead, please see the note below.)\n\nfinally, go get a coffee or two. **do not, under any circumstance, interrupt this script !!!**\n\nin case the script fails to start:\n- if the script cannot unmount all partitions, it will copy itself to the /tmp directory and ask you to flash it a second time from there.\n- if it still fails to unmount all partitions, or if it fails to lock the eMMC ('unable to reread the partition table'), then unplug the device from USB hosts such as PCs, reboot TWRP, and reflash the script immediately after boot up. (you may actually need to reflash twice, the second time from '/tmp'.) do not do anything after booting up and before flashing! in particular, **do not connect the device to a PC or USB host** as this might auto-mount the sdcard via MTP, **and do not mount the sdcard as USB mass storage** via TWRP's UI. in some rare cases you might need to use TWRP's UI to disable MTP before rebooting and to manually unmount all partitions before flashing the script from '/tmp'.\n- if locking issues remain, your phone is probably encrypted; this script is not compatible with encrypted phones.\n\nif you want to sideload:\n- sideloading conceals the filename from the device, and thus filename-based configuration will not work.\n- to sideload you need to add a file called 'flashize/repit-settings' to the zip containing the full intended filename, or otherwise just the configuration part of it. for example, a file containing `-system=1G` is enough (the `-` is required). note that your recovery might require you to resign the zip after that change.\n- otherwise you can add the file directly to the device before sideloading, for example via adb push. in that case it must be named '/tmp/repit-settings'.\n\n#### HOW TO CONFIGURE\n\nconfigure the script by renaming the zip file before flashing it.\n\nvalid zip names: `<prefix>[-partition1=<conf>][-partition2=<conf>]...<suffix>`\n\nvalid partition `<conf>` values: `[<size>(G|M)|same|min|max][+[keep|wipe][+[ext4|vfat|f2fs|swap|raw]]]`\n\nthe defaults are device-dependent. please look inside your device's configuration file for more information. for configuration samples please see [the i9100 section](#galaxy-s2-samples) below.\n\n##### Partition Data\n- `keep`: retain the data in the partition. if the partition needs to be moved or resized, this option usually makes the operation significantly slower, even if the partition is mostly empty.\n- `wipe`: wipe the partition. always wipe partitions that are empty or carry data that you do not care about: it will make REPIT faster and will result in less wear on the flash memory.\n\n##### Partition Sizes\n- `same`: do not alter the size of this partition.\n- `min`: make this unused partition a minimum yet formattable size (typically 8 MiB, but device-dependent).\n- `max`: make this partition as big as possible (at most one partition per 'heap' can have its size set to 'max').\n- `<size>(G|M)`: fractional number followed by a size unit expressing the desired partition size. the unit is either `G` for GiB or `M` for MiB. this value gets rounded to the nearest acceptable discreet value. the size granularity is device-dependent, but typically set to match the device-dependent partition alignment (which typically is 1 or 4 MiB).\n\n##### Partition Types\n- `ext4` and `vfat`: these partitions have full move, resize and wipe support.\n- `f2fs`: f2fs partitions can be moved and wiped, and can only be resized while wiping them.\n<br>(tools to resize f2fs file systems do not exist for now.)\n- `swap`: swap partitions can be wiped, and can only be moved or resized while wiping them.\n<br>(it makes no sense to retain their content.)\n- `raw`: raw partitions are treated as opaque blobs and can only be moved.\n<br>(neither resizing nor wiping is supported.)\n\n##### Supported Features\n\n|          | wipe | keep + move       | keep + resize   | keep + move + resize | crypto footer |\n|:--------:|:----:|:-----------------:|:---------------:|:--------------------:|:-------------:|\n| **ext4** | YES  | YES (brute force) | YES (efficient) | YES (brute force)    | YES           |\n| **vfat** | YES  | YES (efficient)   | YES (efficient) | YES (efficient)      | no            |\n| **f2fs** | YES  | YES (brute force) | no              | no                   | YES           |\n| **swap** | YES  | no                | no              | no                   | no            |\n| **raw**  | no   | YES               | no              | no                   | no            |\n\n- **brute force:** the complete partition extent is operated upon.\n- **efficient:** only the stored data within the partition is operated upon.\n- **crypto footer:** support for encryption metadata at the end of the partition.\n\n#### IN CASE OF ISSUES\n\nif there are any problems, **read the log!** you can scroll it on TWRP. most likely it will tell you what is wrong and what to do about it. if not, make sure to somehow record the log. **REPIT logs to file '/tmp/lanchon-repit.log'.** otherwise, you can [obtain a copy of TWRP's log](http://rootzwiki.com/topic/24120-how-to-get-a-log-from-twrp/) (which includes REPIT's log), or if not at least take a picture of it with your camera. in TWRP 2.8.7.* you can see a full screen log by hitting the back button once, then the center button at the bottom of the screen that looks like a TV screen. after recording the log, you can try reflashing the script if you understand what happened and flashing it again makes sense.\n\n**PLEASE NOTE:** your _'did not work'_ report is useless unless you post info from your log.\n\n<br>\n\n## Device-Specific Information\n\neach supported device has a unique targeted build of REPIT in the [download](https://www.androidfilehost.com/?w=files&flid=49911) section. you can also find device-specific information in the [device tree](https://github.com/Lanchon/REPIT/tree/master/device); try searching by device codename using Github's [find file](https://github.com/Lanchon/REPIT/find/master/device). all configuration options for a specific device are defined in the corresponding `<device-codename>.sh` file and the `common.sh` files that might exist in the same directory and in directories above it. you might also find device-specific readme files with relevant information.\n\n#### IF YOUR DEVICE IS NOT SUPPORTED\n\nso your device is unsupported, tough luck... but porting REPIT to a new device is an easy job; you can either do it yourself or request that i do it for you. to request a new port, please [follow this steps](https://github.com/Lanchon/REPIT/blob/master/device-dump/README.md); port requests are welcome. if you want to get your hands dirty, check the configuration files for i9100 ([1](https://github.com/Lanchon/REPIT/blob/master/device/galaxy-s2/exynos-4210/i9100.sh), [2](https://github.com/Lanchon/REPIT/blob/master/device/galaxy-s2/common.sh)), they are the most complete and commented. but usually you can get away with much less, take a look at [i9300](https://github.com/Lanchon/REPIT/blob/master/device/i9300.sh). for an example of how to handle out-of-order partitions, check out [janice](https://github.com/Lanchon/REPIT/blob/master/device/janice.sh).\n\n<br>\n\n## The Galaxy S2 Family\n\nREPIT started its life as i9100-only tool and it inherits this doc section from the good old days.\n\n> **IMPORTANT NOTE:** this script will not work if your phone is encrypted. you need to decrypt your phone first. this was found and reported by XDA user **jer194** [here](http://forum.xda-developers.com/galaxy-s2/orig-development/tool-lanchon-repit-data-sparing-t3311747/post65307128). if you run the script on an encrypted phone anyway, no damage will come: it will just refuse to start, complaining that it cannot reread the partition table.\n\n#### IF... your stock-partitioned device cannot flash gapps after updating to CM 13.0\n\ndownload and flash the file as it is. it will get most space from the unused /preload partition and only 8 MiB for the internal sdcard, and then make /system 1 GiB in size. it will keep you current /data size constant, whatever it is. it will retain all data except data in /preload, which is unused in custom roms (but some multi-boot setups use it).\n\n#### IF... your device is usable\n\nyou can nonetheless use this script to do general repartitioning, file system fixing, wiping, and/or file system type changes. download the script, rename it to express your desired configuration (see below), and then flash it.\n\n#### Galaxy S2 HOW TO\n\nfirst get [official TWRP](https://twrp.me/samsung/samsunggalaxys2i9100.html) running on your device, then follow the generic how-to.\n\nvalid zip names: `<prefix>[-system=<conf>][-data=<conf>][-sdcard=<conf>][-preload=<conf>]<suffix>`\n\nfor this device, partition alignment is 4 MiB and partition sizes get rounded to the nearest 4 MiB boundary. (it is typical for all devices to use the same value for partition alignment and granularity.)\n\n##### Galaxy S2 Defaults\n- `-system=same+keep+ext4`\n- `-data=same+keep+ext4`\n- `-sdcard=same+keep+vfat` <-- note `vfat` here\n- `-preload=same+keep+ext4`\n\n##### Galaxy S2 Samples\n- repartition to stock, wiping preload (in case you used a very small preload before):\n  <br>(**note:** in general it is not recommended to resize file systems by large factors.)\n  <br>`lanchon-repit-XXXXXXXX-system=0.5G-data=2G-sdcard=max-preload=0.5G+wipe-i9100.zip`\n- repartition to stock (without wiping preload):\n  <br>`-system=0.5G-data=2G-sdcard=max-preload=0.5G`\n- wipe data:\n  <br>`-data=+wipe`\n- wipe/change internal sdcard to ext4 (not recommended):\n  <br>`-sdcard=+wipe+ext4`\n- **repartition to 1 GiB system, 6 GiB data, no preload...**\n  - ...keeping all other data:\n    <br>`-system=1G-data=6G-sdcard=max-preload=min+wipe`\n  - ...keeping all other data, **for phones with ext4-formatted internal sdcard:**\n    <br>`-system=1G-data=6G-sdcard=max++ext4-preload=min+wipe`\n  - ...keeping system and sdcard but **WIPING DATA:**\n    <br>(**note:** wiping data is much faster than moving it around if system is being resized and data is large.)\n    <br>`-system=1G-data=6G+wipe-sdcard=max-preload=min+wipe`\n\n<br>\n\n## Disclaimer\n\ni believe this software to be very safe and i exercised it a lot before posting it. but i accept no responsibility if your data is lost or your device is bricked.\n\n<br>\n\n-----\n\nfor historical information regarding the CHEF-KOCH incident (and XDA's response), please follow [this link](https://github.com/Lanchon/REPIT/blob/master/README-CHEF-KOCH.md).\n"
  },
  {
    "path": "_config.yml",
    "content": "theme: jekyll-theme-cayman"
  },
  {
    "path": "device/.disabled/falcon/falcon_UNTESTED.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### falcon (non-GPE versions)\n\n# Disk /dev/block/mmcblk0: 15269888 sectors, 7.3 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20\n# Partition table holds up to 36 entries\n# First usable sector is 34, last usable sector is 15269854\n# Total free space is 72203 sectors (35.3 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1             256          131327   64.0 MiB    0700  modem\n#    2          131328          132351   512.0 KiB   FFFF  sbl1\n#    3          132352          132415   32.0 KiB    FFFF  DDR\n#    4          132608          133631   512.0 KiB   FFFF  aboot\n#    5          135608          136007   200.0 KiB   FFFF  rpm\n#    6          136608          137407   400.0 KiB   FFFF  tz\n#    7          137608          137671   32.0 KiB    FFFF  sdi\n#    8          137672          138695   512.0 KiB   FFFF  utags\n#    9          138696          142791   2.0 MiB     FFFF  logs\n#   10          142792          147455   2.3 MiB     0700  padA\n#   11          147456          148479   512.0 KiB   FFFF  abootBackup\n#   12          150456          150855   200.0 KiB   FFFF  rpmBackup\n#   13          151456          152255   400.0 KiB   FFFF  tzBackup\n#   14          152456          152519   32.0 KiB    0700  sdiBackup\n#   15          152520          153543   512.0 KiB   FFFF  utagsBackup\n#   16          153544          155647   1.0 MiB     0700  padB\n#   17          155648          158719   1.5 MiB     FFFF  modemst1\n#   18          158720          161791   1.5 MiB     FFFF  modemst2\n#   19          161792          162815   512.0 KiB   FFFF  hob\n#   20          162816          162831   8.0 KiB     FFFF  dhob\n#   21          163072          166143   1.5 MiB     FFFF  fsg\n#   22          166144          166145   1024 bytes  FFFF  fsc\n#   23          166146          166161   8.0 KiB     FFFF  ssd\n#   24          166162          168209   1024.0 KiB  FFFF  sp\n#   25          168210          168465   128.0 KiB   FFFF  cid\n#   26          168466          174609   3.0 MiB     FFFF  pds\n#   27          174610          182801   4.0 MiB     FFFF  logo\n#   28          182802          190993   4.0 MiB     FFFF  clogo\n#   29          191232          207615   8.0 MiB     0700  persist\n#   30          207616          208639   512.0 KiB   FFFF  misc\n#   31          208640          229119   10.0 MiB    FFFF  boot\n#   32          229120          249599   10.0 MiB    FFFF  recovery\n#   33          249600         1605631   662.1 MiB   0700  cache\n#   34         1605632         3604479   976.0 MiB   0700  system\n#   35         3604480         3620863   8.0 MiB     FFFF  kpan\n#   36         3620864        15204095   5.5 GiB     0700  userdata\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\n#device_makeFilenameConfig=\"cache=32M+wipe-system=same-data=max+wipe\"\ndevice_makeFilenameConfig=\"cache=32M+wipe-system=same-data=max++ext4\"\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:falcon:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/msm_sdcc.1/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the crypto footer size:\n    local footerSize=$(( 16384 / sectorSize ))\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition   33  cache       cache           \"same keep ext4\"    0\n    initPartition   34  system      system          \"same keep ext4\"    0\n    initPartition   35  kpan        kpan            \"same keep raw\"     0\n    initPartition   36  userdata    data            \"same keep f2fs\"    $footerSize\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"33 34 36\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=36\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    heapAlignment=$(( 4 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"$(seq 33 36)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=$(parOldEnd 32)       # one past the end of a specific partition\n    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n\n}\n"
  },
  {
    "path": "device/.disabled/falcon/falcon_gpe_UNTESTED.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### falcon_gpe (GPE version)\n\n# Disk /dev/block/mmcblk0: 30777344 sectors, 14.7 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20\n# Partition table holds up to 37 entries\n# First usable sector is 34, last usable sector is 30777310\n# Total free space is 72203 sectors (35.3 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1             256          131327   64.0 MiB    0700  modem\n#    2          131328          132351   512.0 KiB   FFFF  sbl1\n#    3          132352          132415   32.0 KiB    FFFF  DDR\n#    4          132608          133631   512.0 KiB   FFFF  aboot\n#    5          135608          136007   200.0 KiB   FFFF  rpm\n#    6          136608          137407   400.0 KiB   FFFF  tz\n#    7          137608          137671   32.0 KiB    FFFF  sdi\n#    8          137672          138695   512.0 KiB   FFFF  utags\n#    9          138696          142791   2.0 MiB     FFFF  logs\n#   10          142792          147455   2.3 MiB     0700  metadata\n#   11          147456          148479   512.0 KiB   FFFF  abootBackup\n#   12          150456          150855   200.0 KiB   FFFF  rpmBackup\n#   13          151456          152255   400.0 KiB   FFFF  tzBackup\n#   14          152456          152519   32.0 KiB    0700  sdiBackup\n#   15          152520          153543   512.0 KiB   FFFF  utagsBackup\n#   16          153544          155647   1.0 MiB     0700  padB\n#   17          155648          158719   1.5 MiB     FFFF  modemst1\n#   18          158720          161791   1.5 MiB     FFFF  modemst2\n#   19          161792          162815   512.0 KiB   FFFF  hob\n#   20          162816          162831   8.0 KiB     FFFF  dhob\n#   21          163072          166143   1.5 MiB     FFFF  fsg\n#   22          166144          166145   1024 bytes  FFFF  fsc\n#   23          166146          166161   8.0 KiB     FFFF  ssd\n#   24          166162          168209   1024.0 KiB  FFFF  sp\n#   25          168210          168465   128.0 KiB   FFFF  cid\n#   26          168466          174609   3.0 MiB     FFFF  pds\n#   27          174610          182801   4.0 MiB     FFFF  logo\n#   28          182802          190993   4.0 MiB     FFFF  clogo\n#   29          191232          207615   8.0 MiB     0700  persist\n#   30          207616          208639   512.0 KiB   FFFF  misc\n#   31          208640          229119   10.0 MiB    FFFF  boot\n#   32          229120          249599   10.0 MiB    FFFF  recovery\n#   33          249600          262143   6.1 MiB     0700  padC\n#   34          262144         1409023   560.0 MiB   0700  cache\n#   35         1409024         3129343   840.0 MiB   0700  system\n#   36         3129344         3145727   8.0 MiB     FFFF  kpan\n#   37         3145728        30711551   13.1 GiB    0700  userdata\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\n#device_makeFilenameConfig=\"cache=32M+wipe-system=same-data=max\"\n#device_makeFilenameConfig=\"cache=32M+wipe-system=976M-data=max\"\n\ndevice_makeFilenameConfig=\"cache=424M+wipe-system=976M-data=same\"\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:falcon:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/msm_sdcc.1/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition   34  cache       cache           \"same keep ext4\"    0\n    initPartition   35  system      system          \"same keep ext4\"    0\n    initPartition   36  kpan        kpan            \"same keep raw\"     0\n    initPartition   37  userdata    data            \"same keep ext4\"    0\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"34 35 37\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=37\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    heapAlignment=$(( 4 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"$(seq 34 37)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=$(parOldEnd 33)       # one past the end of a specific partition\n    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n\n}\n"
  },
  {
    "path": "device/.disabled/galaxy-s4-mini/serrano3gxx_UNTESTED.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### serrano3gxx\n\n# This port was possible thanks to the invaluable help of vaedasti.\n\n# Disk /dev/block/mmcblk0: 15269888 sectors, 7.3 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20\n# Partition table holds up to 128 entries\n# First usable sector is 34, last usable sector is 15269854\n# Total free space is 8158 sectors (4.0 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1            8192          131071   60.0 MiB    0700  modem\n#    2          131072          131327   128.0 KiB   FFFF  sbl1\n#    3          131328          131839   256.0 KiB   FFFF  sbl2\n#    4          131840          132863   512.0 KiB   FFFF  sbl3\n#    5          132864          136959   2.0 MiB     FFFF  aboot\n#    6          136960          137983   512.0 KiB   FFFF  rpm\n#    7          137984          139007   512.0 KiB   FFFF  tz\n#    8          139008          164607   12.5 MiB    FFFF  pad\n#    9          164608          180991   8.0 MiB     8300  param\n#   10          180992          208895   13.6 MiB    8300  efs\n#   11          208896          215039   3.0 MiB     FFFF  modemst1\n#   12          215040          221183   3.0 MiB     FFFF  modemst2\n#   13          221184          241663   10.0 MiB    FFFF  boot\n#   14          241664          262143   10.0 MiB    FFFF  recovery\n#   15          262144          282623   10.0 MiB    FFFF  fota\n#   16          282624          296943   7.0 MiB     8300  backup\n#   17          296944          303087   3.0 MiB     FFFF  fsg\n#   18          303088          303103   8.0 KiB     FFFF  ssd\n#   19          303104          319487   8.0 MiB     8300  persist\n#   20          319488          344063   12.0 MiB    8300  persdata\n#   21          344064         3416063   1.5 GiB     8300  system\n#   22         3416064         3825663   200.0 MiB   8300  cache\n#   23         3825664         4030463   100.0 MiB   8300  hidden\n#   24         4030464        15269854   5.4 GiB     8300  userdata\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\ndevice_makeFilenameConfig=\"system=1G-cache=32M+wipe-preload=min+wipe-data=max\"\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:serrano3g:*) ;;\n        *:serrano3gxx:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/platform/msm_sdcc.1/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the crypto footer size:\n    local footerSize=$(( 16384 / sectorSize ))\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition   21  system      system          \"same keep ext4\"    0\n    initPartition   22  cache       cache           \"same keep ext4\"    0\n    initPartition   23  hidden      preload         \"same keep ext4\"    0\n    initPartition   24  userdata    data            \"same keep ext4\"    $footerSize\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"$(seq 21 24)\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=24\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    heapAlignment=$(( 1 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"$(seq 21 24)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=$(parOldEnd 20)       # one past the end of a specific partition\n    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n\n}\n"
  },
  {
    "path": "device/.disabled/galaxy-s5/common.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### galaxy-s5\n\n# This port was possible thanks to the invaluable help of wecip.\n\n# Disk /dev/block/mmcblk0: 30777344 sectors, 14.7 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20\n# Partition table holds up to 128 entries\n# First usable sector is 34, last usable sector is 30777310\n# Total free space is 8158 sectors (4.0 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1            8192           38911   15.0 MiB    8300  apnhlos\n#    2           38912          156543   57.4 MiB    0700  modem\n#    3          156544          157567   512.0 KiB   FFFF  sbl1\n#    4          157568          157695   64.0 KiB    FFFF  dbi\n#    5          157696          157759   32.0 KiB    FFFF  ddr\n#    6          157760          161855   2.0 MiB     FFFF  aboot\n#    7          161856          162879   512.0 KiB   FFFF  rpm\n#    8          162880          163903   512.0 KiB   FFFF  tz\n#    9          163904          170047   3.0 MiB     FFFF  fsg\n#   10          170048          184319   7.0 MiB     FFFF  pad\n#   11          184320          204799   10.0 MiB    FFFF  param\n#   12          204800          233471   14.0 MiB    8300  efs\n#   13          233472          239615   3.0 MiB     FFFF  modemst1\n#   14          239616          245759   3.0 MiB     FFFF  modemst2\n#   15          245760          272383   13.0 MiB    FFFF  boot\n#   16          272384          303103   15.0 MiB    FFFF  recovery\n#   17          303104          329727   13.0 MiB    FFFF  fota\n#   18          329728          344045   7.0 MiB     8300  backup\n#   19          344046          344047   1024 bytes  FFFF  fsc\n#   20          344048          344063   8.0 KiB     FFFF  ssd\n#   21          344064          360447   8.0 MiB     8300  persist\n#   22          360448          378879   9.0 MiB     8300  persdata\n#   23          378880         5498879   2.4 GiB     8300  system\n#   24         5498880         5908479   200.0 MiB   8300  cache\n#   25         5908480         6010879   50.0 MiB    8300  hidden\n#   26         6010880        30777310   11.8 GiB    8300  userdata\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\ndevice_makeFilenameConfig=\"system=1G-cache=32M+wipe-preload=min+wipe-data=max\"\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/msm_sdcc.1/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the crypto footer size:\n    local footerSize=$(( 16384 / sectorSize ))\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition   23  system      system          \"same keep ext4\"    0\n    initPartition   24  cache       cache           \"same keep ext4\"    0\n    initPartition   25  hidden      preload         \"same keep ext4\"    0\n    initPartition   26  userdata    data            \"same keep ext4\"    $footerSize\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"$(seq 23 26)\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=26\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    heapAlignment=$(( 1 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"$(seq 23 26)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=$(parOldEnd 22)       # one past the end of a specific partition\n    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n\n}\n"
  },
  {
    "path": "device/.disabled/galaxy-s5/klte_UNTESTED.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### klte\n\n# This port was possible thanks to the invaluable help of wecip.\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:kltexx:*) ;;\n        *:kltelra:*) ;;\n        *:kltetmo:*) ;;\n        *:kltecan:*) ;;\n        *:klteatt:*) ;;\n        *:klteub:*) ;;\n        *:klteacg:*) ;;\n        *:klte:*) ;;\n        *:kltekor:*) ;;\n        *:klteskt:*) ;;\n        *:kltektt:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/.disabled/y560_UNTESTED.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### y560\n\n# This port was possible thanks to the invaluable help of macio525.\n\n# Disk /dev/block/mmcblk0: 15269888 sectors, 7.3 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20\n# Partition table holds up to 32 entries\n# First usable sector is 34, last usable sector is 15269854\n# Total free space is 332856 sectors (162.5 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1          131072          262143   64.0 MiB    0700  modem\n#    2          262144          263167   512.0 KiB   FFFF  sbl1\n#    3          263168          264191   512.0 KiB   FFFF  sbl1bak\n#    4          264192          266239   1024.0 KiB  FFFF  aboot\n#    5          266240          268287   1024.0 KiB  FFFF  abootbak\n#    6          268288          269311   512.0 KiB   FFFF  rpm\n#    7          269312          270335   512.0 KiB   FFFF  rpmbak\n#    8          270336          271871   768.0 KiB   FFFF  tz\n#    9          271872          273407   768.0 KiB   FFFF  tzbak\n#   10          273408          275455   1024.0 KiB  0700  pad\n#   11          275456          278527   1.5 MiB     FFFF  modemst1\n#   12          278528          281599   1.5 MiB     FFFF  modemst2\n#   13          281600          283647   1024.0 KiB  FFFF  misc\n#   14          283648          283649   1024 bytes  FFFF  fsc\n#   15          283650          283665   8.0 KiB     FFFF  ssd\n#   16          283666          304145   10.0 MiB    FFFF  splash\n#   17          393216          393279   32.0 KiB    FFFF  DDR\n#   18          393280          396351   1.5 MiB     FFFF  fsg\n#   19          396352          396383   16.0 KiB    FFFF  sec\n#   20          396384          461919   32.0 MiB    FFFF  boot\n#   21          461920          527455   32.0 MiB    FFFF  persist\n#   22          527456         4538259   1.9 GiB     FFFF  system\n#   23         4538260         5062547   256.0 MiB   FFFF  cache\n#   24         5062548         5128083   32.0 MiB    FFFF  recovery\n#   25         5128084         5130131   1024.0 KiB  FFFF  devinfo\n#   26         5242880         5243903   512.0 KiB   FFFF  keystore\n#   27         5243904         5374975   64.0 MiB    FFFF  oem\n#   28         5374976         5375999   512.0 KiB   FFFF  config\n#   29         5376000        15269854   4.7 GiB     FFFF  userdata\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\ndevice_makeFilenameConfig=\"system=1G-cache=32M+wipe-data=max\"\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:y560:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/soc.0/7824900.sdhci/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the crypto footer size:\n    local footerSize=$(( 16384 / sectorSize ))\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition   22  system      system          \"same keep ext4\"    0\n    initPartition   23  cache       cache           \"same keep ext4\"    0\n    initPartition   24  recovery    recovery        \"same keep raw\"     0\n    initPartition   25  devinfo     devinfo         \"same keep raw\"     0\n    initPartition   26  keystore    keystore        \"same keep raw\"     0\n    initPartition   27  oem         oem             \"same keep raw\"     0\n    initPartition   28  config      config          \"same keep raw\"     0\n    initPartition   29  userdata    data            \"same keep ext4\"    $footerSize\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"22 23 29\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=29\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    #heapAlignment=$(( 2 * 1024 / sectorSize ))     # stock alignment of the heap partitions is 2 KiB !!!\n    heapAlignment=$(( 1 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"$(seq 22 29)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=$(parOldEnd 21)       # one past the end of a specific partition\n    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n\n}\n"
  },
  {
    "path": "device/.disabled/y560_test.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### y560\n\n# This port was possible thanks to the invaluable help of macio525.\n\n# Disk /dev/block/mmcblk0: 15269888 sectors, 7.3 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20\n# Partition table holds up to 32 entries\n# First usable sector is 34, last usable sector is 15269854\n# Total free space is 332856 sectors (162.5 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1          131072          262143   64.0 MiB    0700  modem\n#    2          262144          263167   512.0 KiB   FFFF  sbl1\n#    3          263168          264191   512.0 KiB   FFFF  sbl1bak\n#    4          264192          266239   1024.0 KiB  FFFF  aboot\n#    5          266240          268287   1024.0 KiB  FFFF  abootbak\n#    6          268288          269311   512.0 KiB   FFFF  rpm\n#    7          269312          270335   512.0 KiB   FFFF  rpmbak\n#    8          270336          271871   768.0 KiB   FFFF  tz\n#    9          271872          273407   768.0 KiB   FFFF  tzbak\n#   10          273408          275455   1024.0 KiB  0700  pad\n#   11          275456          278527   1.5 MiB     FFFF  modemst1\n#   12          278528          281599   1.5 MiB     FFFF  modemst2\n#   13          281600          283647   1024.0 KiB  FFFF  misc\n#   14          283648          283649   1024 bytes  FFFF  fsc\n#   15          283650          283665   8.0 KiB     FFFF  ssd\n#   16          283666          304145   10.0 MiB    FFFF  splash\n#   17          393216          393279   32.0 KiB    FFFF  DDR\n#   18          393280          396351   1.5 MiB     FFFF  fsg\n#   19          396352          396383   16.0 KiB    FFFF  sec\n#   20          396384          461919   32.0 MiB    FFFF  boot\n#   21          461920          527455   32.0 MiB    FFFF  persist\n#   22          527456         4538259   1.9 GiB     FFFF  system\n#   23         4538260         5062547   256.0 MiB   FFFF  cache\n#   24         5062548         5128083   32.0 MiB    FFFF  recovery\n#   25         5128084         5130131   1024.0 KiB  FFFF  devinfo\n#   26         5242880         5243903   512.0 KiB   FFFF  keystore\n#   27         5243904         5374975   64.0 MiB    FFFF  oem\n#   28         5374976         5375999   512.0 KiB   FFFF  config\n#   29         5376000        15269854   4.7 GiB     FFFF  userdata\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\n#   device_makeFilenameConfig=\"system=1G-cache=32M+wipe-data=max\"\ndevice_makeFilenameConfig=\"cache=255M+wipe\"\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:y560:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/soc.0/7824900.sdhci/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the crypto footer size:\n    local footerSize=$(( 16384 / sectorSize ))\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n#    initPartition   22  system      system          \"same keep ext4\"    0\n    initPartition   23  cache       cache           \"same keep ext4\"    0\n    initPartition   24  recovery    recovery        \"same keep raw\"     0\n#    initPartition   25  devinfo     devinfo         \"same keep raw\"     0\n#    initPartition   26  keystore    keystore        \"same keep raw\"     0\n#    initPartition   27  oem         oem             \"same keep raw\"     0\n#    initPartition   28  config      config          \"same keep raw\"     0\n#    initPartition   29  userdata    data            \"same keep ext4\"    $footerSize\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n#    configurablePartitions=\"22 23 29\"\n    configurablePartitions=\"23\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=29\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n#    heapAlignment=$(( 1 * MiB ))\n    heapAlignment=$(( 2 * 1024 / sectorSize ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n#    heapPartitions=\"$(seq 22 29)\"\n    heapPartitions=\"$(seq 23 24)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n#    heapStart=$(parOldEnd 21)       # one past the end of a specific partition\n#    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n    heapStart=$(parOldEnd 22)       # one past the end of a specific partition\n    heapEnd=$(parOldStart 25)       # or the start of a specific partition\n\n}\n"
  },
  {
    "path": "device/cherry.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### cherry\n\n# This port was possible thanks to the invaluable help of jerryhou85.\n\n# Disk /dev/block/mmcblk0: 15269888 sectors, 7.3 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20\n# Partition table holds up to 24 entries\n# First usable sector is 34, last usable sector is 15269854\n# Partitions will be aligned on 1-sector boundaries\n# Total free space is 16350 sectors (8.0 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1              34            1057   512.0 KiB   FFFF  sbl1\n#    2            1058            2081   512.0 KiB   FFFF  hyp\n#    3            8192            8255   32.0 KiB    FFFF  sec\n#    4            8256            8319   32.0 KiB    FFFF  DDR\n#    5           16384           17407   512.0 KiB   FFFF  rpm\n#    6           17408           18431   512.0 KiB   FFFF  tz\n#    7           18432           28543   4.9 MiB     FFFF  aboot\n#    8           28544           30591   1024.0 KiB  FFFF  pad\n#    9           30592          161663   64.0 MiB    FFFF  oeminfo\n#   10          161664          169855   4.0 MiB     FFFF  modemst1\n#   11          169856          178047   4.0 MiB     FFFF  modemst2\n#   12          180224          376831   96.0 MiB    FFFF  modem\n#   13          376832          385023   4.0 MiB     FFFF  fsg\n#   14          385024          389119   2.0 MiB     FFFF  fsc\n#   15          389120          393215   2.0 MiB     FFFF  ssd\n#   16          393216          524287   64.0 MiB    FFFF  log\n#   17          524288          589823   32.0 MiB    FFFF  persist\n#   18          589824          630783   20.0 MiB    FFFF  boot\n#   19          630784          679935   24.0 MiB    FFFF  recovery\n#   20          679936         2252799   768.0 MiB   FFFF  cust\n#   21         2252800         2777087   256.0 MiB   FFFF  cache\n#   22         2777088         2785279   4.0 MiB     FFFF  misc\n#   23         2785280         6455295   1.8 GiB     FFFF  system\n#   24         6455296        15269854   4.2 GiB     0700  userdata\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\ndevice_makeFilenameConfig=\"cust=min+wipe-cache=32M+wipe-system=1G-data=max\"\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:cherry:*) ;;\n        *:Che1-CL20:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/soc.0/7824900.sdhci/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the crypto footer size:\n    local footerSize=$(( 16384 / sectorSize ))\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition   20  cust        cust            \"same keep ext4\"    0\n    initPartition   21  cache       cache           \"same keep ext4\"    0\n    initPartition   22  misc        misc            \"same keep raw\"     0\n    initPartition   23  system      system          \"same keep ext4\"    0\n    initPartition   24  userdata    data            \"same keep ext4\"    $footerSize\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"20 21 23 24\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=24\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 512 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    heapAlignment=$(( 4 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"$(seq 20 24)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=$(parOldEnd 19)       # one past the end of a specific partition\n    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n\n}\n"
  },
  {
    "path": "device/dior.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### dior\n\n# This port was possible thanks to the invaluable help of jerryhou85.\n\n# Caution: invalid backup GPT header, but valid main header; regenerating\n# backup header from main header.\n# \n# ****************************************************************************\n# Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk\n# verification and recovery are STRONGLY recommended.\n# ****************************************************************************\n# Disk /dev/block/mmcblk0: 15269888 sectors, 7.3 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20\n# Partition table holds up to 32 entries\n# First usable sector is 34, last usable sector is 15269854\n# Total free space is 65546 sectors (32.0 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1              34            4095   2.0 MiB     FFFF  sbl1\n#    2            4096            8157   2.0 MiB     0700  sbl1bak\n#    3            8158           10205   1024.0 KiB  FFFF  rpm\n#    4           10206           12253   1024.0 KiB  0700  rpmbak\n#    5           12254           14301   1024.0 KiB  FFFF  tz\n#    6           14302           16349   1024.0 KiB  0700  tzbak\n#    7           16350           16365   8.0 KiB     FFFF  ssd\n#    8           16366           18413   1024.0 KiB  FFFF  sdi\n#    9           18414           20461   1024.0 KiB  FFFF  DDR\n#   10           20462           28653   4.0 MiB     FFFF  aboot\n#   11           28654           36845   4.0 MiB     0700  abootbak\n#   12           36846           47085   5.0 MiB     8300  bk1\n#   13           47086           55277   4.0 MiB     FFFF  misc\n#   14           55278           71661   8.0 MiB     8300  logo\n#   15           71662          131061   29.0 MiB    8300  bk2\n#   16          131062          134133   1.5 MiB     FFFF  modemst1\n#   17          134134          137205   1.5 MiB     FFFF  modemst2\n#   18          137206          137207   1024 bytes  FFFF  fsc\n#   19          137208          262133   61.0 MiB    8300  bk3\n#   20          262134          265205   1.5 MiB     FFFF  fsg\n#   21          265206          327669   30.5 MiB    8300  bk4\n#   22          327670          393205   32.0 MiB    8300  bk5\n#   23          393206          524277   64.0 MiB    0700  modem\n#   24          524278          557045   16.0 MiB    FFFF  boot\n#   25          557046          589813   16.0 MiB    FFFF  recovery\n#   26          589814          655349   32.0 MiB    0700  persist\n#   27          655350         2293749   800.0 MiB   0700  system\n#   28         2293750         3080181   384.0 MiB   0700  cache\n#   29         3145728        15269854   5.8 GiB     0700  userdata\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\n#device_makeFilenameConfig=\"system=1160M-cache=32M+wipe-data=same\"\n#device_makeFilenameConfig=\"system=max-cache=32M+wipe-data=same\"\n\n#device_makeFilenameConfig=\"system=1G-cache=168M+wipe-data=same\"\n#device_makeFilenameConfig=\"system=1G-cache=max+wipe-data=same\"\n\ndevice_makeFilenameConfig=\"system=same-cache=32M+wipe-data=max\"\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:dior:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/msm_sdcc.1/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition   27  system      system          \"same keep ext4\"    0\n    initPartition   28  cache       cache           \"same keep ext4\"    0\n    initPartition   29  userdata    data            \"same keep ext4\"    0\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"$(seq 27 29)\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=29\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    heapAlignment=$(( 4 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"$(seq 27 29)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=$(parOldEnd 26)       # one past the end of a specific partition\n    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n\n}\n"
  },
  {
    "path": "device/galaxy-j5/common.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### galaxy-j5\n\n# This port was possible thanks to the invaluable help of ajislav.\n\n# Disk /dev/block/mmcblk0: 15269888 sectors, 7.3 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20\n# Partition table holds up to 128 entries\n# First usable sector is 34, last usable sector is 15269854\n# Total free space is 8165 sectors (4.0 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1            8192           38911   15.0 MiB    0700  apnhlos\n#    2           38912          156543   57.4 MiB    0700  modem\n#    3          156544          157567   512.0 KiB   FFFF  sbl1\n#    4          157568          157631   32.0 KiB    FFFF  ddr\n#    5          157632          161727   2.0 MiB     FFFF  aboot\n#    6          161728          162751   512.0 KiB   FFFF  rpm\n#    7          162752          163775   512.0 KiB   FFFF  qsee\n#    8          163776          164799   512.0 KiB   FFFF  qhee\n#    9          164800          170943   3.0 MiB     FFFF  fsg\n#   10          170944          170975   16.0 KiB    FFFF  sec\n#   11          170976          192511   10.5 MiB    0700  pad\n#   12          192512          212991   10.0 MiB    FFFF  param\n#   13          212992          241663   14.0 MiB    8300  efs\n#   14          241664          247807   3.0 MiB     FFFF  modemst1\n#   15          247808          253951   3.0 MiB     FFFF  modemst2\n#   16          253952          280575   13.0 MiB    FFFF  boot\n#   17          280576          311295   15.0 MiB    FFFF  recovery\n#   18          311296          336897   12.5 MiB    FFFF  fota\n#   19          336898          351215   7.0 MiB     8300  backup\n#   20          351216          357359   3.0 MiB     FFFF  fsc\n#   21          357360          357375   8.0 KiB     FFFF  ssd\n#   22          357376          373759   8.0 MiB     8300  persist\n#   23          373760          374783   512.0 KiB   8300  persistent\n#   24          374784          393215   9.0 MiB     8300  persdata\n#   25          393216         4653055   2.0 GiB     8300  system\n#   26         4653056         5062655   200.0 MiB   8300  cache\n#   27         5062656         5206015   70.0 MiB    8300  hidden\n#   28         5206016        15269847   4.8 GiB     8300  userdata\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\ndevice_makeFilenameConfig=\"system=1G-cache=32M+wipe-preload=min+wipe-data=max\"\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/soc.0/7824900.sdhci/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the crypto footer size:\n    local footerSize=$(( 16384 / sectorSize ))\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition   25  system      system          \"same keep ext4\"    0\n    initPartition   26  cache       cache           \"same keep ext4\"    0\n    initPartition   27  hidden      preload         \"same keep ext4\"    0\n    initPartition   28  userdata    data            \"same keep ext4\"    $footerSize\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"$(seq 25 28)\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=28\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    heapAlignment=$(( 1 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"$(seq 25 28)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=$(parOldEnd 24)       # one past the end of a specific partition\n    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n\n}\n"
  },
  {
    "path": "device/galaxy-j5/j5lte.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### j5lte\n\n# This port was possible thanks to the invaluable help of ajislav.\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:j5lte:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/galaxy-s2/common.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### galaxy-s2\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\ndevice_makeFilenameConfig=\"system=1G-data=same-sdcard=max-preload=min+wipe\"\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    # exynos 4210:\n    #sdev=/sys/devices/platform/dw_mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    # omap 4430:\n    #sdev=/sys/devices/platform/omap/omap_hsmmc.1/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n\n    # unmounting the partitions of the selected block device seems to be enough:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n\n    # but we will unmount the external sdcard too (due to some reports that i was so far unable to reproduce):\n    #unmountPattern=\"/dev/block/mmcblk\\(0\\|1\\)\\(p[0-9]\\+\\)\\?\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the crypto footer size:\n    local footerSize=$(( 16384 / sectorSize ))\n    # not all partition types support crypto footers; those that do not will ignore the value passed to initPartition.\n    # also, not all devices use crypto footers; on those devices, pass a value of zero to initPartition for all partitions.\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    #initPartition   7  CACHE       cache           \"same keep ext4\"    0\n    #initPartition   8  MODEM       modem           \"same keep raw\"     0\n    initPartition    9  FACTORYFS   system          \"same keep ext4\"    0\n    initPartition   10  DATAFS      data            \"same keep ext4\"    $footerSize\n    initPartition   11  UMS         sdcard          \"same keep vfat\"    0\n    initPartition   12  HIDDEN      preload         \"same keep ext4\"    0\n\n    # resizing cache is disabled for now since i am not sure that the modem partition can be safely moved simply by updating\n    # the GPT and not changing the PIT. it is possible that whatever code boots up the modem might read the partition offset\n    # from the PIT and not the GPT. it is also possible that the device might brick if the modem cannot be brought up.\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    #configurablePartitions=\"7 $(seq 9 12)\"\n    configurablePartitions=\"$(seq 9 12)\"\n    # for some partitions it may be unsafe to do anything besides moving them around; those should be left out of this set.\n\n}\n\ndevice_setup() {\n\n    ### this is the first function that can access block devices and/or their metadata.\n\n    # the number of partitions that the device must have:\n    partitionCount=12\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    ### the following settings are actually per-heap, but can be defined here instead if their values are constant.\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    # this defaults to 8 MiB, the smallest power-of-2 size that will fit a standard ext4 file system.\n    # note: this setting only applies to the 'min' keyword; partition sizes all the way down to $heapSizeGranularity\n    # can still be manually defined even if they are smaller than $heapMinSize.\n    \n    # the partition alignment:\n    heapAlignment=$(( 4 * MiB ))\n    # for best results it is recommended that you use the same alignment chosen by the device OEM.\n    # you can determine its value by analyzing the stock partitioning, for example with this command:\n    # > parted /dev/block/whatever -s unit MiB print free\n    # if in doubt, use 1 or 4 MiB.\n    \n    # user-configured partition sizes will be rounded (to nearest) to multiples of this value:\n    #heapSizeGranularity=$heapAlignment\n    # this defaults to $heapAlignment and should normally not be changed.\n\n}\n\ndevice_setupHeap_main() {\n\n    # each heap is a set of partitions that are physically contiguous in the block device.\n    # all partition manipulation works exclusively within a heap.\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    #heapPartitions=\"$(seq 7 12)\"\n    heapPartitions=\"$(seq 9 12)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    # (the sector range is from heapStart to heapEnd-1 inclusive.)\n\n    #heapStart=$deviceHeapStart     # the first usable sector of the device\n    #heapStart=$(parOldEnd 6)       # or one past the end of a specific partition\n    heapStart=$(parOldEnd 8)        # or one past the end of a specific partition\n    #heapStart=344064               # or a fixed sector number\n\n    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n    #heapEnd=$(parOldStart 13)      # or the start of a specific partition\n    #heapEnd=30769152               # or a fixed sector number\n\n}\n"
  },
  {
    "path": "device/galaxy-s2/exynos-4210/d710.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### d710\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:epic4gtouch:*) ;;\n        *:SPH-D710:*) ;;\n        *:d710:*) ;;\n        *:smdk4210:*) ;;\n        *:SPH-D710VMUB:*) ;;\n        *:SPH-D710BST:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/galaxy-s2/exynos-4210/i777.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### i777\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:i777:*) ;;\n        *:SGH-I777:*) ;;\n        *:SGH-S959G:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/galaxy-s2/exynos-4210/i9100.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### i9100\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:galaxys2:*) ;;\n        *:i9100:*) ;;\n        *:GT-I9100:*) ;;\n        *:GT-I9100M:*) ;;\n        *:GT-I9100P:*) ;;\n        *:GT-I9100T:*) ;;\n        *:SC-02C:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n\n### code after this comment is old and no longer used. it is here for documentation purposes only.\n\ndevice_detectBlockDeviceSize_i9100() {\n\n    # this is unused code from when detectBlockDeviceHeapRange had not yet been implemented.\n    # it is here for documentation purposes only, ports to other devices should delete this function.\n\n    info \"detecting eMMC size\"\n\n    local deviceSize=$(cat $sdev/size)\n    local heapEnd8GB=15261696\n    local heapEnd16GB=30769152\n    local heapEnd32GB=62513152\n    if [ $(( deviceSize < heapEnd8GB )) -ne 0 ]; then\n        fatal \"eMMC size too small\"\n    elif [ $(( deviceSize < heapEnd16GB )) -ne 0 ]; then\n        heapEnd=$heapEnd8GB\n        info \"eMMC size is 8 GB\"\n    elif [ $(( deviceSize < heapEnd32GB )) -ne 0 ]; then\n        heapEnd=$heapEnd16GB\n        info \"eMMC size is 16 GB\"\n    else\n        heapEnd=$heapEnd32GB\n        info \"eMMC size is 32 GB\"\n    fi\n\n}\n\ndevice_configureStockLayout_i9100() {\n\n    # this is unused code from when the configuration parser had not yet been implemented.\n    # it is here for documentation purposes only, ports to other devices should delete this function.\n\n    # stock partition layout for i9100:\n\n    system_size=0.5\n    data_size=2\n    #sdcard_size=11.5078\n    sdcard_size=max\n    preload_size=0.5\n\n    system_fs=ext4\n    data_fs=ext4\n    sdcard_fs=vfat\n    preload_fs=ext4\n\n}\n"
  },
  {
    "path": "device/galaxy-s2/exynos-4210/n7000.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### n7000\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:galaxynote:*) ;;\n        *:n7000:*) ;;\n        *:N7000:*) ;;\n        *:GT-N7000:*) ;;\n       *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/galaxy-s2/exynos-4210/sc02c.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### sc02c\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:galaxys2:*) ;;\n        *:i9100:*) ;;\n        *:GT-I9100:*) ;;\n        *:GT-I9100M:*) ;;\n        *:GT-I9100P:*) ;;\n        *:GT-I9100T:*) ;;\n        *:SC-02C:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/galaxy-s2/omap-4430/i9100g.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### i9100g\n\n# This port was possible thanks to the invaluable help of MalcolmMcConnor.\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:i9100g:*) ;;\n        *:GT-I9100G:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/galaxy-s3/exynos/i9300.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### i9300\n\n# This port was possible thanks to the invaluable help of ElPumpo/Hawaii_Beach.\n\n# Disk /dev/block/mmcblk0: 30777344 sectors, 2740M\n# Logical sector size: 512\n# Disk identifier (GUID): 52444e41-494f-2044-4d4d-43204449534b\n# Partition table holds up to 128 entries\n# First usable sector is 34, last usable sector is 30777310\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1            8192           16383       4096K   0700  BOTA0\n#    2           16384           24575       4096K   0700  BOTA1\n#    3           24576           65535       20.0M   0700  EFS\n#    4           65536           81919       8192K   0700  PARAM\n#    5           81920           98303       8192K   0700  BOOT\n#    6           98304          114687       8192K   0700  RECOVERY\n#    7          114688          180223       32.0M   0700  RADIO\n#    8          180224         2277375       1024M   0700  CACHE\n#    9         2277376         5423103       1536M   0700  SYSTEM\n#   10         5423104         6569983        560M   0700  HIDDEN\n#   11         6569984         6586367       8192K   0700  OTA\n#   12         6586368        30769151       11.5G   0700  USERDATA\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\ndevice_makeFilenameConfig=\"cache=32M+wipe-system=same-preload=min+wipe-data=max\"\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:m0:*) ;;\n        *:i9300:*) ;;\n        *:GT-I9300:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/platform/dw_mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the crypto footer size:\n    local footerSize=$(( 16384 / sectorSize ))\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition    8  CACHE       cache           \"same keep ext4\"    0\n    initPartition    9  SYSTEM      system          \"same keep ext4\"    0\n    initPartition   10  HIDDEN      preload         \"same keep ext4\"    0\n    initPartition   11  OTA         ota             \"same keep raw\"     0\n    initPartition   12  USERDATA    data            \"same keep ext4\"    $footerSize\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"$(seq 8 12)\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=12\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    heapAlignment=$(( 4 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"$(seq 8 12)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=$(parOldEnd 7)        # one past the end of a specific partition\n    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n\n}\n"
  },
  {
    "path": "device/galaxy-s3/exynos/i9305.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### i9305\n\n# This port was possible thanks to the invaluable help of nishimura-san.\n\n# Disk /dev/block/mmcblk0: 30777344 sectors, 14.7 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 52444E41-494F-2044-4D4D-43204449534B\n# Partition table holds up to 128 entries\n# First usable sector is 34, last usable sector is 30777310\n# Total free space is 16317 sectors (8.0 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1            8192           16383   4.0 MiB     0700  BOTA0\n#    2           16384           24575   4.0 MiB     0700  BOTA1\n#    3           24576           65535   20.0 MiB    0700  EFS\n#    4           65536           73727   4.0 MiB     0700  m9kefs1\n#    5           73728           81919   4.0 MiB     0700  m9kefs2\n#    6           81920           90111   4.0 MiB     0700  m9kefs3\n#    7           90112          106495   8.0 MiB     0700  PARAM\n#    8          106496          122879   8.0 MiB     0700  BOOT\n#    9          122880          139263   8.0 MiB     0700  RECOVERY\n#   10          139264          319487   88.0 MiB    0700  RADIO\n#   11          319488          843775   256.0 MiB   0700  TOMBSTONES\n#   12          843776         2940927   1024.0 MiB  0700  CACHE\n#   13         2940928         6086655   1.5 GiB     0700  SYSTEM\n#   14         6086656         7233535   560.0 MiB   0700  HIDDEN\n#   15         7233536         7249919   8.0 MiB     0700  OTA\n#   16         7249920        30769151   11.2 GiB    0700  USERDATA\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\ndevice_makeFilenameConfig=\"tombstones=same-cache=32M+wipe-system=1G-preload=min+wipe-data=max\"\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:m3:*) ;;\n        *:m3xx:*) ;;\n        *:i9305:*) ;;\n        *:GT-I9305:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/platform/dw_mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the crypto footer size:\n    local footerSize=$(( 16384 / sectorSize ))\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition   11  TOMBSTONES  tombstones      \"same keep ext4\"    0\n    initPartition   12  CACHE       cache           \"same keep ext4\"    0\n    initPartition   13  SYSTEM      system          \"same keep ext4\"    0\n    initPartition   14  HIDDEN      preload         \"same keep ext4\"    0\n    initPartition   15  OTA         ota             \"same keep raw\"     0\n    initPartition   16  USERDATA    data            \"same keep ext4\"    $footerSize\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"$(seq 11 16)\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=16\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    heapAlignment=$(( 4 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"$(seq 11 16)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=$(parOldEnd 10)       # one past the end of a specific partition\n    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n\n}\n"
  },
  {
    "path": "device/galaxy-s3/snapdragon/common.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2019, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### galaxy-s3/snapdragon\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\ndevice_makeFilenameConfig=\"system=same-data=max-cache=32M+wipe\"\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/platform/msm_sdcc.1/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the crypto footer size:\n    local footerSize=$(( 16384 / sectorSize ))\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition   14  system      system          \"same keep ext4\"    0\n    initPartition   15  userdata    data            \"same keep ext4\"    $footerSize\n    initPartition   16  persist     persist         \"same keep raw\"     0\n    initPartition   17  cache       cache           \"same keep ext4\"    0\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"14 15 17\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=23\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    #detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    heapAlignment=$(( 4 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"$(seq 14 17)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=$(parOldEnd 13)       # one past the end of a specific partition\n    heapEnd=$(parOldStart 18)       # the start of a specific partition\n\n}\n"
  },
  {
    "path": "device/galaxy-s3/snapdragon/d2tmo.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2019, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### d2tmo\n\n# This port was possible thanks to the invaluable help of mw-merickso.\n\n# Disk /dev/block/mmcblk0: 30777344 sectors, 14.7 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20\n# Partition table holds up to 128 entries\n# First usable sector is 34, last usable sector is 30765071\n# Total free space is 8158 sectors (4.0 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1            8192          131071   60.0 MiB    0700  modem\n#    2          131072          131327   128.0 KiB   FFFF  sbl1\n#    3          131328          131839   256.0 KiB   FFFF  sbl2\n#    4          131840          132863   512.0 KiB   FFFF  sbl3\n#    5          132864          136959   2.0 MiB     FFFF  aboot\n#    6          136960          137983   512.0 KiB   FFFF  rpm\n#    7          137984          158463   10.0 MiB    FFFF  boot\n#    8          158464          159487   512.0 KiB   FFFF  tz\n#    9          159488          160511   512.0 KiB   FFFF  pad\n#   10          160512          180991   10.0 MiB    8300  param\n#   11          180992          208895   13.6 MiB    8300  efs\n#   12          208896          215039   3.0 MiB     FFFF  modemst1\n#   13          215040          221183   3.0 MiB     FFFF  modemst2\n#   14          221184         3293183   1.5 GiB     8300  system\n#   15         3293184        28958719   12.2 GiB    8300  userdata\n#   16        28958720        28975103   8.0 MiB     8300  persist\n#   17        28975104        30695423   840.0 MiB   8300  cache\n#   18        30695424        30715903   10.0 MiB    FFFF  recovery\n#   19        30715904        30736383   10.0 MiB    FFFF  fota\n#   20        30736384        30748671   6.0 MiB     8300  backup\n#   21        30748672        30754815   3.0 MiB     FFFF  fsg\n#   22        30754816        30754831   8.0 KiB     FFFF  ssd\n#   23        30754832        30765071   5.0 MiB     8300  grow\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:d2tmo:*) ;;\n        *:d2lte:*) ;;\n        *:SGH-T999:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/galaxy-s3/snapdragon/d2usc.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2019, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### d2usc\n\n# This port was possible thanks to the invaluable help of terracota/TeracottaShishi.\n\n# Disk /dev/block/mmcblk0: 61071360 sectors, 29.1 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20\n# Partition table holds up to 128 entries\n# First usable sector is 34, last usable sector is 61071326\n# Total free space is 20397 sectors (10.0 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1            8192          131071   60.0 MiB    0700  modem\n#    2          131072          131327   128.0 KiB   FFFF  sbl1\n#    3          131328          131839   256.0 KiB   FFFF  sbl2\n#    4          131840          132863   512.0 KiB   FFFF  sbl3\n#    5          132864          136959   2.0 MiB     FFFF  aboot\n#    6          136960          137983   512.0 KiB   FFFF  rpm\n#    7          137984          158463   10.0 MiB    FFFF  boot\n#    8          158464          159487   512.0 KiB   FFFF  tz\n#    9          159488          160511   512.0 KiB   FFFF  pad\n#   10          160512          180991   10.0 MiB    8300  param\n#   11          180992          208895   13.6 MiB    8300  efs\n#   12          208896          215039   3.0 MiB     FFFF  modemst1\n#   13          215040          221183   3.0 MiB     FFFF  modemst2\n#   14          221184         3293183   1.5 GiB     8300  system\n#   15         3293184        59252735   26.7 GiB    8300  userdata\n#   16        59252736        59269119   8.0 MiB     8300  persist\n#   17        59269120        60989439   840.0 MiB   8300  cache\n#   18        60989440        61009919   10.0 MiB    FFFF  recovery\n#   19        61009920        61030399   10.0 MiB    FFFF  fota\n#   20        61030400        61042687   6.0 MiB     8300  backup\n#   21        61042688        61048831   3.0 MiB     FFFF  fsg\n#   22        61048832        61048847   8.0 KiB     FFFF  ssd\n#   23        61048848        61059087   5.0 MiB     8300  grow\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:d2usc:*) ;;\n        *:d2lte:*) ;;\n        *:SCH-R530U:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/janice.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### janice\n\n# Disk /dev/block/mmcblk0: 15269888 sectors, 3360M\n# Logical sector size: 512\n# Disk identifier (GUID): 52444e41-494f-2044-4d4d-43204449534b\n# Partition table holds up to 128 entries\n# First usable sector is 34, last usable sector is 15269854\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1           71680          104447       16.0M   0700  PARAM\n#    2           28672           61439       16.0M   0700  Modem FS\n#    3          206848         1460223        612M   0700  SYSTEM\n#    4         5654528         6281215        306M   0700  CACHEFS\n#    5         1460224         5654527       2048M   0700  DATAFS\n#    6            3072            6143       1536K   0700  CSPSA FS\n#    7            8192           28671       10.0M   0700  EFS\n#    8         7038976        15251455       4010M   0700  UMS\n#    9         6281216         6936575        320M   0700  HIDDEN\n#   10            1024            3071       1024K   0700  PIT\n#   11         6936576         7038975       50.0M   0700  Fota\n#   12          104448          108543       2048K   0700  IPL Modem\n#   13          108544          141311       16.0M   0700  Modem\n#   14           63488           67583       2048K   0700  SBL\n#   15          141312          174079       16.0M   0700  Kernel\n#   16           67584           71679       2048K   0700  SBL_2\n#   17          174080          206847       16.0M   0700  Kernel2\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#   10            1024            3071       1024K   0700  PIT\n#    6            3072            6143       1536K   0700  CSPSA FS\n#    7            8192           28671       10.0M   0700  EFS\n#    2           28672           61439       16.0M   0700  Modem FS\n#   14           63488           67583       2048K   0700  SBL\n#   16           67584           71679       2048K   0700  SBL_2\n#    1           71680          104447       16.0M   0700  PARAM\n#   12          104448          108543       2048K   0700  IPL Modem\n#   13          108544          141311       16.0M   0700  Modem\n#   15          141312          174079       16.0M   0700  Kernel\n#   17          174080          206847       16.0M   0700  Kernel2\n#    3          206848         1460223        612M   0700  SYSTEM\n#    5         1460224         5654527       2048M   0700  DATAFS\n#    4         5654528         6281215        306M   0700  CACHEFS\n#    9         6281216         6936575        320M   0700  HIDDEN\n#   11         6936576         7038975       50.0M   0700  Fota\n#    8         7038976        15251455       4010M   0700  UMS\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\ndevice_makeFilenameConfig=\"system=1G-data=3G-cache=32M+wipe-preload=min+wipe-fota=min+wipe+ext4-sdcard=max\"\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:janice:*) ;;\n        *:i9070:*) ;;\n        *:GT-I9070:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/sdi2/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the crypto footer size:\n    local footerSize=$(( 16384 / sectorSize ))\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition    3  SYSTEM      system          \"same keep ext4\"    0\n    initPartition    5  DATAFS      data            \"same keep ext4\"    $footerSize\n    initPartition    4  CACHEFS     cache           \"same keep ext4\"    0\n    initPartition    9  HIDDEN      preload         \"same keep ext4\"    0\n    initPartition   11  Fota        fota            \"same keep raw\"     0\n    initPartition    8  UMS         sdcard          \"same keep vfat\"    0\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"3 5 4 9 11 8\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=17\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 128 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    heapAlignment=$(( 1 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"3 5 4 9 11 8\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=$(parOldEnd 17)       # one past the end of a specific partition\n    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n\n}\n"
  },
  {
    "path": "device/nexus-7-2013/common.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2019, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### nexus-7-2013\n\n# Disk /dev/block/mmcblk0: 61079552 sectors, 29.1 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20\n# Partition table holds up to 32 entries\n# First usable sector is 34, last usable sector is 61079518\n# Total free space is 1526010 sectors (745.1 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1          131072          306143   85.5 MiB    0700  radio\n#    2          393216          399359   3.0 MiB     FFFF  modemst1\n#    3          399360          405503   3.0 MiB     FFFF  modemst2\n#    4          524288          554287   14.6 MiB    8300  persist\n#    5          655360          656919   780.0 KiB   FFFF  m9kefs1\n#    6          656920          658479   780.0 KiB   FFFF  m9kefs2\n#    7          786432          787991   780.0 KiB   FFFF  m9kefs3\n#    8          787992          794135   3.0 MiB     FFFF  fsg\n#    9          917504          920503   1.5 MiB     FFFF  sbl1\n#   10          920504          923503   1.5 MiB     FFFF  sbl2\n#   11          923504          927599   2.0 MiB     FFFF  sbl3\n#   12          927600          937839   5.0 MiB     FFFF  aboot\n#   13          937840          938863   512.0 KiB   FFFF  rpm\n#   14         1048576         1081343   16.0 MiB    FFFF  boot\n#   15         1179648         1180671   512.0 KiB   FFFF  tz\n#   16         1180672         1180673   1024 bytes  FFFF  pad\n#   17         1180674         1183673   1.5 MiB     FFFF  sbl2b\n#   18         1183674         1187769   2.0 MiB     FFFF  sbl3b\n#   19         1187770         1198009   5.0 MiB     FFFF  abootb\n#   20         1198010         1199033   512.0 KiB   FFFF  rpmb\n#   21         1199034         1200057   512.0 KiB   FFFF  tzb\n#   22         1310720         3031039   840.0 MiB   8300  system\n#   23         3031040         4177919   560.0 MiB   8300  cache\n#   24         4194304         4196351   1024.0 KiB  FFFF  misc\n#   25         4325376         4345855   10.0 MiB    FFFF  recovery\n#   26         4456448         4456463   8.0 KiB     FFFF  DDR\n#   27         4456464         4456479   8.0 KiB     FFFF  ssd\n#   28         4456480         4456481   1024 bytes  FFFF  m9kefsc\n#   29         4587520         4587583   32.0 KiB    FFFF  metadata\n#   30         4718592        61079518   26.9 GiB    8300  userdata\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\ndevice_makeFilenameConfig=\"system=max-cache=32M+wipe\"\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/platform/msm_sdcc.1/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the crypto footer size:\n    local footerSize=$(( 16384 / sectorSize ))\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition   22  system      system          \"same keep ext4\"    0\n    initPartition   23  cache       cache           \"same keep ext4\"    0\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"$(seq 22 23)\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=30\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    #detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    heapAlignment=$(( 4 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"$(seq 22 23)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=1310720\n    heapEnd=4194304\n\n}\n"
  },
  {
    "path": "device/nexus-7-2013/deb.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2019, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### deb\n\n# This port was possible thanks to the invaluable help of ipdev99 and xxhoeckyxx.\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:deb:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/nexus-7-2013/flo.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2019, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### flo\n\n# This port was possible thanks to the invaluable help of ipdev99 and xxhoeckyxx.\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:flo:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/nook-hd/common.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### nook-hd\n\n# Logical sector size: 512 bytes\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1             256             511   128.0 KiB   8300  xloader\n#    2             512            1023   256.0 KiB   8300  bootloader\n#    3            1024           31743   15.0 MiB    8300  recovery\n#    4           32768           65535   16.0 MiB    8300  boot\n#    5           65536          163839   48.0 MiB    8300  rom\n#    6          163840          262143   48.0 MiB    8300  bootdata\n#    7          262144         1179647   448.0 MiB   8300  factory\n#    8         1179648         2555903   672.0 MiB   8300  system\n#    9         2555904         3506175   464.0 MiB   8300  cache\n#   10         3506176        30507007   12.9 GiB    8300  userdata\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\n#device_makeFilenameConfig=\"factory=same-system=1104M-cache=32M+wipe-data=same\"\ndevice_makeFilenameConfig=\"factory=same-system=1G-cache=112M+wipe-data=same\"\n#device_makeFilenameConfig=\"factory=32M-system=1G-cache=32M+wipe-data=max\"\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:ovation:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/platform/omap/omap_hsmmc.1/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the crypto footer size:\n    local footerSize=$(( 16384 / sectorSize ))\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition    7  factory     factory         \"same keep ext4\"    0\n    initPartition    8  system      system          \"same keep ext4\"    0\n    initPartition    9  cache       cache           \"same keep ext4\"    0\n    initPartition   10  userdata    data            \"same keep ext4\"    $footerSize\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"$(seq 7 10)\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=10\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    heapAlignment=$(( 4 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"$(seq 7 10)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=$(parOldEnd 6)        # one past the end of a specific partition\n    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n\n}\n"
  },
  {
    "path": "device/nook-hd/hummingbird.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### hummingbird\n\n# This port was possible thanks to the invaluable help of BultoPaco.\n\n# Caution: invalid backup GPT header, but valid main header; regenerating\n# backup header from main header.\n# \n# Warning! Main and backup partition tables differ! Use the 'c' and 'e' options\n# on the recovery & transformation menu to examine the two tables.\n# \n# Warning! One or more CRCs don't match. You should repair the disk!\n# \n# ****************************************************************************\n# Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk\n# verification and recovery are STRONGLY recommended.\n# ****************************************************************************\n# Disk /dev/block/mmcblk0: 31129600 sectors, 14.8 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 4F417C26-4505-4832-9F38-0F1A75E87AFC\n# Partition table holds up to 128 entries\n# First usable sector is 34, last usable sector is 31129566\n# Total free space is 623805 sectors (304.6 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1             256             511   128.0 KiB   8300  xloader\n#    2             512            1023   256.0 KiB   8300  bootloader\n#    3            1024           31743   15.0 MiB    8300  recovery\n#    4           32768           65535   16.0 MiB    8300  boot\n#    5           65536          163839   48.0 MiB    8300  rom\n#    6          163840          262143   48.0 MiB    8300  bootdata\n#    7          262144         1179647   448.0 MiB   8300  factory\n#    8         1179648         2555903   672.0 MiB   8300  system\n#    9         2555904         3506175   464.0 MiB   8300  cache\n#   10         3506176        30507007   12.9 GiB    8300  userdata\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:hummingbird:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/nook-hd/ovation.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### ovation\n\n# This port was possible thanks to the invaluable help of 149113.\n\n# Caution: invalid backup GPT header, but valid main header; regenerating\n# backup header from main header.\n# \n# Warning! Main and backup partition tables differ! Use the 'c' and 'e' options\n# on the recovery & transformation menu to examine the two tables.\n# \n# Warning! One or more CRCs don't match. You should repair the disk!\n# \n# ****************************************************************************\n# Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk\n# verification and recovery are STRONGLY recommended.\n# ****************************************************************************\n# Disk /dev/block/mmcblk0: 30535680 sectors, 14.6 GiB\n# Logical sector size: 512 bytes\n# Disk identifier (GUID): 3290B191-5EED-4A94-BFD4-0ECCA08BCEF4\n# Partition table holds up to 128 entries\n# First usable sector is 34, last usable sector is 30535646\n# Total free space is 29885 sectors (14.6 MiB)\n# \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1             256             511   128.0 KiB   8300  xloader\n#    2             512            1023   256.0 KiB   8300  bootloader\n#    3            1024           31743   15.0 MiB    8300  recovery\n#    4           32768           65535   16.0 MiB    8300  boot\n#    5           65536          163839   48.0 MiB    8300  rom\n#    6          163840          262143   48.0 MiB    8300  bootdata\n#    7          262144         1179647   448.0 MiB   8300  factory\n#    8         1179648         2555903   672.0 MiB   8300  system\n#    9         2555904         3506175   464.0 MiB   8300  cache\n#   10         3506176        30507007   12.9 GiB    8300  userdata\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:ovation:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/tuna/common.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### tuna\n\n# This port was possible thanks to the invaluable help of thagringo.\n\n# Disk /dev/block/mmcblk0: 30777344 sectors, 2740M\n# Logical sector size: 512\n# Disk identifier (GUID): 52444e41-494f-2044-4d4d-43204449534b\n# Partition table holds up to 128 entries\n# First usable sector is 34, last usable sector is 30777310\n#  \n# Number  Start (sector)    End (sector)  Size       Code  Name\n#    1             256             511        128K   0700  xloader\n#    2            1024            8191       3584K   0700  sbl\n#    3            8192           49151       20.0M   0700  efs\n#    4           49152           65535       8192K   0700  param\n#    5           65536           73727       4096K   0700  misc\n#    6           73728           81919       4096K   0700  dgs\n#    7           81920           98303       8192K   0700  boot\n#    8           98304          122751       11.9M   0700  recovery\n# * 13          122752          122879       65536   0700  metadata\n#    9          122880          155647       16.0M   0700  radio\n#   10          155648         1495039        654M   0700  system\n#   11         1495040         2379775        432M   0700  cache\n#   12         2379776        30777309       13.5G   0700  userdata\n\ndevice_makeFlashizeEnv=\"env/arm.zip\"\n\ndevice_makeFilenameConfig=\"system=1G-cache=62M+wipe-data=same\"\n\ndevice_init() {\n\n    device_checkDevice\n\n    # the block device on which REPIT will operate (only one device is supported):\n\n    #sdev=/sys/devices/platform/omap/omap_hsmmc.0/mmc_host/mmc0/mmc0:0001/block/mmcblk0\n    sdev=/sys/block/mmcblk0\n    spar=$sdev/mmcblk0p\n\n    ddev=/dev/block/mmcblk0\n    dpar=/dev/block/mmcblk0p\n\n    sectorSize=512      # in bytes\n\n    # a grep pattern matching the partitions that must be unmounted before REPIT can start:\n    #unmountPattern=\"${dpar}[0-9]\\+\"\n    unmountPattern=\"/dev/block/mmcblk[^ ]*\"\n\n}\n\ndevice_initPartitions() {\n\n    # the set of partitions that can be modified by REPIT:\n    #     <gpt-number>  <gpt-name>  <friendly-name> <conf-defaults>     <crypto-footer>\n    initPartition   10  system      system          \"same keep ext4\"    0\n    initPartition   11  cache       cache           \"same keep ext4\"    0\n    initPartition   12  userdata    data            \"same keep ext4\"    0\n\n    # the set of modifiable partitions that can be configured by the user (overriding <conf-defaults>):\n    configurablePartitions=\"$(seq 10 12)\"\n\n}\n\ndevice_setup() {\n\n    # the number of partitions that the device must have:\n    partitionCount=13\n\n    # the set of defined heaps:\n    allHeaps=\"main\"\n\n    # the partition data move chunk size (must fit in memory):\n    moveDataChunkSize=$(( 256 * MiB ))\n\n    # only call this if you will later use $deviceHeapStart or $deviceHeapEnd:\n    detectBlockDeviceHeapRange\n\n    # the size of partitions configured with the 'min' keyword:\n    #heapMinSize=$(( 8 * MiB ))\n    \n    # the partition alignment:\n    heapAlignment=$(( 1 * MiB ))\n\n}\n\ndevice_setupHeap_main() {\n\n    # the set of contiguous partitions that form this heap, in order of ascending partition start address:\n    heapPartitions=\"$(seq 10 12)\"\n\n    # the disk area (as a sector range) to use for the heap partitions:\n    heapStart=$(parOldEnd 9)        # one past the end of a specific partition\n    heapEnd=$deviceHeapEnd          # one past the last usable sector of the device\n\n}\n"
  },
  {
    "path": "device/tuna/maguro.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### maguro\n\n# This port was possible thanks to the invaluable help of thagringo.\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:maguro:*) ;;\n        *:tuna:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/tuna/toro.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### toro\n\n# This port was possible thanks to the invaluable help of thagringo and musical_chairs.\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:toro:*) ;;\n        *:tuna:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device/tuna/toroplus.sh",
    "content": "#####################################################\n# Lanchon REPIT - Device Handler                    #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### toroplus\n\n# This port was possible thanks to the invaluable help of thagringo and musical_chairs.\n\ndevice_checkDevice() {\n\n    checkTool getprop\n\n    case \":$(getprop ro.product.device):$(getprop ro.build.product):\" in\n        *:toroplus:*) ;;\n        *:tuna:*) ;;\n        *)\n            fatal \"this package is for '$deviceName' devices; this device is '$(getprop ro.product.device)'\"\n            ;;\n    esac\n\n}\n"
  },
  {
    "path": "device-dump/.gitignore",
    "content": "/repit-dump.log\n/repit-dump-out.txt\n/dumps\n"
  },
  {
    "path": "device-dump/README.md",
    "content": "#### How To Dump Your Device To Request A New Port\n\n- get a recent TWRP running on your device.\n- copy '[repit-dump.zip] (https://github.com/Lanchon/REPIT/raw/master/device-dump/repit-dump.zip)' to your device and flash it.\n- pull to your PC a file called 'repit-dump.log' that was generated in the same folder that holds 'repit-dump.zip'.\n- go [here] (https://github.com/Lanchon/REPIT/issues/new) and create a new issue:\n  - attach the pulled 'repit-dump.log' file.\n  - add the following information:\n    - your exact device and device codename.\n    - your recovery (version? official? if not where did you get it?).\n    - your kernel.\n    - your rom.\n    - is your device running the stock partition layout or is it already modified?\n\n#### How To Dump Via Sideload\n\n- adb sideload repit-dump.zip\n- adb pull /tmp/repit-dump.log\n\n**thank you!**\n"
  },
  {
    "path": "device-dump/dump.sh",
    "content": "#!/sbin/sh\n\n#####################################################\n# Lanchon REPIT                                     #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\nrun() {\n    echo \"==========================================================================================================\"\n    echo \"$@\"\n    echo \"----------------------------------------------------------------------------------------------------------\"\n    \"$@\"\n    local code=$?\n    echo\n    return $code\n}\n\nrun getprop ro.product.device\nrun grep ro.product.device default.prop\n\nrun getprop ro.build.product\nrun grep ro.build.product default.prop\n\ncheckTool() {\n    echo \"$1:\"\n    echo \"        $(which \"$1\")\"\n}\n\ncheckTools() {\n\n    checkTool parted\n    checkTool sort\n    checkTool blockdev\n    checkTool sed\n    checkTool awk\n    checkTool readlink\n    checkTool basename\n    checkTool dirname\n    checkTool dd\n\n    checkTool fdisk\n    checkTool gdisk\n    checkTool sfdisk\n    checkTool sgdisk\n\n    #checkTools_fs_ext4\n    #checkTools_fs_vfat\n    #checkTools_fs_raw\n\n}\n\ncheckTools_fs_ext4() {\n    checkTool mke2fs\n    checkTool e2fsck\n    checkTool resize2fs\n}\n\ncheckTools_fs_vfat() {\n    checkTool mkdosfs\n    checkTool mkfs.fat\n    checkTool dosfsck\n    checkTool fsck.fat\n}\n\ncheckTools_fs_f2fs() {\n    checkTool mkfs.f2fs\n    checkTool fsck.f2fs\n}\n\ncheckTools_fs_swap() {\n    checkTool mkswap\n}\n\ncheckTools_fs_raw() {\n    :\n}\n\nrun checkTools\n\nrun checkTools_fs_ext4\nrun checkTools_fs_vfat\nrun checkTools_fs_f2fs\nrun checkTools_fs_swap\nrun checkTools_fs_raw\n\nrun ls -l /sys/block/mmcblk0\n\nrun parted -s /dev/block/mmcblk0 unit MiB print free unit s print free\nrun sgdisk /dev/block/mmcblk0 --set-alignment 1 --print\n\nrun getprop\nrun cat /default.prop\n\nrun env\nrun set\n\nrun ls -lR /sbin\n\nrun ls -l /dev/block\nrun ls -l /sys/block\n\nfor device in /dev/block/*; do\n    run parted -s \"$device\" unit MiB print free unit s print free &&\n    run sgdisk \"$device\" --set-alignment 1 --print\ndone\n\nrun ls -lR /dev/block\nrun ls -lR /sys/block\n\n#run ls -lR /dev\n#run ls -lR /sys\n"
  },
  {
    "path": "device-dump/make-zip",
    "content": "#!/bin/bash\n\nset -e\n\nunsignedZip=\"repit-dump-unsigned.zip\"\nsignedZip=\"repit-dump.zip\"\n\nrm -f \"$unsignedZip\"\nrm -f \"$signedZip\"\n\nflashize-env dump.sh ../env/arm.zip \"$unsignedZip\" repit-dump.log\nsignapk -w ../key/testkey.x509.pem ../key/testkey.pk8 \"$unsignedZip\" \"$signedZip\"\n\n#rm \"$unsignedZip\"\n"
  },
  {
    "path": "device-dump/run-dump",
    "content": "#!/bin/bash\n\nset -e\n\necho \"pushing to device...\"\nadb push dump.sh /tmp/\necho\n\necho \"running...\"\nadb shell sh /tmp/dump.sh >repit-dump.log\n"
  },
  {
    "path": "device-dump/run-dump.bat",
    "content": "@echo off\r\n\r\necho pushing to device...\r\nadb push dump.sh /tmp/\r\necho.\r\n\r\necho running...\r\nadb shell sh /tmp/dump.sh >repit-dump.log\r\n"
  },
  {
    "path": "key/testkey.x509.pem",
    "content": "-----BEGIN CERTIFICATE-----\nMIIEqDCCA5CgAwIBAgIJAJNurL4H8gHfMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD\nVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4g\nVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UE\nAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe\nFw0wODAyMjkwMTMzNDZaFw0zNTA3MTcwMTMzNDZaMIGUMQswCQYDVQQGEwJVUzET\nMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4G\nA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9p\nZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZI\nhvcNAQEBBQADggENADCCAQgCggEBANaTGQTexgskse3HYuDZ2CU+Ps1s6x3i/waM\nqOi8qM1r03hupwqnbOYOuw+ZNVn/2T53qUPn6D1LZLjk/qLT5lbx4meoG7+yMLV4\nwgRDvkxyGLhG9SEVhvA4oU6Jwr44f46+z4/Kw9oe4zDJ6pPQp8PcSvNQIg1QCAcy\n4ICXF+5qBTNZ5qaU7Cyz8oSgpGbIepTYOzEJOmc3Li9kEsBubULxWBjf/gOBzAzU\nRNps3cO4JFgZSAGzJWQTT7/emMkod0jb9WdqVA2BVMi7yge54kdVMxHEa5r3b97s\nzI5p58ii0I54JiCUP5lyfTwE/nKZHZnfm644oLIXf6MdW2r+6R8CAQOjgfwwgfkw\nHQYDVR0OBBYEFEhZAFY9JyxGrhGGBaR0GawJyowRMIHJBgNVHSMEgcEwgb6AFEhZ\nAFY9JyxGrhGGBaR0GawJyowRoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UE\nCBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMH\nQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAG\nCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJAJNurL4H8gHfMAwGA1Ud\nEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAHqvlozrUMRBBVEY0NqrrwFbinZa\nJ6cVosK0TyIUFf/azgMJWr+kLfcHCHJsIGnlw27drgQAvilFLAhLwn62oX6snb4Y\nLCBOsVMR9FXYJLZW2+TcIkCRLXWG/oiVHQGo/rWuWkJgU134NDEFJCJGjDbiLCpe\n+ZTWHdcwauTJ9pUbo8EvHRkU3cYfGmLaLfgn9gP+pWA7LFQNvXwBnDa6sppCccEX\n31I828XzgXpJ4O+mDL1/dBd+ek8ZPUP0IgdyZm5MTYPhvVqGCHzzTy3sIeJFymwr\nsBbmg2OAUNLEMO6nwmocSdN2ClirfxqCzJOLSDE4QyS9BAH6EhY6UFcOaE0=\n-----END CERTIFICATE-----\n"
  },
  {
    "path": "make",
    "content": "#!/bin/bash\n\nset -e\n\nmakeZip() {\n\n    local device=\"$1\"\n\n    echo \"device: $device\"\n\n    script=\"build/lanchon-repit-$device.sh\"\n    ./make-script \"$device\" \"$script\"\n\n    makeFlashizeEnv=\"$(sed -n \"s/^device_makeFlashizeEnv=\\\"\\(.*\\)\\\"$/\\1/p\" \"$script\")\"\n    if [ -z \"$makeFlashizeEnv\" ]; then\n        >&2 echo \"error: value not found: 'device_makeFlashizeEnv'\"\n        exit 1\n    fi\n\n    makeFilenameConfig=\"$(sed -n \"s/^device_makeFilenameConfig=\\\"\\(.*\\)\\\"$/\\1/p\" \"$script\")\"\n    if [ -z \"$makeFilenameConfig\" ]; then\n        >&2 echo \"error: value not found: 'device_makeFilenameConfig'\"\n        exit 1\n    fi\n\n    unsignedZip=\"build/lanchon-repit-unsigned-$device.zip\"\n    signedZip=\"build/lanchon-repit-$versionShort-$makeFilenameConfig-$device.zip\"\n\n    flashize-env \"$script\" \"$makeFlashizeEnv\" \"$unsignedZip\" /tmp/lanchon-repit.log\n    signapk -w key/testkey.x509.pem key/testkey.pk8 \"$unsignedZip\" \"$signedZip\"\n\n    #rm \"$script\"\n    rm \"$unsignedZip\"\n\n}\n\nmakeOne() {\n\n    local device=\"$1\"\n\n    rm -f build/lanchon-repit*-\"$device\".*\n    makeZip \"$device\"\n\n}\n\nmakeAll() {\n\n    rm -f build/lanchon-repit*\n    local f\n    for file in $(find device -type f -not -path '*/\\.*' -name \"*.sh\"); do\n        local device=\"$(basename \"$file\" .sh)\"\n        if [ \"$device\" != \"common\" ]; then\n            makeZip \"$device\"\n        fi\n    done\n\n}\n\nmake() {\n\n    versionLong=\"$(sed -n \"s/^version=\\\"\\(.*\\)\\\"$/\\1/p\" repit.sh)\"\n    if [ -z \"$versionLong\" ]; then\n        >&2 echo \"error: value not found: 'version'\"\n        exit 1\n    fi\n    versionShort=\"$(echo \"$versionLong\" | sed \"s/-//g\")\"\n\n    echo \"version: $versionLong\"\n\n    mkdir -p build\n    if [ $# -eq 0 ]; then\n        makeAll\n    else\n        while [ $# -ne 0 ]; do\n            makeOne \"$1\"\n            shift\n        done\n    fi\n\n}\n\nmake \"$@\"\n"
  },
  {
    "path": "make-script",
    "content": "#!/bin/bash\n\nset -e\n\ncatCommonScripts() {\n\n    local dir=\"$(dirname \"$1\")\"\n\n    if [ \"$dir\" != \".\" ]; then\n\n        catCommonScripts \"$dir\"\n\n        local commonScript=\"$dir/common.sh\"\n        if [ -f \"$commonScript\" ]; then\n            >>\"$out\" cat \"$commonScript\"\n            >>\"$out\" echo\n        fi\n\n    fi\n\n}\n\nmakeScript() {\n\n    device=\"$1\"\n    out=\"${2:-build/lanchon-repit-$device.sh}\"\n\n    deviceScript=\"$(find device -name \"$device.sh\")\"\n\n    if [ \"$device\" == \"common\" ] || [ ! -f \"$deviceScript\" ]; then\n        >&2 echo \"error: invalid device: '$device'\"\n        exit 1\n    fi\n\n    rm -f \"$out\"\n\n    >>\"$out\" cat repit.sh\n    >>\"$out\" echo\n    >>\"$out\" cat repit-par-tools.sh\n    >>\"$out\" echo\n\n    >>\"$out\" cat repit-fs-ext4.sh\n    >>\"$out\" echo\n    >>\"$out\" cat repit-fs-vfat.sh\n    >>\"$out\" echo\n    >>\"$out\" cat repit-fs-f2fs.sh\n    >>\"$out\" echo\n    >>\"$out\" cat repit-fs-swap.sh\n    >>\"$out\" echo\n    >>\"$out\" cat repit-fs-raw.sh\n    >>\"$out\" echo\n\n    catCommonScripts \"$deviceScript\"\n    >>\"$out\" cat \"$deviceScript\"\n    >>\"$out\" echo\n\n    >>\"$out\" echo \"#####################################################\"\n    >>\"$out\" echo\n    >>\"$out\" printf 'deviceName=%q\\n' \"$device\"\n    >>\"$out\" echo\n    >>\"$out\" echo 'main \"$@\"'\n\n}\n\nmakeScript \"$@\"\n"
  },
  {
    "path": "repit-fs-ext4.sh",
    "content": "#####################################################\n# Lanchon REPIT - File System Handler               #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### ext4\n\ncheckTools_fs_ext4() {\n    # only require tools if actually needed\n    #checkTool mke2fs\n    #checkTool e2fsck\n    #checkTool resize2fs\n    :\n}\n\nprocessPar_ext4_wipe_dry() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    info \"will format the partition in ext4 and trim it\"\n    checkTool mke2fs\n\n}\n\nprocessPar_ext4_wipe_wet() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    local footerSize=$(parFooterSize $n)\n    local newFsSize=$(( newSize - footerSize ))\n\n    processParRecreate $n $oldStart $oldSize $newStart $newSize\n    processParWipeCryptoFooter $n $newStart $newSize $footerSize\n    info \"formatting the partition in ext4 and trimming it\"\n    mke2fs -q -t ext4 -E discard $dev ${newFsSize}s\n\n}\n\ncheckFs_ext4() {\n\n    local n=$1\n    local dev=$2\n\n    info \"checking and trimming the file system\"\n    (set +e; e2fsck -fp -E discard $dev)\n    case \"$?\" in\n        0)\n            ;;\n        1)\n            info \"file system errors in $(parName $n) were fixed\"\n            ;;\n        2|3)\n            info \"file system errors in $(parName $n) were fixed, but a reboot is needed before continuing\"\n            fatal \"reboot needed: please reboot and retry the process to continue\"\n            ;;\n        *)\n            fatal \"file system errors in $(parName $n) could not be automatically fixed (try running 'e2fsck -f $dev')\"\n            ;;\n    esac    \n\n}\n\ncheckParSize_ext4() {\n\n    local n=$1\n    local dev=$2\n    local oldSize=$3\n    local newSize=$4\n\n    local footerSize=$(parFooterSize $n)\n    local newFsSize=$(( newSize - footerSize ))\n\n    #if [ $(( newSize < oldSize )) -ne 0 ]; then\n    #if [ $(( newFsSize < oldSize )) -ne 0 ]; then\n    if true; then\n        info \"validating the new partition size\"\n        local blockSize=$(tune2fs -l $dev 2>/dev/null | sed -n \"s/^Block size:[ ]*\\([0-9]*\\)[ ]*$/\\1/p\")\n        if [ -n \"$blockSize\" ]; then\n            #info \"file system block size: $blockSize bytes\"\n            local minBlocks=$(resize2fs -P $dev 2>/dev/null | sed -n \"s/^Estimated minimum size of the filesystem:[ ]*\\([0-9]*\\)[ ]*$/\\1/p\")\n            if [ -n \"$minBlocks\" ]; then\n                local minSize=$(( ( blockSize / sectorSize ) * minBlocks ))\n                info \"estimated minimum file system size: $(printSizeMiB $minSize)\"\n                local newFsFree=$(( newFsSize - minSize ))\n                if [ $(( newFsFree >= 0 )) -ne 0 ]; then\n                    info \"estimated free space after resize: $(printSizeMiB $newFsFree)\"\n                else\n                    fatal \"the new partition size is estimated to be too small to hold the current contents of the file system by $(printSizeMiB $(( -newFsFree )) )\"\n                fi\n            else\n                warning \"partition size validation skipped: cannot estimate the minimum file system size\"\n            fi\n        else\n            warning \"partition size validation skipped: cannot determine the file system block size\"\n        fi\n    fi\n\n}\n\nprocessPar_ext4_keep_dry() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    if [ $(( newStart != oldStart )) -ne 0 ]; then\n        info \"will move the ext4 partition\"\n        warning \"moving a big ext4 partition can take a very long time; it requires copying the complete partition, including its free space\"\n    fi\n    if [ $(( newSize != oldSize )) -ne 0 ]; then\n        info \"will resize the ext4 partition\"\n        #checkTool resize2fs\n    fi\n    if [ $(( newSize == oldSize )) -ne 0 ]; then\n        info \"will resize the ext4 file system if needed to fit its partition\"\n        #checkTool resize2fs\n    fi\n    checkTool e2fsck\n    checkTool resize2fs\n    checkFs_ext4 $n $dev\n    checkParSize_ext4 $n $dev $oldSize $newSize\n\n}\n\nprocessPar_ext4_keep_wet() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    local footerSize=$(parFooterSize $n)\n    local newFsSize=$(( newSize - footerSize ))\n\n    # note: REPIT should not be able to start on encrypted phones due to the block device being locked.\n\n    local moveSize=$oldSize\n    if [ $(( newSize < oldSize )) -ne 0 ]; then\n        info \"shrinking the ext4 file system\"\n        resize2fs -f $dev ${newFsSize}s\n        info \"shrinking the partition entry\"\n        processParRecreate $n $oldStart $oldSize $oldStart $newSize\n        processParWipeCryptoFooter $n $oldStart $newSize $footerSize\n        checkFs_ext4 $n $dev\n        moveSize=$newSize\n    fi\n    if [ $(( newStart != oldStart )) -ne 0 ]; then\n        info \"moving the ext4 partition\"\n        processParMove $n $oldStart $newStart $moveSize\n        checkFs_ext4 $n $dev\n    fi\n    if [ $(( newSize > oldSize )) -ne 0 ]; then\n        info \"enlarging the partition entry\"\n        processParRecreate $n $newStart $oldSize $newStart $newSize\n        processParWipeCryptoFooter $n $newStart $newSize $footerSize\n        info \"enlarging the ext4 file system\"\n        resize2fs -f $dev ${newFsSize}s\n        checkFs_ext4 $n $dev\n    fi\n    if [ $(( newSize == oldSize )) -ne 0 ]; then\n        info \"resizing the ext4 file system if needed to fit its partition\"\n        resize2fs -f $dev ${newFsSize}s\n        checkFs_ext4 $n $dev\n    fi\n\n}\n"
  },
  {
    "path": "repit-fs-f2fs.sh",
    "content": "#####################################################\n# Lanchon REPIT - File System Handler               #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### f2fs\n\ncheckTools_fs_f2fs() {\n    # only require tools if actually needed\n    #checkTool mkfs.f2fs\n    #checkTool fsck.f2fs\n    :\n}\n\nprocessPar_f2fs_wipe_dry() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    info \"will format the partition in f2fs and trim it\"\n    checkTool mkfs.f2fs\n\n}\n\nprocessPar_f2fs_wipe_wet() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    local footerSize=$(parFooterSize $n)\n    local newFsSize=$(( newSize - footerSize ))\n\n    processParRecreate $n $oldStart $oldSize $newStart $newSize\n    processParWipeCryptoFooter $n $newStart $newSize $footerSize\n    info \"formatting the partition in f2fs and trimming it\"\n    mkfs.f2fs -t 1 $dev ${newFsSize}\n\n}\n\ncheckFs_f2fs() {\n\n    local n=$1\n    local dev=$2\n\n    if [ -z \"$(which fsck.f2fs)\" ]; then\n\n        warning \"skipping file system check (tool 'fsck.f2fs' is not available)\"\n\n    else\n\n        info \"checking the file system\"\n        if ! fsck.f2fs -f $dev; then\n            fatal \"file system errors in $(parName $n) could not be fixed\"\n        fi\n\n    fi\n\n}\n\nprocessPar_f2fs_keep_dry() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    if [ $(( newSize != oldSize )) -ne 0 ]; then\n        fatal \"cannot resize f2fs partitions\"\n    fi\n    if [ $(( newStart != oldStart )) -ne 0 ]; then\n        info \"will move the f2fs partition\"\n        warning \"moving a big f2fs partition can take a very long time; it requires copying the complete partition, including its free space\"\n    fi\n\n    #checkTool fsck.f2fs\n    checkFs_f2fs $n $dev\n\n}\n\nprocessPar_f2fs_keep_wet() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    if [ $(( newSize != oldSize )) -ne 0 ]; then\n        fatal \"assertion failed: cannot resize f2fs partitions\"\n    fi\n    if [ $(( newStart != oldStart )) -ne 0 ]; then\n        info \"moving the f2fs partition\"\n        processParMove $n $oldStart $newStart $oldSize\n        checkFs_f2fs $n $dev\n    fi\n\n}\n"
  },
  {
    "path": "repit-fs-raw.sh",
    "content": "#####################################################\n# Lanchon REPIT - File System Handler               #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### raw\n\ncheckTools_fs_raw() {\n    # only require tools if actually needed\n    :\n}\n\nprocessPar_raw_wipe_dry() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    fatal \"cannot wipe raw partitions\"\n\n}\n\nprocessPar_raw_keep_dry() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    if [ $(( newSize != oldSize )) -ne 0 ]; then\n        fatal \"cannot resize raw partitions\"\n    fi\n    if [ $(( newStart != oldStart )) -ne 0 ]; then\n        info \"will move the raw partition\"\n    fi\n\n}\n\nprocessPar_raw_keep_wet() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    if [ $(( newSize != oldSize )) -ne 0 ]; then\n        fatal \"assertion failed: cannot resize raw partitions\"\n    fi\n    if [ $(( newStart != oldStart )) -ne 0 ]; then\n        info \"moving the raw partition\"\n        processParMove $n $oldStart $newStart $oldSize\n    fi\n\n}\n"
  },
  {
    "path": "repit-fs-swap.sh",
    "content": "#####################################################\n# Lanchon REPIT - File System Handler               #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### swap\n\ncheckTools_fs_swap() {\n    # only require tools if actually needed\n    #checkTool mkswap\n    :\n}\n\nprocessPar_swap_wipe_dry() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    info \"will format the partition as swap area\"\n    checkTool mkswap\n\n}\n\nprocessPar_swap_wipe_wet() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    processParRecreate $n $oldStart $oldSize $newStart $newSize\n    info \"formatting the partition as swap area\"\n    mkswap $dev\n\n}\n\nprocessPar_swap_keep_dry() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    if [ $(( newStart != oldStart || newSize != oldSize )) -ne 0 ]; then\n        fatal \"cannot move or resize swap partitions \"\\\n\"(it makes no sense, please wipe the partition instead; note that you can still move the contents of any partition by using the 'raw' type)\"\n    fi\n\n}\n\nprocessPar_swap_keep_wet() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    if [ $(( newStart != oldStart || newSize != oldSize )) -ne 0 ]; then\n        fatal \"assertion failed: cannot move or resize swap partitions\"\n    fi\n\n}\n"
  },
  {
    "path": "repit-fs-vfat.sh",
    "content": "#####################################################\n# Lanchon REPIT - File System Handler               #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### vfat\n\ncheckTools_fs_vfat() {\n    # only require tools if actually needed\n    #mkfs_vfat=$(chooseTool mkdosfs mkfs.fat)\n    #fsck_vfat=$(chooseTool dosfsck fsck.fat)\n    :\n}\n\nprocessPar_vfat_wipe_dry() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    info \"will format the partition in vfat\"\n    mkfs_vfat=$(chooseTool mkdosfs mkfs.fat)\n\n}\n\nprocessPar_vfat_wipe_wet() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    processParRecreate $n $oldStart $oldSize $newStart $newSize\n    info \"formatting the partition in vfat\"\n    $mkfs_vfat -I $dev\n\n}\n\ncheckFs_vfat() {\n\n    local n=$1\n    local dev=$2\n\n    info \"checking the file system\"\n    # the -w flag is used here to bound memory use\n    if ! $fsck_vfat -pw $dev; then\n        info \"errors detected, retrying the file system check\"\n        if ! $fsck_vfat -pw $dev; then\n            fatal \"file system errors in $(parName $n) could not be fixed\"\n        fi\n    fi\n\n}\n\nprocessPar_vfat_keep_dry() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    if [ $(( newStart != oldStart || newSize != oldSize )) -ne 0 ]; then\n        info \"will move/resize the vfat partition\"\n    fi\n    fsck_vfat=$(chooseTool dosfsck fsck.fat)\n    checkFs_vfat $@\n\n}\n\nprocessPar_vfat_keep_wet() {\n\n    local n=$1\n    local dev=$2\n    local oldStart=$3\n    local oldSize=$4\n    local newStart=$5\n    local newSize=$6\n\n    if [ $(( newStart != oldStart || newSize != oldSize )) -ne 0 ]; then\n        info \"moving/resizing the vfat partition\"\n        info \"note that the error 'unable to satisfy all constraints on the partition' usually means \"\\\n\"that the new desired partition size would be too small to hold the files already stored in the partition.\"\n        runParted resize $n $newStart $(( newStart + newSize - 1 ))\n        rereadParTable\n        checkFs_vfat $@\n    fi\n\n}\n"
  },
  {
    "path": "repit-par-tools.sh",
    "content": "#####################################################\n# Lanchon REPIT - Generic Partition Tools           #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\n### recreate partition\n\nprocessParRecreate() {\n\n    local n=$1\n    local oldStart=$2\n    local oldSize=$3\n    local newStart=$4\n    local newSize=$5\n\n    if [ $(( newStart != oldStart || newSize != oldSize )) -ne 0 ]; then\n\n        info \"deleting current partition\"\n        runParted rm $n\n\n        info \"creating new partition\"\n        if ! runParted mkpart primary $newStart $(( newStart + newSize - 1 )); then\n            info \"attempting to restore previous partition\"\n            runParted mkpart primary $oldStart $(( oldStart + oldSize - 1 ))\n            info \"naming the partition\"\n            runParted name $n $(parGet $n pname)\n            rereadParTable\n            fatal \"unable to create new partition (previous partition was successfully restored)\"\n        fi\n\n        info \"naming the partition\"\n        runParted name $n $(parGet $n pname)\n        rereadParTable\n\n    fi\n\n}\n\nprocessParWipeCryptoFooter() {\n\n    local n=$1\n    local start=$2\n    local size=$3\n    local footerSize=$4\n\n    if [ $(( footerSize != 0 )) -ne 0 ]; then\n\n        local footerStart=$(( start + size - footerSize ))\n\n        info \"creating a temporary partition to wipe the crypto footer due to dd's 4 GiB wraparound bug\"\n        processParRecreate $n $start $size $footerStart $footerSize\n\n        info \"wiping the crypto footer\"\n        dd if=/dev/zero of=${dpar}$n bs=$sectorSize count=$footerSize conv=noerror,sync\n\n        info \"recreating the original partition\"\n        processParRecreate $n 0 0 $start $size\n\n    fi\n\n}\n\n### move partition\n\nmoveDataChunk() {\n\n    local n=$1\n    local oldStart=$2\n    local newStart=$3\n    local size=$4\n\n    echo \"-----  moving $(printSizeMiB $size) chunk: $(printSizeMiB $oldStart) -> $(printSizeMiB $newStart)\"\n\n    # WARNING: dd has a dangerous 4 GiB wraparound bug!!!\n    #dd if=$ddev of=$tchunk bs=$sectorSize skip=$oldStart count=$size conv=noerror,sync\n    #dd if=$tchunk of=$ddev bs=$sectorSize seek=$newStart count=$size conv=noerror,sync\n\n    info \"creating a temporary partition to read chunk at device offset $(printSizeMiB $oldStart)\"\n    runParted mkpart primary $oldStart $(( oldStart + size - 1 ))\n    rereadParTable\n    info \"reading data\"\n    dd if=${dpar}$n of=$tchunk bs=$sectorSize conv=noerror,sync\n    info \"deleting the temporary partition\"\n    runParted rm $n\n\n    info \"creating a temporary partition to write chunk at device offset $(printSizeMiB $newStart)\"\n    runParted mkpart primary $newStart $(( newStart + size - 1 ))\n    rereadParTable\n    info \"writing data\"\n    dd if=$tchunk of=${dpar}$n bs=$sectorSize conv=noerror,sync\n    info \"deleting the temporary partition\"\n    runParted rm $n\n\n    #rereadParTable\n    rm -f $tchunk\n\n    echo\n\n}\n\nmoveData() {\n\n    local pn=$1\n    local oldStart=$2\n    local newStart=$3\n    local size=$4\n\n    local chunk=$moveDataChunkSize\n    local n\n    local m\n\n    if [ $(( newStart < oldStart )) -ne 0 ]; then\n        info \"moving data towards the beginning of the disk\"\n        echo\n        m=0\n        for n in $(seq -- 0 $chunk $(( size - chunk - 1 )) ); do\n            moveDataChunk $pn $(( oldStart + n )) $(( newStart + n )) $chunk\n            m=$(( n + chunk ))\n        done\n        moveDataChunk $pn $(( oldStart + m )) $(( newStart + m )) $(( size - m ))\n    fi\n\n    if [ $(( newStart > oldStart )) -ne 0 ]; then\n        info \"moving data towards the end of the disk\"\n        echo\n        m=$size\n        for n in $(seq -- $(( size - chunk )) $(( - chunk )) 1); do\n            moveDataChunk $pn $(( oldStart + n )) $(( newStart + n )) $chunk\n            m=$n\n        done\n        moveDataChunk $pn $oldStart $newStart $m\n    fi\n\n}\n\nprocessParMove() {\n\n    local n=$1\n    local oldStart=$2\n    local newStart=$3\n    local size=$4\n\n    if [ $(( newStart != oldStart )) -ne 0 ]; then\n\n#rereadParTable\n#echo \"#####  calculating MD5 hash of partition\"\n#md5sum ${dpar}$n\n\n        # this does not work (so we manually dd data around instead)\n        #runParted move $n $newStart $(( newStart + size - 1 ))\n        #rereadParTable\n\n        info \"ensure that the destination partition can be created before starting the move\"\n        processParRecreate $n $oldStart $size $newStart $size\n\n        #info \"deleting the partition to ensure no access to partially moved data if move is interrupted\"\n        info \"deleting the partition to workaround dd's 4 GiB wraparound bug\"\n        runParted rm $n\n        #rereadParTable\n\n        moveData $n $oldStart $newStart $size\n\n        #info \"recreating the partition\"\n        info \"creating the final partition\"\n        runParted mkpart primary $newStart $(( newStart + size - 1 ))\n        info \"naming the partition\"\n        runParted name $n $(parGet $n pname)\n        rereadParTable\n\n##rereadParTable\n#echo \"#####  calculating MD5 hash of partition\"\n#md5sum ${dpar}$n\n\n    fi\n\n}\n"
  },
  {
    "path": "repit.sh",
    "content": "#!/sbin/sh\n\n#####################################################\n# Lanchon REPIT                                     #\n# Copyright 2016, Lanchon                           #\n#####################################################\n\n#####################################################\n# Lanchon REPIT is free software licensed under     #\n# the GNU General Public License (GPL) version 3    #\n# and any later version.                            #\n#####################################################\n\nset -e\n\nversion=\"2017-01-15\"\n\n### logging\n\nfatal() {\n    echo\n    >&2 echo \"FATAL:\" \"$@\"\n    exit 1\n}\n\nwarning() {\n    >&2 echo \"WARNING:\" \"$@\"\n}\n\ninfo() {\n    echo \"info:\" \"$@\"\n}\n\n### helpers\n\nprintSizeMiB() {\n    local size=\"$1\"\n    echo \"$(( (size) / $MiB )) MiB\"\n}\n\ncheckTool() {\n    #info \"checking tool: $1\"\n    if [ -z \"$(which \"$1\")\" ]; then\n        fatal \"required tool '$1' missing (please use a recent version of TWRP to run this package)\"\n    fi\n}\n\nchooseTool() {\n    #info \"choosing tool: $*\"\n    local tool\n    for tool in \"$@\"; do\n        if [ -n \"$(which \"$tool\")\" ]; then\n            echo \"$tool\"\n            return\n        fi\n    done\n    fatal \"all tool alternatives missing: $* (please use a recent version of TWRP to run this package)\"\n}\n\nrunParted() {\n    parted -s $ddev unit s \"$@\"\n}\n\nrereadParTable() {\n    local hint=\"$1\"\n    info \"rereading partition table\"\n    sync\n    blockdev --flushbufs $ddev\n    if ! blockdev --rereadpt $ddev; then\n        fatal \"unable to reread the partition table${hint}\"\n    fi\n    sleep 1\n}\n\ndetectBlockDeviceHeapRange() {\n    info \"determining usable sector range of block device\"\n    checkTool sgdisk\n    local out=\"$(sgdisk \"$ddev\" --set-alignment 1 --print)\"\n    deviceHeapStart=$(echo \"$out\" | sed -n \"s/^First usable sector is[ ]*\\([0-9]*\\)[, ]*last usable sector is[ ]*\\([0-9]*\\)[ ]*$/\\1/p\")\n    deviceHeapEnd=$(echo \"$out\" | sed -n \"s/^First usable sector is[ ]*\\([0-9]*\\)[, ]*last usable sector is[ ]*\\([0-9]*\\)[ ]*$/\\2/p\")\n    if [ -z \"$deviceHeapStart\" ] || [ -z \"$deviceHeapEnd\" ]; then\n        warning \"unable to parse sgdisk output (dump of output follows)\"\n        >&2 echo\n        >&2 echo \"$out\"\n        >&2 echo\n        fatal \"unable to determine usable sector range of block device\"\n    fi\n    deviceHeapEnd=$(( deviceHeapEnd + 1 ))\n}\n\nalignDown() {\n    echo $(( ($1) / heapAlignment * heapAlignment ))\n}\n\nalignUp() {\n    echo $(( (($1) + (heapAlignment - 1)) / heapAlignment * heapAlignment ))\n}\n\n### data store\n\nparOldStart() {\n    cat ${spar}$1/start\n}\n\nparNewStart() {\n    cat ${tpar}$1/start\n}\n\nparOldSize() {\n    cat ${spar}$1/size\n}\n\nparNewSize() {\n    cat ${tpar}$1/size\n}\n\nparFooterSize() {\n    cat ${tpar}$1/footerSize\n}\n\nparNewSizeMinusFooter() {\n    echo $(( $(parNewSize $1) - $(parFooterSize $1) ))\n}\n\nparNewSizeAligned() {\n    cat ${tpar}$1/sizeAligned\n}\n\nparOldEnd() {\n    echo $(( $(parOldStart $1) + $(parOldSize $1) ))\n}\n\nparNewEnd() {\n    echo $(( $(parNewStart $1) + $(parNewSize $1) ))\n}\n\nparNewEndAligned() {\n    echo $(( $(parNewStart $1) + $(parNewSizeAligned $1) ))\n}\n\nparGet() {\n    cat ${tpar}$1/$2\n}\n\nparSet() {\n    echo -n \"$3\" >${tpar}$1/$2\n}\n\nparName() {\n    echo -n \"partition #$1 '$(parGet $1 fname)' ($(parGet $1 pname))\"\n}\n\n### initialization\n\ndetectSideload() {\n\n    local packageName=\"$1\"\n\n    # /tmp/update.zip: old sideload protocol\n    # /sideload/package.zip: current sideload-host protocol\n    if [ \"$1\" == \"/tmp/update.zip\" ] || [ \"$1\" == \"/sideload/package.zip\" ]; then\n        fatal \"adb sideload is not directly supported: it hides the package filename and thus filename-based configuration does not work \"\\\n\"(please adb push the package to '/tmp' and run it from there; or adb sideload it after adding a 'flashize/settings' file to the package containing the desired package filename override)\"\n    fi\n\n}\n\ncheckTools() {\n\n    checkTool parted\n    checkTool sort\n    checkTool blockdev\n    checkTool sed\n    checkTool awk\n    checkTool readlink\n    checkTool basename\n    checkTool dirname\n    checkTool dd\n\n    checkTools_fs_ext4\n    checkTools_fs_vfat\n    checkTools_fs_f2fs\n    checkTools_fs_swap\n    checkTools_fs_raw\n\n}\n\ninitPartitionConf() {\n\n    local n=$1\n    local size=$2\n    local content=$3\n    local fs=$4\n\n    $(parSet $n parsedSize $size)\n    $(parSet $n parsedContent $content)\n    $(parSet $n parsedFs $fs)\n\n}\n\ninitPartition() {\n\n    local n=$1\n    local pname=$2\n    local fname=$3\n    local conf=$4\n    local footerSize=$5\n\n    mkdir -p ${tpar}$n\n\n    $(parSet $n pname $pname)\n    $(parSet $n fname $fname)\n\n    initPartitionConf $n $conf\n\n    $(parSet $n footerSize $footerSize)\n\n    initedPartitions=\"$initedPartitions $n\"\n\n}\n\ninitPartitions() {\n\n    rm -rf $tdir\n\n    initedPartitions=\"\"\n    device_initPartitions\n\n}\n\nparsePartitionConfiguration() {\n\n    local n=$1\n    local packageName=\"$2\"\n\n    local parName=$(parGet $n fname)\n    local conf=\"$(echo -n \"$packageName\" | sed -n \"s/.*-${parName}=\\([^-=]*\\)\\(-.*\\|\\)\\$/\\1/p\")\"\n\n    if [ -n \"$conf\" ]; then\n\n        local regex=\"^\\(\\|[0-9]\\+[GgMm]\\|[0-9]\\+[.][0-9]*[GgMm]\\|[.][0-9]\\+[GgMm]\\|same\\|min\\|max\\)\\(+\\(\\|keep\\|wipe\\)\\(+\\(\\|ext4\\|vfat\\|f2fs\\|swap\\|raw\\)\\)\\?\\)\\?$\"\n\n        if [ -n \"$(echo -n \"$conf\" | sed \"s/$regex//\")\" ]; then\n            fatal \"invalid partition configuration for '$parName': $parName=$conf\"\n        fi\n\n        local val\n        val=\"$(echo -n \"$conf\" | sed -n \"s/$regex/\\1/p\")\"\n        if [ -n \"$val\" ]; then $(parSet $n parsedSize \"$val\"); fi\n        val=\"$(echo -n \"$conf\" | sed -n \"s/$regex/\\3/p\")\"\n        if [ -n \"$val\" ]; then $(parSet $n parsedContent \"$val\"); fi\n        val=\"$(echo -n \"$conf\" | sed -n \"s/$regex/\\5/p\")\"\n        if [ -n \"$val\" ]; then $(parSet $n parsedFs \"$val\"); fi\n\n    fi\n\n}\n\nparsePackageName() {\n\n    local packageName=\"$1\"\n\n    local parNames=\"\"\n    local n\n    for n in $configurablePartitions; do\n        if [ -n \"$parNames\" ]; then\n            parNames=\"$parNames|\"\n        fi\n        parNames=\"$parNames$(parGet $n fname)\"\n    done\n    info \"valid package names: <prefix>[-($parNames)=<conf>]...<suffix>\"\n    info \"valid partition <conf> values: [<size>(G|M)|same|min|max][+[keep|wipe][+[ext4|vfat|f2fs|swap|raw]]]\"\n\n    echo\n    echo \"-----  DEFAULTS  -----\"\n    for n in $configurablePartitions; do\n        #echo \"-$(parGet $n fname)=$(parGet $n parsedSize)+$(parGet $n parsedContent)+$(parGet $n parsedFs)\"\n        echo \"$(parGet $n fname) = size:$(parGet $n parsedSize) + content:$(parGet $n parsedContent) + fs:$(parGet $n parsedFs)\"\n    done\n    echo\n\n    info \"parsing package name\"\n    if [ -z \"$packageName\" ]; then\n        fatal \"unable to retrieve package name\"\n    fi\n    packageName=\"$(basename \"$packageName\" .zip)\"\n    for n in $configurablePartitions; do\n        parsePartitionConfiguration $n $packageName\n    done\n\n    echo\n    echo \"-----  CONFIGURATION  -----\"\n    for n in $initedPartitions; do\n        #echo \"-$(parGet $n fname)=$(parGet $n parsedSize)+$(parGet $n parsedContent)+$(parGet $n parsedFs)\"\n        echo \"$(parGet $n fname) = size:$(parGet $n parsedSize) + content:$(parGet $n parsedContent) + fs:$(parGet $n parsedFs)\"\n    done\n    echo\n\n}\n\ndisableSwap() {\n    #info \"checking tool: swapoff\"\n    if [ -n \"$(which swapoff)\" ]; then\n        info \"disabling swap\"\n        swapoff -a\n    fi\n}\n\ncheckUnmount() {\n\n    local packageName=\"$1\"\n\n    if [ ! -e $ddev ] || [ ! -e $sdev ]; then\n        fatal \"block device not found\"\n    fi\n\n    local hint\n    if [ -f \"$packageName\" ]; then\n        local resolvedPackageName\n        resolvedPackageName=\"$(readlink -f \"$packageName\")\"\n        if [ -z \"$resolvedPackageName\" ]; then\n            resolvedPackageName=\"$packageName\"\n        fi\n        if [ \"$(dirname \"$resolvedPackageName\")\" != \"/tmp\" ]; then\n            info \"copying package to '/tmp'\"\n            cp -f \"$packageName\" \"/tmp/\"\n            hint=\"this package copied itself to '/tmp'; please run it again from there\"\n        else\n            hint=\\\n\"please disable MTP in TWRP's 'Mount' menu (or disconnect from PC), reboot TWRP and run this package again; \"\\\n\"run it immediately after boot up, do not enable USB mass storage; \"\\\n\"note that you might be told to run it yet again from '/tmp'; \"\\\n\"make sure your phone is not encrypted: encrypted phones are not supported\"\n        fi\n    else\n        hint=\"please use TWRP's file manager to copy this package to '/tmp' and run it again from there\"\n    fi\n\n    info \"unmounting all partitions\"\n\n    local dev\n    for dev in $(grep -ow \"^$unmountPattern\" /proc/mounts | sort -u); do\n        if ! umount $dev; then\n            fatal \"unable to unmount all partitions ($hint)\"\n        fi\n    done\n\n    # rereadParTable requires everything unmounted\n    rereadParTable \" ($hint)\"\n\n}\n\ninit() {\n\n    local packageName=\"$1\"\n\n    detectSideload \"$packageName\"\n\n    tdir=/tmp/lanchon-repit\n    tchunk=$tdir/chunk.tmp\n    tpar=$tdir/partition-info/p\n\n    device_init\n    \n    MiB=$((        1024 * 1024 / sectorSize ))      # 1 MiB in sectors\n    GiB=$(( 1024 * 1024 * 1024 / sectorSize ))      # 1 GiB in sectors\n    \n    checkTools\n    initPartitions\n    parsePackageName \"$packageName\"\n    disableSwap\n    checkUnmount \"$packageName\"\n\n}\n\n### setup\n\nsetup() {\n\n    checkTool parted\n    checkTool sort\n    checkTool blockdev\n    checkTool awk\n\n    #info \"unmounting all partitions\"\n    #...\n    #rereadParTable\n\n    heapMinSize=$(( 8 * MiB ))\n\n    device_setup\n\n    info \"checking existing partitions\"\n\n    local n\n    for n in $(seq 1 $partitionCount); do\n        if [ ! -e ${spar}$n ]; then\n            fatal \"partition #$n: not found\"\n        fi\n        if [ $(( $(parOldStart $n) < 0 )) -ne 0 ]; then\n            fatal \"partition #$n: invalid start\"\n        fi\n        if [ $(( $(parOldSize $n) <= 0 )) -ne 0 ]; then\n            fatal \"partition #$n: invalid size\"\n        fi\n    done\n    \n    for n in $(seq $(( partitionCount + 1 )) $(( partitionCount + 100 )) ); do\n        if [ -e ${spar}$n ]; then\n            fatal \"partition #$n: unexpected\"\n        fi\n    done\n\n}\n\nsetupHeapExisting() {\n\n    info \"checking existing partition layout\"\n\n    # TODO: verify that no partitions that are not members of the heap step into the heap area.\n    # TODO: maybe verify that all partitions that are members of the heap are fully contained in the heap area.\n\n    local nPrev=\"\"\n    local gap\n    local n\n    for n in $heapPartitions; do\n        info \"current size: $(parName $n): $(printSizeMiB $(parOldSize $n))\"\n        if [ -z \"$nPrev\" ]; then\n            gap=$(( $(parOldStart $n) - heapStart ))\n            if [ $(( gap < 0 )) -ne 0 ]; then\n                warning \"$(parName $n) starts $(printSizeMiB $(( -(gap) )) ) before the start of heap '$heapName'\"\n            fi\n            gap=$(( $(parOldStart $n) - heapStartAligned ))\n            if [ $(( gap > 0 )) -ne 0 ]; then\n                warning \"$(parName $n) starts $(printSizeMiB $gap) after the aligned start of heap '$heapName'\"\n            fi\n        else\n            gap=$(( $(parOldStart $n) - $(parOldEnd $nPrev) ))\n            if [ $(( gap < 0 )) -ne 0 ]; then\n                fatal \"layout reversal between $(parName $nPrev) and $(parName $n) in heap '$heapName'\"\n            fi\n            gap=$(( $(parOldStart $n) - $(alignUp $(parOldEnd $nPrev)) ))\n            if [ $(( gap > 0 )) -ne 0 ]; then\n                warning \"$(parName $n) starts $(printSizeMiB $gap) after the aligned end of $(parName $nPrev)\"\n            fi\n        fi\n        nPrev=$n\n    done\n    gap=$(( heapEnd - $(parOldEnd $nPrev) ))\n    if [ $(( gap < 0 )) -ne 0 ]; then\n        warning \"$(parName $nPrev) ends $(printSizeMiB $(( -(gap) )) ) after the end of heap '$heapName'\"\n    fi\n    if [ $(( gap >= heapAlignment )) -ne 0 ]; then\n        warning \"$(parName $nPrev) ends $(printSizeMiB $gap) before the end of heap '$heapName'\"\n    fi\n\n}\n\nsetupHeapPartition() {\n\n    local n=$1\n\n    local size=\"$(parGet $n parsedSize)\"\n    local content=\"$(parGet $n parsedContent)\"\n    local fs=\"$(parGet $n parsedFs)\"\n\n    if [ -z \"$size\" ]; then\n        fatal \"$(parName $n): undefined new size\"\n    fi\n    if [ -z \"$content\" ]; then\n        fatal \"$(parName $n): undefined content policy\"\n    fi\n    if [ -z \"$fs\" ]; then\n        fatal \"$(parName $n): undefined file system type\"\n    fi\n\n    case \"$size\" in\n        same)\n            size=$(parOldSize $n)\n            ;;\n        min)\n            size=$heapMinSize\n            ;;\n        max)\n            size=0\n            ;;\n        *)\n            local regex=\"^\\([0-9.]*\\)[ ]*\\([GgMm]\\)\\?$\"\n            local sizeUnit=\"$(echo -n \"$size\" | sed -n \"s/$regex/\\2/p\")\"\n            local size=\"$(echo -n \"$size\" | sed -n \"s/$regex/\\1/p\")\"\n            case \"$sizeUnit\" in\n                M|m)\n                    sizeUnit=$MiB\n                    ;;\n                G|g|*)\n                    sizeUnit=$GiB\n                    ;;\n            esac\n            local sizeGranularity=$(( heapSizeGranularity ))\n            size=$(awk \"BEGIN { print int(($size) * $sizeUnit / $sizeGranularity + 0.5) * $sizeGranularity }\")\n            if [ $(( size < heapSizeGranularity )) -ne 0 ]; then\n                fatal \"$(parName $n): invalid new size\"\n            fi\n            ;;\n    esac\n\n    case \"$content\" in\n        keep)\n            ;;\n        wipe)\n            ;;\n        *)\n            fatal \"$(parName $n): invalid content policy\"\n            ;;\n    esac\n\n    case \"$fs\" in\n        ext4)\n            ;;\n        vfat)\n            ;;\n        f2fs)\n            ;;\n        swap)\n            ;;\n        raw)\n            ;;\n        *)\n            fatal \"$(parName $n): invalid file system type\"\n            ;;\n    esac\n\n    $(parSet $n size $size)\n    $(parSet $n content $content)\n    $(parSet $n fs $fs)\n\n    $(parSet $n sizeAligned $(alignUp $size))\n\n}\n\nsetupHeapNew() {\n\n    info \"checking new partition layout\"\n\n    local n\n    for n in $heapPartitions; do\n        setupHeapPartition $n\n    done\n\n    local sizeAligned=$(( heapEndAligned - heapStartAligned ))\n\n    # correct $sizeAligned in case the size of last partition and the end of heap are both unaligned,\n    # and their combination would lead to an unused area at heap end the size of $heapAlignment or larger.\n    local lastPar=$n\n    local lastParEnd=$(( heapEndAligned - $(parNewSizeAligned $lastPar) + $(parNewSize $lastPar) ))\n    if [ $(( heapEnd - lastParEnd >= heapAlignment )) -ne 0 ]; then\n        sizeAligned=$(( sizeAligned + heapAlignment ))\n    fi\n\n    for n in $heapPartitions; do\n        sizeAligned=$(( sizeAligned - $(parNewSizeAligned $n) ))\n    done\n\n    local maxPar\n    for n in $heapPartitions; do\n        if [ $(( $(parNewSize $n) == 0 )) -ne 0 ]; then\n            if [ -n \"$maxPar\" ]; then\n                fatal \"more than one partition in heap '$heapName' has its size set to 'max'\"\n            fi\n            maxPar=$n\n            local size=$(( sizeAligned / heapSizeGranularity * heapSizeGranularity ))\n            if [ $(( size < heapSizeGranularity )) -ne 0 ]; then\n                fatal \"the new partition layout of heap '$heapName' requires more space than available\"\n            fi\n            $(parSet $n size $size)\n            $(parSet $n sizeAligned $sizeAligned)\n        fi\n        info \"new size: $(parName $n): $(printSizeMiB $(parNewSize $n))\"\n    done\n\n    local nextStart=$heapStartAligned\n    for n in $heapPartitions; do\n        $(parSet $n start $nextStart)\n        nextStart=$(parNewEndAligned $n)\n    done\n\n    gap=$(( heapEnd - $(parNewEnd $lastPar) ))\n    if [ $(( gap < 0 )) -ne 0 ]; then\n        fatal \"the new partition layout of heap '$heapName' requires more space than available\"\n    fi\n    if [ $(( gap >= heapAlignment )) -ne 0 ]; then\n        warning \"there will be $(printSizeMiB $gap) of unused space at the end of heap '$heapName'\"\n    fi\n\n}\n\nsetupHeap() {\n\n    setupHeapExisting\n    setupHeapNew\n\n}\n\nforEachHeap() {\n\n    for heapName in $allHeaps; do\n\n        echo \"#####  processing heap '$heapName'\"\n\n        device_setupHeap_$heapName\n\n        heapStartAligned=$(alignUp $heapStart)\n        heapEndAligned=$(alignDown $heapEnd)\n\n        if [ -z \"$heapSizeGranularity\" ]; then\n            heapSizeGranularity=$heapAlignment\n            \"$@\"\n            heapSizeGranularity=\"\"\n        else\n            \"$@\"\n        fi\n\n    done\n\n}\n\n### execution\n\nprocessPar() {\n\n    local n=$1\n\n    echo \"*****  processing $(parName $n)\"\n\n    eval processPar_$(parGet $n fs)_$(parGet $n content)_$processMode $n ${dpar}$n $(parOldStart $n) $(parOldSize $n) $(parNewStart $n) $(parNewSize $n)\n\n}\n\nprocessParList() {\n\n    local first=$1\n    local rest=${@:2}\n\n    echo \"-----  analyzing $(parName $first)\"\n\n    if [ -z \"$rest\" ]; then\n\n        processPar $first\n\n    else\n\n        local second=$2\n\n        if [ $(( $(parNewEnd $first) > $(parOldStart $second) )) -ne 0 ]; then\n            info \"$(parName $first) will expand into storage area currently used by $(parName $second)\"\n            info \"deferring processing of $(parName $first) until required space is freed\"\n            processParList $rest\n            processPar $first\n        else\n            processPar $first\n            processParList $rest\n        fi\n\n    fi\n\n}\n\nprocessHeap() {\n\n    processMode=$1\n\n    processParList $heapPartitions\n\n}\n\nflushBuffers() {\n\n    info \"flushing buffers\"\n\n    sync\n    blockdev --flushbufs $ddev\n    sleep 3\n\n}\n\n### main\n\nmain() {\n\n    local packageName=\"$1\"\n\n    echo \" ####################################\"\n    echo \"  Lanchon REPIT\"\n    echo \"  A Data-Sparing Repartitioning Tool\"\n    echo \"  Version: $version\"\n    echo \"  Device: $deviceName\"\n    echo \"  Copyright 2016, Lanchon (GPLv3)\"\n    echo \" ####################################\"\n    echo\n\n    echo \"=====  PRELIMINARY CHECKS  =====\"\n    if [ -f \"/tmp/repit-settings\" ]; then\n        packageName=\"$(cat \"/tmp/repit-settings\")\"\n        info \"overriding configuration via '/tmp/repit-settings' to '$packageName'\"\n    elif [ -n \"$FLASHIZE_ENV_VERSION\" ] && [ -f \"/tmp/flashize/repit-settings\" ]; then\n        packageName=\"$(cat \"/tmp/flashize/repit-settings\")\"\n        info \"overriding configuration via 'flashize/repit-settings' to '$packageName'\"\n    fi\n    init \"$packageName\"\n    echo\n\n    echo \"=====  PREPARATION  =====\"\n    setup\n    forEachHeap setupHeap\n    echo\n\n    echo \"=====  DRY-RUN  =====\"\n    forEachHeap processHeap dry\n    echo\n\n    echo \"=====  EXECUTION  =====\"\n    forEachHeap processHeap wet\n    flushBuffers\n    echo\n\n    echo \"=====  SUCCESS  =====\"\n    #echo\n\n}\n"
  },
  {
    "path": "run",
    "content": "#!/bin/bash\n\nset -e\n\ndevice=\"$1\"\nconf=\"$2\"\n\nif [ -e run.conf ]; then\n    source run.conf\nfi\n\nscript=\"build/lanchon-repit-$device.sh\"\n./make-script \"$device\" \"$script\"\n\nadb push \"$script\" /tmp/repit.sh\necho\n\n#adb shell sh -c \".\\ /tmp/flashize/env/setup\\ ;\\ .\\ /tmp/repit.sh\\ /tmp/lanchon-repit-00000000-$conf-$device.zip\"\n\nadb shell <<EOF\n. /tmp/flashize/env/setup &&\n. /tmp/repit.sh /tmp/lanchon-repit-00000000-$conf-$device.zip\nexit\nEOF\n"
  }
]