| OLD | NEW |
| 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_string status_fd "" \ | 25 DEFINE_string status_fd "" \ |
| 26 "The file descriptor to report status on; ignored." | 26 "The file descriptor to report status on; ignored." |
| 27 DEFINE_boolean unpack $FLAGS_FALSE "Is the action 'unpack'?" | 27 DEFINE_boolean unpack $FLAGS_FALSE "Is the action 'unpack'?" |
| 28 DEFINE_boolean configure $FLAGS_FALSE "Is the action 'configure'?" | 28 DEFINE_boolean configure $FLAGS_FALSE "Is the action 'configure'?" |
| 29 DEFINE_boolean remove $FLAGS_FALSE "Is the action 'remove'?" |
| 29 DEFINE_boolean auto_deconfigure $FLAGS_FALSE "Ignored" | 30 DEFINE_boolean auto_deconfigure $FLAGS_FALSE "Ignored" |
| 31 DEFINE_boolean force_depends $FLAGS_FALSE "Ignored" |
| 32 DEFINE_boolean force_remove_essential $FLAGS_FALSE "Ignored" |
| 30 | 33 |
| 31 # Fix up the command line and parse with shflags. | 34 # Fix up the command line and parse with shflags. |
| 32 FIXED_FLAGS="$@" | 35 FIXED_FLAGS="$@" |
| 33 FIXED_FLAGS=${FIXED_FLAGS/status-fd/status_fd} | 36 FIXED_FLAGS=${FIXED_FLAGS/status-fd/status_fd} |
| 34 FIXED_FLAGS=${FIXED_FLAGS/auto-deconfigure/auto_deconfigure} | 37 FIXED_FLAGS=${FIXED_FLAGS/auto-deconfigure/auto_deconfigure} |
| 38 FIXED_FLAGS=${FIXED_FLAGS/force-depends/force_depends} |
| 39 FIXED_FLAGS=${FIXED_FLAGS/force-remove-essential/force_remove_essential} |
| 35 FLAGS $FIXED_FLAGS || exit 1 | 40 FLAGS $FIXED_FLAGS || exit 1 |
| 36 eval set -- "${FLAGS_ARGV}" | 41 eval set -- "${FLAGS_ARGV}" |
| 37 | 42 |
| 38 # Die on any errors. | 43 # Die on any errors. |
| 39 set -e | 44 set -e |
| 40 | 45 |
| 41 if [ $FLAGS_configure -eq $FLAGS_TRUE ]; then | 46 if [ $FLAGS_configure -eq $FLAGS_TRUE ]; then |
| 42 # We ignore configure requests. | 47 # We ignore configure requests. |
| 43 exit 0 | 48 exit 0 |
| 44 fi | 49 fi |
| 50 if [ $FLAGS_remove -eq $FLAGS_TRUE ]; then |
| 51 # We log but ignore remove requests. |
| 52 echo "dpkg_no_scripts, remove: $@" |
| 53 exit 0 |
| 54 fi |
| 45 if [ $FLAGS_unpack -ne $FLAGS_TRUE ]; then | 55 if [ $FLAGS_unpack -ne $FLAGS_TRUE ]; then |
| 46 # Ignore unknown command line. | 56 # Ignore unknown command line. |
| 47 echo "Unexpected command line: $@" | 57 echo "Unexpected command line: $@" |
| 48 exit 0 | 58 exit 0 |
| 49 fi | 59 fi |
| 50 if [ -z "$FLAGS_root" ]; then | 60 if [ -z "$FLAGS_root" ]; then |
| 51 echo "Missing root directory." | 61 echo "Missing root directory." |
| 52 exit 0 | 62 exit 0 |
| 53 fi | 63 fi |
| 54 | 64 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 65 if [ -n "$DPKG_STATUS" ]; then | 75 if [ -n "$DPKG_STATUS" ]; then |
| 66 TMPDIR=$(mktemp -d) | 76 TMPDIR=$(mktemp -d) |
| 67 dpkg-deb --control "$p" "$TMPDIR" | 77 dpkg-deb --control "$p" "$TMPDIR" |
| 68 | 78 |
| 69 # Copy the info files | 79 # Copy the info files |
| 70 PACKAGE=$(dpkg-deb --field "$p" Package) | 80 PACKAGE=$(dpkg-deb --field "$p" Package) |
| 71 FILES=$(ls "$TMPDIR" | grep -v control) | 81 FILES=$(ls "$TMPDIR" | grep -v control) |
| 72 for f in $FILES; do | 82 for f in $FILES; do |
| 73 cp "${TMPDIR}/$f" "${DPKG_INFO}/$PACKAGE.$f" | 83 cp "${TMPDIR}/$f" "${DPKG_INFO}/$PACKAGE.$f" |
| 74 done | 84 done |
| 85 touch "${DPKG_INFO}/$PACKAGE.list" |
| 75 | 86 |
| 76 # Mark the package as installed successfully. | 87 # Mark the package as installed successfully. |
| 77 echo "Status: install ok installed" >> "$DPKG_STATUS" | 88 echo "Status: install ok installed" >> "$DPKG_STATUS" |
| 78 cat "${TMPDIR}/control" >> "$DPKG_STATUS" | 89 cat "${TMPDIR}/control" >> "$DPKG_STATUS" |
| 79 echo "" >> "$DPKG_STATUS" | 90 echo "" >> "$DPKG_STATUS" |
| 80 | 91 |
| 81 rm -rf "$TMPDIR" | 92 rm -rf "$TMPDIR" |
| 82 fi | 93 fi |
| 83 done | 94 done |
| OLD | NEW |