• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# Copyright (C) 2018 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# This script updates SQLite source files with a SQLite tarball.
18#
19# Usage: UPDATE-SOURCE.bash SQLITE-SOURCE.tgz
20#
21# This script must be executed in $ANDROID_BUILD_TOP/external/sqlite/
22#
23
24set -e
25
26script_name="$(basename "$0")"
27
28source_tgz="$1"
29source_ext_dir="$1.extracted"
30
31die() {
32    echo "$script_name: $*"
33    exit 1
34}
35
36echo_and_exec() {
37    echo "  Running: $@"
38    "$@"
39}
40
41# Make sure the source tgz file exists.
42pwd="$(pwd)"
43if [[ ! "$pwd" =~ .*/external/sqlite/? ]] ; then
44    die 'Execute this script in $ANDROID_BUILD_TOP/external/sqlite/'
45fi
46
47# Make sure the source tgz file exists.
48
49if [[ ! -f "$source_tgz" ]] ; then
50    die " Missing or invalid argument.
51
52  Usage: $script_name SQLITE-SOURCE_TGZ
53"
54fi
55
56
57echo
58echo "# Extracting the source tgz..."
59echo_and_exec rm -fr "$source_ext_dir"
60echo_and_exec mkdir -p "$source_ext_dir"
61echo_and_exec tar xvf "$source_tgz" -C "$source_ext_dir" --strip-components=1
62
63echo
64echo "# Making file sqlite3.c in $source_ext_dir ..."
65(
66    cd "$source_ext_dir"
67    echo_and_exec ./configure
68    echo_and_exec make -j 4 sqlite3.c
69)
70
71echo
72echo "# Copying the source files ..."
73for to in dist/orig/ dist/ ; do
74    echo_and_exec cp "$source_ext_dir/"{shell.c,sqlite3.c,sqlite3.h,sqlite3ext.h} "$to"
75done
76
77echo
78echo "# Applying Android.patch ..."
79(
80    cd dist
81    echo_and_exec patch -i Android.patch
82)
83
84echo
85echo "# Regenerating Android.patch ..."
86(
87    cd dist
88    echo_and_exec bash -c '(for x in orig/*; do diff -u -d $x ${x#orig/}; done) > Android.patch'
89)
90
91cat <<EOF
92
93=======================================================
94
95  Finished successfully!
96
97  Make sure to update README.version
98
99=======================================================
100
101EOF
102
103