Advertisement
Captain_Throwback

patchlevel.sh

Jul 27th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. #!/sbin/sh
  2.  
  3. finish()
  4. {
  5. umount /v
  6. umount /s
  7. rmdir /v
  8. rmdir /s
  9. setprop crypto.ready 1
  10. exit 0
  11. }
  12.  
  13. osver=$(getprop ro.build.version.release_orig)
  14. patchlevel=$(getprop ro.build.version.security_patch_orig)
  15. suffix=$(getprop ro.boot.slot_suffix)
  16.  
  17. if [ -z "$suffix" ]; then
  18. suf=$(getprop ro.boot.slot)
  19. suffix="_$suf"
  20. fi
  21.  
  22. venpath="/dev/block/bootdevice/by-name/vendor$suffix"
  23. mkdir /v
  24. mount -t ext4 -o ro "$venpath" /v
  25. syspath="/dev/block/bootdevice/by-name/system$suffix"
  26. mkdir /s
  27. mount -t ext4 -o ro "$syspath" /s
  28.  
  29. if [ -f /s/system/build.prop ]; then
  30. # TODO: It may be better to try to read these from the boot image than from /system
  31. device=$(grep -i 'ro.product.device' /s/system/build.prop | cut -f2 -d'=')
  32. fingerprint=$(grep -i 'ro.build.fingerprint' /s/system/build.prop | cut -f2 -d'=')
  33. osver=$(grep -i 'ro.build.version.release' /s/system/build.prop | cut -f2 -d'=')
  34. patchlevel=$(grep -i 'ro.build.version.security_patch' /s/system/build.prop | cut -f2 -d'=')
  35. if [ ! -z "$device" ]; then
  36. resetprop ro.product.device "$device"
  37. sed -i "s/ro.product.device=.*/ro.product.device="$device"/g" /prop.default ;
  38. fi
  39. if [ ! -z "$fingerprint" ]; then
  40. resetprop ro.build.fingerprint "$fingerprint"
  41. sed -i "s/ro.build.fingerprint=.*/ro.build.fingerprint="$osver"/g" /prop.default ;
  42. fi
  43. if [ ! -z "$osver" ]; then
  44. resetprop ro.build.version.release "$osver"
  45. sed -i "s/ro.build.version.release=.*/ro.build.version.release="$osver"/g" /prop.default ;
  46. fi
  47. if [ ! -z "$patchlevel" ]; then
  48. resetprop ro.build.version.security_patch "$patchlevel"
  49. sed -i "s/ro.build.version.security_patch=.*/ro.build.version.security_patch="$patchlevel"/g" /prop.default ;
  50. fi
  51. finish
  52. else
  53. # Be sure to increase the PLATFORM_VERSION in build/core/version_defaults.mk to override Google's anti-rollback features to something rather insane
  54. if [ ! -z "$osver" ]; then
  55. resetprop ro.build.version.release "$osver"
  56. sed -i "s/ro.build.version.release=.*/ro.build.version.release="$osver"/g" /prop.default ;
  57. fi
  58. if [ ! -z "$patchlevel" ]; then
  59. resetprop ro.build.version.security_patch "$patchlevel"
  60. sed -i "s/ro.build.version.security_patch=.*/ro.build.version.security_patch="$patchlevel"/g" /prop.default ;
  61. fi
  62. finish
  63. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement