1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
#!/bin/sh
# create-snapshot - create an upstream snapshot as a tarball w/o unneeded files
#
# Copyright (C) 2013 Canonical Ltd.
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more
# details.
# .
# You should have received a copy of the GNU General Public
# License along with this package; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA
#
# depends: git, xz-utils (xz)
# author: Loïc Minier <loic.minier@ubuntu.com>
ANDROID_TAG="${ANDROID_TAG:-}"
ANDROID_TAG_PATTERN="${ANDROID_TAG_PATTERN:-android-[0-9].*}"
ANDROID_MIRROR="https://android.googlesource.com/"
CORE_REPO="${ANDROID_MIRROR}/platform/system/core"
EXTRAS_REPO="${ANDROID_MIRROR}/platform/system/extras"
LIBHARDWARE_REPO="${ANDROID_MIRROR}/platform/hardware/libhardware"
LIBSELINUX_REPO="${ANDROID_MIRROR}/platform/external/libselinux"
BUILD_REPO="${ANDROID_MIRROR}/platform/build"
GITIGNORE="
*
!.gitignore
!*.indirectionsymlink
!*.[ch]
!*.mk
!NOTICE
!MODULE_LICENSE_*
!/system/
!/system/core/
!/system/core/adb/
!/system/core/fastboot/
!/system/core/fs_mgr/
!/system/core/fs_mgr/include/
!/system/core/include/
!/system/core/include/android/
!/system/core/include/cutils/
!/system/core/include/log/
!/system/core/include/mincrypt/
!/system/core/include/private/
!/system/core/include/utils/
!/system/core/include/zipfile/
!/system/core/liblog/
!/system/core/liblog/tests/
!/system/core/libcutils/
!/system/core/libmincrypt/
!/system/core/libzipfile/
!/system/core/libsparse/
!/system/core/libsparse/include/
!/system/core/libsparse/include/sparse/
!/system/core/libsparse/simg_dump.py
!/system/core/mkbootimg/
!/system/core/mkbootimg/mkbootimg
!/system/extras/
!/system/extras/ext4_utils/
!/system/extras/ext4_utils/mkuserimg.sh
!/system/extras/ext4_utils/test_ext4fixup
!/system/extras/f2fs_utils/
!/hardware/
!/hardware/libhardware/
!/hardware/libhardware/include/
!/hardware/libhardware/include/hardware/
!/external/
!/external/libselinux/
!/external/libselinux/include/
!/external/libselinux/include/selinux/
!/external/libselinux/src/
!/external/f2fs-tools/
!/external/f2fs-tools/include/
!/external/f2fs-tools/lib/
!/external/f2fs-tools/mkfs/
!/build/
!/build/core/
!/build/core/version_defaults.mk
!/build/core/combo/
!/build/core/combo/include/
!/build/core/combo/include/arch/
!/build/core/combo/include/arch/linux-*/
!/build/core/combo/include/arch/linux-*/AndroidConfig.h
"
self="$(basename "$0")"
work_dir=""
log() {
echo "$*" >&2
}
log_i() {
log "I:" "$@"
}
cleanup() {
if [ -n "$work_dir" ]; then
log_i "Cleaning up..."
rm -rf "$work_dir"
fi
}
trap "cleanup" 0 1 2 3 9 11 13 15
work_dir="$(mktemp -dt "$self.XXXXXXXXXX")"
git_latest_tag() {
git for-each-ref --sort='-taggerdate' --format='%(refname:short)' --count=1 "refs/tags/$ANDROID_TAG_PATTERN"
}
git_checkout_some_tag() {
cd "$1"
if [ -z "$ANDROID_TAG" ]; then
ANDROID_TAG=`git_latest_tag`
fi
if ! git checkout "$ANDROID_TAG"; then
log "E: failed to check out $ANDROID_TAG"
exit 1
else
log_i "$1: tag=`git describe`"
rm -rf ".git"
cd -
fi
}
# run from within the android-tools directory
in_work_dir() {
mkdir -p system hardware external
log_i "Cloning core..."
git clone "$CORE_REPO" system/core
git_checkout_some_tag system/core
log_i "Cloning extras..."
git clone "$EXTRAS_REPO" system/extras
git_checkout_some_tag system/extras
log_i "Cloning libhardware..."
git clone "$LIBHARDWARE_REPO" hardware/libhardware
git_checkout_some_tag hardware/libhardware
log_i "Cloning libselinux..."
git clone "$LIBSELINUX_REPO" external/libselinux
git_checkout_some_tag external/libselinux
log_i "Cloning build..."
git clone "$BUILD_REPO"
git_checkout_some_tag build
log_i "Importing in git..."
git init
echo "$GITIGNORE" >.gitignore
git add .
git commit -m "Initial import"
log_i "Committed $ANDROID_TAG: core extras libhardware"
}
oldpwd="$PWD"
cd "$work_dir" && in_work_dir
cd "$oldpwd"
log_i "Creating tarball..."
FULLNAME="android-tools_${ANDROID_TAG#android-}"
GIT_DIR="$work_dir/.git" git archive --format=tar \
--prefix="$FULLNAME/" HEAD | xz >"$FULLNAME.tar.xz"
|