blob: c94c65936f72b8138c6ff77a429f398b8980ef3c [file] [log] [blame]
Gabriele Me1983892018-03-02 17:18:08 +01001#!/bin/sh
2
Jackeagle73240362019-01-27 18:07:02 +05303updates_dir=/data/bliss_updates
Gabriele Me1983892018-03-02 17:18:08 +01004
5if [ ! -f "$1" ]; then
6 echo "Usage: $0 ZIP [UNVERIFIED]"
7 echo "Push ZIP to $updates_dir and add it to Updater"
8 echo
Jackeagle73240362019-01-27 18:07:02 +05309 echo "The name of ZIP is assumed to have Bliss-VERSION-CODENAME-TYPE-DATE.* as format"
Gabriele Me1983892018-03-02 17:18:08 +010010 echo "If UNVERIFIED is set, the app will verify the update"
11 exit
12fi
13zip_path=`realpath "$1"`
14
15if [ "`adb get-state 2>/dev/null`" != "device" ]; then
16 echo "No device found. Waiting for one..."
17 adb wait-for-device
18fi
19if ! adb root; then
20 echo "Could not run adbd as root"
21 exit 1
22fi
23
24zip_path_device=$updates_dir/`basename "$zip_path"`
25if adb shell test -f "$zip_path_device"; then
26 echo "$zip_path_device exists already"
27 exit 1
28fi
29
30if [ -n "$2" ]; then
31 status=1
32else
33 status=2
34fi
35
Jackeagle73240362019-01-27 18:07:02 +053036# Assume Bliss-VERSION-CODENAME-TYPE-DATE.zip
Gabriele Me1983892018-03-02 17:18:08 +010037zip_name=`basename "$zip_path"`
38id=`echo "$zip_name" | sha1sum | cut -d' ' -f1`
39version=`echo "$zip_name" | cut -d'-' -f2`
40type=`echo "$zip_name" | cut -d'-' -f4`
41build_date=`echo "$zip_name" | cut -d'-' -f3 | cut -d'_' -f1`
chrmhoffmann29ca6e52020-12-28 11:09:08 +010042if [ "`uname`" = "Darwin" ]; then
Mickey Knox416401a2020-03-05 13:11:39 +010043 timestamp=`date -jf "%Y%m%d %H:%M:%S" "$build_date 23:59:59" +%s`
44 size=`stat -f%z "$zip_path"`
45else
46 timestamp=`date --date="$build_date 23:59:59" +%s`
47 size=`stat -c "%s" "$zip_path"`
48fi
Gabriele Me1983892018-03-02 17:18:08 +010049
50adb push "$zip_path" "$zip_path_device"
51adb shell chgrp cache "$zip_path_device"
52adb shell chmod 664 "$zip_path_device"
53
54# Kill the app before updating the database
Jackeagle73240362019-01-27 18:07:02 +053055adb shell "killall com.blissroms.updater 2>/dev/null"
56adb shell "sqlite3 /data/data/com.blissroms.updater/databases/updates.db" \
Gabriele Me1983892018-03-02 17:18:08 +010057 "\"INSERT INTO updates (status, path, download_id, timestamp, type, version, size)" \
58 " VALUES ($status, '$zip_path_device', '$id', $timestamp, '$type', '$version', $size)\""
Rashed Abdel-Tawab1022c6b2018-07-26 16:47:12 -040059
60# Exit root mode
61adb unroot