diff options
author | lambdadroid | 2018-01-13 15:30:24 +0100 |
---|---|---|
committer | lambdadroid | 2018-01-13 15:32:46 +0100 |
commit | b9a4495088c4a82efe51a7a8fb0a0e6eb8dcce03 (patch) | |
tree | efb8ce6294e0e983553c5f5a52d868cd4bd21fff | |
parent | 65802ce96661d8aa7bafa0a313eba2da50edcef7 (diff) | |
download | aur-b9a4495088c4a82efe51a7a8fb0a0e6eb8dcce03.tar.gz |
me176c-firmware: Copy battery daemon
-rw-r--r-- | .SRCINFO | 6 | ||||
-rw-r--r-- | PKGBUILD | 23 | ||||
-rwxr-xr-x | unpackbootimg.py | 41 |
3 files changed, 66 insertions, 4 deletions
@@ -1,13 +1,17 @@ pkgbase = me176c-firmware pkgdesc = Additional firmware files for the ASUS MeMO Pad 7 (ME176C/CX) pkgver = 12.10.1.36 - pkgrel = 1 + pkgrel = 2 url = https://github.com/me176c-dev/me176c-archlinux arch = x86_64 license = unknown + makedepends = python + makedepends = mkinitcpio options = !strip source = http://dlcdnet.asus.com/pub/ASUS/EeePAD/ME176C/UL-K013-WW-12.10.1.36-user.zip + source = unpackbootimg.py sha256sums = b19a2901bd5920b58bd3693243a9edf433656bcee8f454637ee401e28c096469 + sha256sums = 3eab49bb9c4e1bb890b77a1b2a6762ecb7b628278789caa2efb82f287635503d pkgname = me176c-firmware @@ -1,16 +1,33 @@ # Maintainer: lambdadroid <lambdadroid@gmail.com> pkgname=me176c-firmware pkgver=12.10.1.36 -pkgrel=1 +pkgrel=2 pkgdesc="Additional firmware files for the ASUS MeMO Pad 7 (ME176C/CX)" arch=(x86_64) url="https://github.com/me176c-dev/me176c-archlinux" license=('unknown') +makedepends=('python' 'mkinitcpio') options=('!strip') -source=("http://dlcdnet.asus.com/pub/ASUS/EeePAD/ME176C/UL-K013-WW-$pkgver-user.zip") -sha256sums=('b19a2901bd5920b58bd3693243a9edf433656bcee8f454637ee401e28c096469') +source=( + "http://dlcdnet.asus.com/pub/ASUS/EeePAD/ME176C/UL-K013-WW-$pkgver-user.zip" + 'unpackbootimg.py' +) +sha256sums=('b19a2901bd5920b58bd3693243a9edf433656bcee8f454637ee401e28c096469' + '3eab49bb9c4e1bb890b77a1b2a6762ecb7b628278789caa2efb82f287635503d') + +build() { + # Extract boot image ramdisk + ./unpackbootimg.py boot.img + lsinitcpio -x ramdisk + + # Replace /config with /oemcfg, /config is sometimes used for ConfigFS + sed -i 's@/config/@/oemcfg/@g' sbin/upi_ug31xx +} package() { + # Battery daemon + install -Dm755 sbin/upi_ug31xx "$pkgdir/opt/asus/me176c/upi_ug31xx" + # WiFi NVRAM file install -Dm644 system/etc/nvram.txt "$pkgdir/usr/lib/firmware/brcm/brcmfmac43362-sdio.txt" diff --git a/unpackbootimg.py b/unpackbootimg.py new file mode 100755 index 000000000000..a63b0eef171c --- /dev/null +++ b/unpackbootimg.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +import sys +import struct + +BOOT_MAGIC = 'ANDROID!'.encode() + +HEADER_FORMAT = '8s10I16s512s32s1024s' +HEADER_SIZE = struct.calcsize(HEADER_FORMAT) + +def extract_file(f, name, pos, size): + f.seek(pos) + with open(name, 'wb') as o: + o.write(f.read(size)) + +def unpack_image(f): + header = struct.unpack(HEADER_FORMAT, f.read(HEADER_SIZE)[:HEADER_SIZE]) + + # Ensure this is an Android boot image + if header[0] != BOOT_MAGIC: + print("Image does not appear to be an Android boot image") + exit(1) + + page_size = header[8] + page_mask = page_size - 1 + + # Extract kernel + kernel_size = header[1] + extract_file(f, 'kernel', page_size, kernel_size) + + # Extract ramdisk + ramdisk_size = header[3] + extract_file(f, 'ramdisk', page_size + (kernel_size + page_mask) & ~page_mask, ramdisk_size) + + # Extract command line + cmdline = header[12].decode().rstrip('\0') + header[12].decode().rstrip('\0') + + with open('cmdline.txt', 'w') as o: + o.write(cmdline) + +with open(sys.argv[1], 'rb') as f: + unpack_image(f) |