Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: src/scripts/dpkg_no_scripts.sh

Issue 542097: Move is_whitelisted to the common script so that all users get the previous fix (Closed)
Patch Set: Fix silent failure case Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/scripts/common.sh ('k') | src/scripts/package_script_whitelist.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # This script can be used to replace the "dpkg" binary as far as the 7 # This script can be used to replace the "dpkg" binary as far as the
8 # "apt-get install" command is concerned. When "apt-get install foo" 8 # "apt-get install" command is concerned. When "apt-get install foo"
9 # runs it will make two calls to dpkg like: 9 # runs it will make two calls to dpkg like:
10 # dpkg --status-fd ## --unpack --auto-deconfigure /path/to/foo.deb 10 # dpkg --status-fd ## --unpack --auto-deconfigure /path/to/foo.deb
11 # dpkg --status-fd ## --configure foo 11 # dpkg --status-fd ## --configure foo
12 # This script will extract the .deb file and make it appear to be installed 12 # This script will extract the .deb file and make it appear to be installed
13 # successfully. It will skip the maintainer scripts and configure steps. 13 # successfully. It will skip the maintainer scripts and configure steps.
14 # 14 #
15 # As a one-off test, you can run like: 15 # As a one-off test, you can run like:
16 # apt-get -o="Dir::Bin::dpkg=/path/to/this" install foo 16 # apt-get -o="Dir::Bin::dpkg=/path/to/this" install foo
17 17
18 # Load common constants. This should be the first executable line. 18 # Load common constants. This should be the first executable line.
19 # The path to common.sh should be relative to your script's location. 19 # The path to common.sh should be relative to your script's location.
20 . "$(dirname "$0")/common.sh" 20 . "$(dirname "$0")/common.sh"
21 21
22 # Flags 22 # Flags
23 DEFINE_string root "" \ 23 DEFINE_string root "" \
24 "The target rootfs directory in which to install packages." 24 "The target rootfs directory in which to install packages."
25 DEFINE_boolean dpkg_fallback $FLAGS_TRUE \ 25 DEFINE_boolean dpkg_fallback $FLAGS_TRUE \
26 "Run normal dpkg if maintainer scripts are not whitelisted." 26 "Run normal dpkg if maintainer scripts are not whitelisted."
27 DEFINE_string status_fd "" \ 27 DEFINE_string status_fd "" \
28 "The file descriptor to report status on; ignored." 28 "The file descriptor to report status on; ignored."
29 DEFINE_string whitelist "${SRC_ROOT}/package_scripts/package.whitelist" \
30 "The whitelist file to use."
29 DEFINE_boolean unpack $FLAGS_FALSE "Is the action 'unpack'?" 31 DEFINE_boolean unpack $FLAGS_FALSE "Is the action 'unpack'?"
30 DEFINE_boolean configure $FLAGS_FALSE "Is the action 'configure'?" 32 DEFINE_boolean configure $FLAGS_FALSE "Is the action 'configure'?"
31 DEFINE_boolean remove $FLAGS_FALSE "Is the action 'remove'?" 33 DEFINE_boolean remove $FLAGS_FALSE "Is the action 'remove'?"
32 DEFINE_boolean auto_deconfigure $FLAGS_FALSE "Ignored" 34 DEFINE_boolean auto_deconfigure $FLAGS_FALSE "Ignored"
33 DEFINE_boolean force_depends $FLAGS_FALSE "Ignored" 35 DEFINE_boolean force_depends $FLAGS_FALSE "Ignored"
34 DEFINE_boolean force_remove_essential $FLAGS_FALSE "Ignored" 36 DEFINE_boolean force_remove_essential $FLAGS_FALSE "Ignored"
35 37
36 # Fix up the command line and parse with shflags. 38 # Fix up the command line and parse with shflags.
37 FIXED_FLAGS="$@" 39 FIXED_FLAGS="$@"
38 FIXED_FLAGS=${FIXED_FLAGS/status-fd/status_fd} 40 FIXED_FLAGS=${FIXED_FLAGS/status-fd/status_fd}
39 FIXED_FLAGS=${FIXED_FLAGS/auto-deconfigure/auto_deconfigure} 41 FIXED_FLAGS=${FIXED_FLAGS/auto-deconfigure/auto_deconfigure}
40 FIXED_FLAGS=${FIXED_FLAGS/force-depends/force_depends} 42 FIXED_FLAGS=${FIXED_FLAGS/force-depends/force_depends}
41 FIXED_FLAGS=${FIXED_FLAGS/force-remove-essential/force_remove_essential} 43 FIXED_FLAGS=${FIXED_FLAGS/force-remove-essential/force_remove_essential}
42 FLAGS $FIXED_FLAGS || exit 1 44 FLAGS $FIXED_FLAGS || exit 1
43 eval set -- "${FLAGS_ARGV}" 45 eval set -- "${FLAGS_ARGV}"
44 46
45 # Die on any errors. 47 # Die on any errors.
46 set -e 48 set -e
47 49
48 # Returns true if the input file is whitelisted.
49 #
50 # $1 - The file to check
51 is_whitelisted() {
52 local whitelist="${SRC_ROOT}/package_scripts/package.whitelist"
53 test -f "$whitelist" || return
54
55 local checksum=$(md5sum "$1" | awk '{ print $1 }')
56 local count=$(sed -e "s/#.*$//" "${whitelist}" | grep -c "$checksum" \
57 || /bin/true)
58 test $count -ne 0
59 }
60
61 # Returns true if either of the two given files exist and are not whitelisted. 50 # Returns true if either of the two given files exist and are not whitelisted.
62 # 51 #
63 # $1 - The package name. 52 # $1 - The package name.
64 # $2 - The path to the preinst file if it were to exist. 53 # $2 - The path to the preinst file if it were to exist.
65 # $3 - The path to the postinst file if it were to exist. 54 # $3 - The path to the postinst file if it were to exist.
66 has_missing_whitelist() { 55 has_missing_whitelist() {
67 local package=$1 56 local package=$1
68 local preinst=$2 57 local preinst=$2
69 local postinst=$3 58 local postinst=$3
70 local missing_whitelist=0 59 local missing_whitelist=0
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 touch "${dpkg_info}/${package}.list" # TODO: Proper .list files. 139 touch "${dpkg_info}/${package}.list" # TODO: Proper .list files.
151 140
152 # Mark the package as installed successfully. 141 # Mark the package as installed successfully.
153 echo "Status: install ok installed" >> "$dpkg_status" 142 echo "Status: install ok installed" >> "$dpkg_status"
154 cat "${tmpdir}/control" >> "$dpkg_status" 143 cat "${tmpdir}/control" >> "$dpkg_status"
155 echo "" >> "$dpkg_status" 144 echo "" >> "$dpkg_status"
156 145
157 rm -rf "$tmpdir" 146 rm -rf "$tmpdir"
158 147
159 # Run our maintainer script for this package if we have one. 148 # Run our maintainer script for this package if we have one.
160 local chromium_postinst="${SRC_ROOT}/package_scripts/${package}.preinst" 149 local chromium_preinst="${SRC_ROOT}/package_scripts/${package}.preinst"
161 if [ -f "$chromium_preinst" ]; then 150 if [ -f "$chromium_preinst" ]; then
162 echo "Running: ${chromium_preinst}" 151 echo "Running: ${chromium_preinst}"
163 ROOT="$FLAGS_root" SRC_ROOT="$SRC_ROOT" $chromium_preinst 152 ROOT="$FLAGS_root" SRC_ROOT="$SRC_ROOT" $chromium_preinst
164 fi 153 fi
165 154
166 echo "Unpacking: $p" 155 echo "Unpacking: $p"
167 dpkg-deb --extract "$p" "$FLAGS_root" 156 dpkg-deb --extract "$p" "$FLAGS_root"
168 done 157 done
169 } 158 }
170 159
171 # This script requires at least "--root=" 160 # This script requires at least "--root="
172 if [ -z "$FLAGS_root" ]; then 161 if [ -z "$FLAGS_root" ]; then
173 echo "dpkg_no_scripts: Missing root directory." 162 echo "dpkg_no_scripts: Missing root directory."
174 exit 1 163 exit 1
175 fi 164 fi
176 165
177 if [ $FLAGS_configure -eq $FLAGS_TRUE ]; then 166 if [ $FLAGS_configure -eq $FLAGS_TRUE ]; then
178 do_configure $@ 167 do_configure $@
179 elif [ $FLAGS_unpack -eq $FLAGS_TRUE ]; then 168 elif [ $FLAGS_unpack -eq $FLAGS_TRUE ]; then
180 do_unpack $@ 169 do_unpack $@
181 elif [ $FLAGS_remove -eq $FLAGS_TRUE ]; then 170 elif [ $FLAGS_remove -eq $FLAGS_TRUE ]; then
182 # We log but ignore remove requests. 171 # We log but ignore remove requests.
183 echo "Ignoring remove: $@" 172 echo "Ignoring remove: $@"
184 else 173 else
185 echo "dpkg_no_scripts.sh: Unknown or missing command." 174 echo "dpkg_no_scripts.sh: Unknown or missing command."
186 exit 1 175 exit 1
187 fi 176 fi
188 177
189 exit 0 178 exit 0
OLDNEW
« no previous file with comments | « src/scripts/common.sh ('k') | src/scripts/package_script_whitelist.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698