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

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

Issue 517004: Add a helper script to be able to run "apt-get install" without running (Closed)
Patch Set: Created 11 years 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
2
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
5 # found in the LICENSE file.
6
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"
9 # runs it will make two calls to dpkg like:
10 # dpkg --status-fd ## --unpack --auto-deconfigure /path/to/foo.deb
11 # dpkg --status-fd ## --configure foo
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.
14 #
15 # As a one-off test, you can run like:
16 # apt-get -o="Dir::Bin::dpkg=/path/to/this" install foo
17
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.
20 . "$(dirname "$0")/common.sh"
21
22 # Flags
23 DEFINE_string root "" \
24 "The target rootfs directory in which to install packages."
25 DEFINE_string status_fd "" \
26 "The file descriptor to report status on; ignored."
27 DEFINE_boolean unpack $FLAGS_FALSE "Is the action 'unpack'?"
28 DEFINE_boolean configure $FLAGS_FALSE "Is the action 'configure'?"
29 DEFINE_boolean auto_deconfigure $FLAGS_FALSE "Ignored"
30
31 # Fix up the command line and parse with shflags.
32 FIXED_FLAGS="$@"
33 FIXED_FLAGS=${FIXED_FLAGS/status-fd/status_fd}
34 FIXED_FLAGS=${FIXED_FLAGS/auto-deconfigure/auto_deconfigure}
35 FLAGS $FIXED_FLAGS || exit 1
36 eval set -- "${FLAGS_ARGV}"
37
38 # Die on any errors.
39 set -e
40
41 if [ $FLAGS_configure -eq $FLAGS_TRUE ]; then
42 # We ignore configure requests.
43 exit 0
44 fi
45 if [ $FLAGS_unpack -ne $FLAGS_TRUE ]; then
46 # Ignore unknown command line.
47 echo "Unexpected command line: $@"
48 exit 0
49 fi
50 if [ -z "$FLAGS_root" ]; then
51 echo "Missing root directory."
52 exit 0
53 fi
54
55 DPKG_STATUS=""
56 if [ -d "$FLAGS_root/var/lib/dpkg" ]; then
57 DPKG_STATUS="$FLAGS_root/var/lib/dpkg/status"
58 DPKG_INFO="$FLAGS_root/var/lib/dpkg/info/"
59 fi
60
61 for p in "$@"; do
62 echo "Extracting $p"
63 dpkg-deb --extract "$p" "$FLAGS_root"
64
65 if [ -n "$DPKG_STATUS" ]; then
66 TMPDIR=$(mktemp -d)
67 dpkg-deb --control "$p" "$TMPDIR"
68
69 # Copy the info files
70 PACKAGE=$(dpkg-deb --field "$p" Package)
71 FILES=$(ls "$TMPDIR" | grep -v control)
72 for f in $FILES; do
73 cp "${TMPDIR}/$f" "${DPKG_INFO}/$PACKAGE.$f"
74 done
75
76 # Mark the package as installed successfully.
77 echo "Status: install ok installed" >> "$DPKG_STATUS"
78 cat "${TMPDIR}/control" >> "$DPKG_STATUS"
79 echo "" >> "$DPKG_STATUS"
80
81 rm -rf "$TMPDIR"
82 fi
83 done
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698