Lanchon / REPIT

A Device-Only Data-Sparing Repartitioning Tool For Android
159 stars 25 forks source link

Regression: empty partition size field no longer accepted after introduction of size units #67

Closed the-gangster closed 7 years ago

the-gangster commented 7 years ago

Hi Lanchon,

in the past Repit was able to be named with only the absolute minimum non-standard parameters for a partition. On the German thread to your Repit tool I published the (undocumented) possibility to also use it for trimming by naming it lanchon-repit-yyyymmdd--i9100.zip. On an i9100 (where the sdcard defaults to =same+keep+vfat) it was possible to use repit.zip for users with ext4-formatted sdcard by simply naming it lanchon-repit-yyyymmdd-sdcard=++ext4-i9100.zip Above doesn't work anymore since your 20160923-builds introduced the size units. They kind of broke the packagename-parsing. I expect this to happen also for any other partition of any supported device, where fallback to default is aimed for the 'size' but 'data' or 'type' parameters are provided, In other words where the partition definition starts with a '+'.

As an example I'll attach a log where I renamed the zip three times, to demonstrate it (my internalSD is vFat). You'll see... lanchon-repit-20160923--i9100.zip (succeeding) lanchon-repit-20160923-sdcard=++vfat-i9100.zip (failing) lanchon-repit-20160923-sdcard=+keep-i9100.zip (failing)

NOTE: This is nothing critical as you can still provide the default value explicitly in the name (e.g. in above examples lanchon-repit-yyyymmdd-sdcard=same++ext4-i9100.zip works as expected on a device with ext4) Currently it is simply no longer an option to drop the size parameter, if any other definition (data or type) for that partition is given. That's all.

recovery-log-with-three-runs-showing-parsingerrors-of-20160923-build.log.txt

Lanchon commented 7 years ago

hi, thanks!

btw, this should work too AFAI remember:

and these should work too, but presumably don't due to this bug:

lol, this is why i didn't want to touch the old code to add units for ages! i knew i would eff up :)

so yes, the bug is where you privately mentioned it is: https://github.com/Lanchon/REPIT/commit/56d11cc04e8226505fac720d427baac0b5e111d4#diff-72c89382cb0c347a91c23ec0bd1693feR241

this is a leftover from an initial implementation that defaulted to GiB units for backwards compatibility. you can see the defaulting code is still there: https://github.com/Lanchon/REPIT/commit/56d11cc04e8226505fac720d427baac0b5e111d4#diff-72c89382cb0c347a91c23ec0bd1693feR488 https://github.com/Lanchon/REPIT/commit/56d11cc04e8226505fac720d427baac0b5e111d4#diff-72c89382cb0c347a91c23ec0bd1693feR495

Lanchon commented 7 years ago

i also wanted to reject "numbers" that entirely consisted of a single dot. so i made this change:

@@ -238,7 +238,7 @@ parsePartitionConfiguration() {

     if [ -n "$conf" ]; then

-        local regex="^\([0-9.]*[GgMm]\|same\|min\|max\)\(+\(\|keep\|wipe\)\(+\(\|ext4\|vfat\|f2fs\|swap\|raw\)\)\?\)\?$"
+        local regex="^\(\|[0-9]\+[GgMm]\|[0-9]\+[.][0-9]*[GgMm]\|[.][0-9]\+[GgMm]\|same\|min\|max\)\(+\(\|keep\|wipe\)\(+\(\|ext4\|vfat\|f2fs\|swap\|raw\)\)\?\)\?$"

         if [ -n "$(echo -n "$conf" | sed "s/$regex//")" ]; then
             fatal "invalid partition configuration for '$parName': $parName=$conf"

but i won't commit because i can't test. i'd be very grateful if you or anybody else with an i9100 could test. size values such as 1G, 1.G, 1.0G, .1G and the empty string should be accepted, and .G and G shouldn't. you can make sure REPIT doesnt touch your phone by adding something foolish like -preload=100G

here is the test build: lanchon-repit-20170114-i9100.zip

thanks again!

the-gangster commented 7 years ago

Hi again, the 20170114-approach looks good. See the enclosed log for details on which variants I tested. Errors in the later processing (once passed the name parsing) have been provoked intentionally as I didn't really want to resize. recovery-log-with-all-size-tests-done-on-20170114-build.log.txt

Thanks for fixing that fast!

Lanchon commented 7 years ago

wow thanks so much!! those were a lot of tests you did! :)

well ill push the code and the new versions tomorrow when im at home. right now out and about :) thanks again!!