aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorElliott Hughes2016-03-22 23:08:39 -0500
committerElliott Hughes2016-03-22 23:08:39 -0500
commit57eb4fd6e20f53ec80eab66dcd5a0c1cefaa9262 (patch)
tree5a93fba92960ebb5db20abe7d3d5112cf4b1f7a1 /tools
parent867e60db16d2ec687a12e525cf26f203da8396b2 (diff)
downloadplatform-bootable-recovery-57eb4fd6e20f53ec80eab66dcd5a0c1cefaa9262.tar.gz
platform-bootable-recovery-57eb4fd6e20f53ec80eab66dcd5a0c1cefaa9262.tar.xz
platform-bootable-recovery-57eb4fd6e20f53ec80eab66dcd5a0c1cefaa9262.zip
Remove dead tools.
None of these have been touched since cupcake, except to keep them building. Change-Id: I5ed13849e6842e755c62da05f1a8a6da2583b1ee
Diffstat (limited to 'tools')
-rw-r--r--tools/ota/Android.mk33
-rw-r--r--tools/ota/add-property-tag.c141
-rw-r--r--tools/ota/check-lost+found.c145
-rw-r--r--tools/ota/convert-to-bmp.py79
4 files changed, 0 insertions, 398 deletions
diff --git a/tools/ota/Android.mk b/tools/ota/Android.mk
deleted file mode 100644
index 142c3b25..00000000
--- a/tools/ota/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
1# Copyright (C) 2008 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15LOCAL_PATH := $(call my-dir)
16
17include $(CLEAR_VARS)
18LOCAL_FORCE_STATIC_EXECUTABLE := true
19LOCAL_MODULE := add-property-tag
20LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
21LOCAL_MODULE_TAGS := debug
22LOCAL_SRC_FILES := add-property-tag.c
23LOCAL_STATIC_LIBRARIES := libc
24include $(BUILD_EXECUTABLE)
25
26include $(CLEAR_VARS)
27LOCAL_FORCE_STATIC_EXECUTABLE := true
28LOCAL_MODULE := check-lost+found
29LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
30LOCAL_MODULE_TAGS := debug
31LOCAL_SRC_FILES := check-lost+found.c
32LOCAL_STATIC_LIBRARIES := libcutils libc
33include $(BUILD_EXECUTABLE)
diff --git a/tools/ota/add-property-tag.c b/tools/ota/add-property-tag.c
deleted file mode 100644
index aab30b2d..00000000
--- a/tools/ota/add-property-tag.c
+++ /dev/null
@@ -1,141 +0,0 @@
1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <ctype.h>
18#include <errno.h>
19#include <getopt.h>
20#include <limits.h>
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24
25/*
26 * Append a tag to a property value in a .prop file if it isn't already there.
27 * Normally used to modify build properties to record incremental updates.
28 */
29
30// Return nonzero if the tag should be added to this line.
31int should_tag(const char *line, const char *propname) {
32 const char *prop = strstr(line, propname);
33 if (prop == NULL) return 0;
34
35 // Make sure this is actually the property name (not an accidental hit)
36 const char *ptr;
37 for (ptr = line; ptr < prop && isspace(*ptr); ++ptr) ;
38 if (ptr != prop) return 0; // Must be at the beginning of the line
39
40 for (ptr += strlen(propname); *ptr != '\0' && isspace(*ptr); ++ptr) ;
41 return (*ptr == '='); // Must be followed by a '='
42}
43
44// Remove existing tags from the line, return the following number (if any)
45int remove_tag(char *line, const char *tag) {
46 char *pos = strstr(line, tag);
47 if (pos == NULL) return 0;
48
49 char *end;
50 int num = strtoul(pos + strlen(tag), &end, 10);
51 strcpy(pos, end);
52 return num;
53}
54
55// Write line to output with the tag added, adding a number (if >0)
56void write_tagged(FILE *out, const char *line, const char *tag, int number) {
57 const char *end = line + strlen(line);
58 while (end > line && isspace(end[-1])) --end;
59 if (number > 0) {
60 fprintf(out, "%.*s%s%d%s", (int)(end - line), line, tag, number, end);
61 } else {
62 fprintf(out, "%.*s%s%s", (int)(end - line), line, tag, end);
63 }
64}
65
66int main(int argc, char **argv) {
67 const char *filename = "/system/build.prop";
68 const char *propname = "ro.build.fingerprint";
69 const char *tag = NULL;
70 int do_remove = 0, do_number = 0;
71
72 int opt;
73 while ((opt = getopt(argc, argv, "f:p:rn")) != -1) {
74 switch (opt) {
75 case 'f': filename = optarg; break;
76 case 'p': propname = optarg; break;
77 case 'r': do_remove = 1; break;
78 case 'n': do_number = 1; break;
79 case '?': return 2;
80 }
81 }
82
83 if (argc != optind + 1) {
84 fprintf(stderr,
85 "usage: add-property-tag [flags] tag-to-add\n"
86 "flags: -f /dir/file.prop (default /system/build.prop)\n"
87 " -p prop.name (default ro.build.fingerprint)\n"
88 " -r (if set, remove the tag rather than adding it)\n"
89 " -n (if set, add and increment a number after the tag)\n");
90 return 2;
91 }
92
93 tag = argv[optind];
94 FILE *input = fopen(filename, "r");
95 if (input == NULL) {
96 fprintf(stderr, "can't read %s: %s\n", filename, strerror(errno));
97 return 1;
98 }
99
100 char tmpname[PATH_MAX];
101 snprintf(tmpname, sizeof(tmpname), "%s.tmp", filename);
102 FILE *output = fopen(tmpname, "w");
103 if (output == NULL) {
104 fprintf(stderr, "can't write %s: %s\n", tmpname, strerror(errno));
105 return 1;
106 }
107
108 int found = 0;
109 char line[4096];
110 while (fgets(line, sizeof(line), input)) {
111 if (!should_tag(line, propname)) {
112 fputs(line, output); // Pass through unmodified
113 } else {
114 found = 1;
115 int number = remove_tag(line, tag);
116 if (do_remove) {
117 fputs(line, output); // Remove the tag but don't re-add it
118 } else {
119 write_tagged(output, line, tag, number + do_number);
120 }
121 }
122 }
123
124 fclose(input);
125 fclose(output);
126
127 if (!found) {
128 fprintf(stderr, "property %s not found in %s\n", propname, filename);
129 remove(tmpname);
130 return 1;
131 }
132
133 if (rename(tmpname, filename)) {
134 fprintf(stderr, "can't rename %s to %s: %s\n",
135 tmpname, filename, strerror(errno));
136 remove(tmpname);
137 return 1;
138 }
139
140 return 0;
141}
diff --git a/tools/ota/check-lost+found.c b/tools/ota/check-lost+found.c
deleted file mode 100644
index 8ce12d39..00000000
--- a/tools/ota/check-lost+found.c
+++ /dev/null
@@ -1,145 +0,0 @@
1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <dirent.h>
18#include <errno.h>
19#include <fcntl.h>
20#include <limits.h>
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24#include <sys/klog.h>
25#include <sys/reboot.h>
26#include <sys/stat.h>
27#include <sys/types.h>
28#include <time.h>
29#include <unistd.h>
30
31#include "private/android_filesystem_config.h"
32
33// Sentinel file used to track whether we've forced a reboot
34static const char *kMarkerFile = "/data/misc/check-lost+found-rebooted-2";
35
36// Output file in tombstones directory (first 8K will be uploaded)
37static const char *kOutputDir = "/data/tombstones";
38static const char *kOutputFile = "/data/tombstones/check-lost+found-log";
39
40// Partitions to check
41static const char *kPartitions[] = { "/system", "/data", "/cache", NULL };
42
43/*
44 * 1. If /data/misc/forced-reboot is missing, touch it & force "unclean" boot.
45 * 2. Write a log entry with the number of files in lost+found directories.
46 */
47
48int main(int argc __attribute__((unused)), char **argv __attribute__((unused))) {
49 mkdir(kOutputDir, 0755);
50 chown(kOutputDir, AID_SYSTEM, AID_SYSTEM);
51 FILE *out = fopen(kOutputFile, "a");
52 if (out == NULL) {
53 fprintf(stderr, "Can't write %s: %s\n", kOutputFile, strerror(errno));
54 return 1;
55 }
56
57 // Note: only the first 8K of log will be uploaded, so be terse.
58 time_t start = time(NULL);
59 fprintf(out, "*** check-lost+found ***\nStarted: %s", ctime(&start));
60
61 struct stat st;
62 if (stat(kMarkerFile, &st)) {
63 // No reboot marker -- need to force an unclean reboot.
64 // But first, try to create the marker file. If that fails,
65 // skip the reboot, so we don't get caught in an infinite loop.
66
67 int fd = open(kMarkerFile, O_WRONLY|O_CREAT, 0444);
68 if (fd >= 0 && close(fd) == 0) {
69 fprintf(out, "Wrote %s, rebooting\n", kMarkerFile);
70 fflush(out);
71 sync(); // Make sure the marker file is committed to disk
72
73 // If possible, dirty each of these partitions before rebooting,
74 // to make sure the filesystem has to do a scan on mount.
75 int i;
76 for (i = 0; kPartitions[i] != NULL; ++i) {
77 char fn[PATH_MAX];
78 snprintf(fn, sizeof(fn), "%s/%s", kPartitions[i], "dirty");
79 fd = open(fn, O_WRONLY|O_CREAT, 0444);
80 if (fd >= 0) { // Don't sweat it if we can't write the file.
81 TEMP_FAILURE_RETRY(write(fd, fn, sizeof(fn))); // write, you know, some data
82 close(fd);
83 unlink(fn);
84 }
85 }
86
87 reboot(RB_AUTOBOOT); // reboot immediately, with dirty filesystems
88 fprintf(out, "Reboot failed?!\n");
89 exit(1);
90 } else {
91 fprintf(out, "Can't write %s: %s\n", kMarkerFile, strerror(errno));
92 }
93 } else {
94 fprintf(out, "Found %s\n", kMarkerFile);
95 }
96
97 int i;
98 for (i = 0; kPartitions[i] != NULL; ++i) {
99 char fn[PATH_MAX];
100 snprintf(fn, sizeof(fn), "%s/%s", kPartitions[i], "lost+found");
101 DIR *dir = opendir(fn);
102 if (dir == NULL) {
103 fprintf(out, "Can't open %s: %s\n", fn, strerror(errno));
104 } else {
105 int count = 0;
106 struct dirent *ent;
107 while ((ent = readdir(dir))) {
108 if (strcmp(ent->d_name, ".") && strcmp(ent->d_name, ".."))
109 ++count;
110 }
111 closedir(dir);
112 if (count > 0) {
113 fprintf(out, "OMGZ FOUND %d FILES IN %s\n", count, fn);
114 } else {
115 fprintf(out, "%s is clean\n", fn);
116 }
117 }
118 }
119
120 char dmesg[131073];
121 int len = klogctl(KLOG_READ_ALL, dmesg, sizeof(dmesg) - 1);
122 if (len < 0) {
123 fprintf(out, "Can't read kernel log: %s\n", strerror(errno));
124 } else { // To conserve space, only write lines with certain keywords
125 fprintf(out, "--- Kernel log ---\n");
126 dmesg[len] = '\0';
127 char *saveptr, *line;
128 int in_yaffs = 0;
129 for (line = strtok_r(dmesg, "\n", &saveptr); line != NULL;
130 line = strtok_r(NULL, "\n", &saveptr)) {
131 if (strstr(line, "yaffs: dev is")) in_yaffs = 1;
132
133 if (in_yaffs ||
134 strstr(line, "yaffs") ||
135 strstr(line, "mtd") ||
136 strstr(line, "msm_nand")) {
137 fprintf(out, "%s\n", line);
138 }
139
140 if (strstr(line, "yaffs_read_super: isCheckpointed")) in_yaffs = 0;
141 }
142 }
143
144 return 0;
145}
diff --git a/tools/ota/convert-to-bmp.py b/tools/ota/convert-to-bmp.py
deleted file mode 100644
index 446c09da..00000000
--- a/tools/ota/convert-to-bmp.py
+++ /dev/null
@@ -1,79 +0,0 @@
1#!/usr/bin/python2.4
2
3"""A simple script to convert asset images to BMP files, that supports
4RGBA image."""
5
6import struct
7import Image
8import sys
9
10infile = sys.argv[1]
11outfile = sys.argv[2]
12
13if not outfile.endswith(".bmp"):
14 print >> sys.stderr, "Warning: I'm expecting to write BMP files."
15
16im = Image.open(infile)
17if im.mode == 'RGB':
18 im.save(outfile)
19elif im.mode == 'RGBA':
20 # Python Imaging Library doesn't write RGBA BMP files, so we roll
21 # our own.
22
23 BMP_HEADER_FMT = ("<" # little-endian
24 "H" # signature
25 "L" # file size
26 "HH" # reserved (set to 0)
27 "L" # offset to start of bitmap data)
28 )
29
30 BITMAPINFO_HEADER_FMT= ("<" # little-endian
31 "L" # size of this struct
32 "L" # width
33 "L" # height
34 "H" # planes (set to 1)
35 "H" # bit count
36 "L" # compression (set to 0 for minui)
37 "L" # size of image data (0 if uncompressed)
38 "L" # x pixels per meter (1)
39 "L" # y pixels per meter (1)
40 "L" # colors used (0)
41 "L" # important colors (0)
42 )
43
44 fileheadersize = struct.calcsize(BMP_HEADER_FMT)
45 infoheadersize = struct.calcsize(BITMAPINFO_HEADER_FMT)
46
47 header = struct.pack(BMP_HEADER_FMT,
48 0x4d42, # "BM" in little-endian
49 (fileheadersize + infoheadersize +
50 im.size[0] * im.size[1] * 4),
51 0, 0,
52 fileheadersize + infoheadersize)
53
54 info = struct.pack(BITMAPINFO_HEADER_FMT,
55 infoheadersize,
56 im.size[0],
57 im.size[1],
58 1,
59 32,
60 0,
61 0,
62 1,
63 1,
64 0,
65 0)
66
67 f = open(outfile, "wb")
68 f.write(header)
69 f.write(info)
70 data = im.tostring()
71 for j in range(im.size[1]-1, -1, -1): # rows bottom-to-top
72 for i in range(j*im.size[0]*4, (j+1)*im.size[0]*4, 4):
73 f.write(data[i+2]) # B
74 f.write(data[i+1]) # G
75 f.write(data[i+0]) # R
76 f.write(data[i+3]) # A
77 f.close()
78else:
79 print >> sys.stderr, "Don't know how to handle image mode '%s'." % (im.mode,)