mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 14:41:31 +02:00
Get rid of some scripts that are no longer used
Review URL: http://codereview.chromium.org/651083
This commit is contained in:
parent
7c867169b7
commit
0c70b3902e
@ -1,121 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
|
||||||
# found in the LICENSE file.
|
|
||||||
|
|
||||||
# Load common constants. This should be the first executable line.
|
|
||||||
# The path to common.sh should be relative to your script's location.
|
|
||||||
. "$(dirname "$0")/common.sh"
|
|
||||||
|
|
||||||
verbose() {
|
|
||||||
echo "$@"
|
|
||||||
"$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_inside_chroot
|
|
||||||
assert_not_root_user
|
|
||||||
|
|
||||||
# Flags
|
|
||||||
DEFINE_boolean stable $FLAGS_FALSE "Build with stable version of browser."
|
|
||||||
DEFINE_boolean new_build $FLAGS_FALSE "Use chromiumos-build."
|
|
||||||
DEFINE_string architecture i386 "The architecture to build for (--new_build only)." a
|
|
||||||
|
|
||||||
# Fix up the command line and parse with shflags.
|
|
||||||
FIXED_FLAGS="$@"
|
|
||||||
FIXED_FLAGS=${FIXED_FLAGS/new-build/new_build}
|
|
||||||
FLAGS $FIXED_FLAGS || exit 1
|
|
||||||
eval set -- "${FLAGS_ARGV}"
|
|
||||||
|
|
||||||
# Die on error
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Number of jobs for scons calls.
|
|
||||||
NUM_JOBS=`grep -c "^processor" /proc/cpuinfo`
|
|
||||||
|
|
||||||
PLATFORM_DIR="$SRC_ROOT/platform"
|
|
||||||
|
|
||||||
PLATFORM_DIRS="acpi assets fake_hal init installer login_manager \
|
|
||||||
memento_softwareupdate pam_google pam_offline window_manager \
|
|
||||||
cros chrome screenlocker cryptohome \
|
|
||||||
monitor_reconfig microbenchmark minijail metrics_collection \
|
|
||||||
theme metrics_daemon"
|
|
||||||
|
|
||||||
THIRD_PARTY_DIR="$SRC_ROOT/third_party"
|
|
||||||
THIRD_PARTY_PACKAGES="e2fsprogs/files flimflam \
|
|
||||||
gflags google-breakpad gpt gtest gmock \
|
|
||||||
ibus ibus-chewing ibus-anthy ibus-hangul ibus-m17n \
|
|
||||||
ply-image slim/src synaptics \
|
|
||||||
upstart/files wpa_supplicant \
|
|
||||||
xscreensaver/xscreensaver-5.08 xserver-xorg-core \
|
|
||||||
xserver-xorg-video-intel"
|
|
||||||
|
|
||||||
if [ $FLAGS_stable -eq $FLAGS_TRUE ]
|
|
||||||
then
|
|
||||||
# Passed to copy_chrome_zip.sh to get stable version of the browser
|
|
||||||
export GET_STABLE_CHROME=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $FLAGS_new_build -eq $FLAGS_TRUE ]; then
|
|
||||||
# chromiumos-build works out the build order for itself.
|
|
||||||
PACKAGES='dh-chromeos libchrome libchromeos'
|
|
||||||
for PKG in $PLATFORM_DIRS $THIRD_PARTY_PACKAGES; do
|
|
||||||
# Handle some special-case naming.
|
|
||||||
case $PKG in
|
|
||||||
e2fsprogs/files)
|
|
||||||
PACKAGES="$PACKAGES e4fsprogs-git"
|
|
||||||
;;
|
|
||||||
ibus-anthy|ibus-chewing|ibus-hangul)
|
|
||||||
# These are difficult to cross-build right now, and we can live
|
|
||||||
# without them temporarily.
|
|
||||||
if [ "$FLAGS_architecture" = i386 ]; then
|
|
||||||
PACKAGES="$PACKAGES ${PKG%/*}"
|
|
||||||
else
|
|
||||||
echo "WARNING: Skipping $PKG on $FLAGS_architecture"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
PACKAGES="$PACKAGES ${PKG%/*}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
verbose chromiumos-build -a "$FLAGS_architecture" --apt-source $PACKAGES
|
|
||||||
else
|
|
||||||
# Build dh-chromeos really first. Some of third_party needs it.
|
|
||||||
echo "Building package dh-chromeos..."
|
|
||||||
cd "$PLATFORM_DIR/dh-chromeos"
|
|
||||||
./make_pkg.sh
|
|
||||||
cd -
|
|
||||||
|
|
||||||
# Build third_party packages first, since packages and libs depend on them.
|
|
||||||
for i in $THIRD_PARTY_PACKAGES
|
|
||||||
do
|
|
||||||
echo "Building package ${i}..."
|
|
||||||
cd "$THIRD_PARTY_DIR/$i"
|
|
||||||
./make_pkg.sh
|
|
||||||
cd -
|
|
||||||
done
|
|
||||||
|
|
||||||
# Build base lib next, since packages depend on it.
|
|
||||||
echo "Building base library..."
|
|
||||||
cd "$THIRD_PARTY_DIR/chrome"
|
|
||||||
./make_pkg.sh
|
|
||||||
cd -
|
|
||||||
|
|
||||||
#Build common lib next.
|
|
||||||
echo "Building common library..."
|
|
||||||
cd "$SRC_ROOT/common"
|
|
||||||
./make_pkg.sh
|
|
||||||
cd -
|
|
||||||
|
|
||||||
# Build platform packages
|
|
||||||
for i in $PLATFORM_DIRS
|
|
||||||
do
|
|
||||||
echo "Building package ${i}..."
|
|
||||||
cd "$PLATFORM_DIR/$i"
|
|
||||||
./make_pkg.sh
|
|
||||||
cd -
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "All packages built."
|
|
@ -1,262 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
|
||||||
# found in the LICENSE file.
|
|
||||||
|
|
||||||
# Script to customize the root file system after packages have been installed.
|
|
||||||
#
|
|
||||||
# NOTE: This script should be called by build_image.sh. Do not run this
|
|
||||||
# on your own unless you know what you are doing.
|
|
||||||
|
|
||||||
# Load common constants. This should be the first executable line.
|
|
||||||
# The path to common.sh should be relative to your script's location.
|
|
||||||
. "$(dirname "$0")/common.sh"
|
|
||||||
|
|
||||||
# Script must be run inside the chroot
|
|
||||||
assert_inside_chroot
|
|
||||||
|
|
||||||
# Flags
|
|
||||||
DEFINE_string arch "x86" \
|
|
||||||
"The target architecture to build for. One of { x86, arm }."
|
|
||||||
DEFINE_string root "" \
|
|
||||||
"The root file system to customize."
|
|
||||||
|
|
||||||
# Parse command line
|
|
||||||
FLAGS "$@" || exit 1
|
|
||||||
eval set -- "${FLAGS_ARGV}"
|
|
||||||
|
|
||||||
# Die on any errors.
|
|
||||||
set -e
|
|
||||||
|
|
||||||
ROOT_FS_DIR="$FLAGS_root"
|
|
||||||
if [[ -z "$ROOT_FS_DIR" ]]; then
|
|
||||||
echo "Error: --root is required."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ ! -d "$ROOT_FS_DIR" ]]; then
|
|
||||||
echo "Error: Root FS does not exist? ($ROOT_FS_DIR)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Determine default user full username.
|
|
||||||
if [ ${CHROMEOS_OFFICIAL:-0} = 1 ]; then
|
|
||||||
FULLNAME="Google Chrome OS User"
|
|
||||||
else
|
|
||||||
FULLNAME="Chromium OS User"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Determine what password to use for the default user.
|
|
||||||
CRYPTED_PASSWD_FILE="${SCRIPTS_DIR}/shared_user_passwd.txt"
|
|
||||||
if [ -f $CRYPTED_PASSWD_FILE ]; then
|
|
||||||
echo "Using password from $CRYPTED_PASSWD_FILE"
|
|
||||||
CRYPTED_PASSWD=$(cat $CRYPTED_PASSWD_FILE)
|
|
||||||
else
|
|
||||||
# Use a random password. unix_md5_crypt will generate a random salt.
|
|
||||||
echo "Using random password."
|
|
||||||
PASSWORD="$(base64 /dev/urandom | head -1)"
|
|
||||||
CRYPTED_PASSWD="$(echo "$PASSWORD" | openssl passwd -1 -stdin)"
|
|
||||||
PASSWORD="gone now"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set up a default user and add to sudo and the required groups.
|
|
||||||
ADD_USER="chronos"
|
|
||||||
ADD_GROUPS="audio video"
|
|
||||||
SHELL="/bin/sh"
|
|
||||||
if [[ -x "${ROOT_FS_DIR}/bin/bash" ]] ; then
|
|
||||||
SHELL="/bin/bash"
|
|
||||||
fi
|
|
||||||
echo "${ADD_USER}:x:1000:1000:${FULLNAME}:/home/${ADD_USER}/:${SHELL}" | \
|
|
||||||
sudo dd of="${ROOT_FS_DIR}/etc/passwd" conv=notrunc oflag=append
|
|
||||||
echo "${ADD_USER}:${CRYPTED_PASSWD}:14500:0:99999::::" | \
|
|
||||||
sudo dd of="${ROOT_FS_DIR}/etc/shadow" conv=notrunc oflag=append
|
|
||||||
echo "${ADD_USER}:x:1000:" | \
|
|
||||||
sudo dd of="${ROOT_FS_DIR}/etc/group" conv=notrunc oflag=append
|
|
||||||
for i in $ADD_GROUPS; do
|
|
||||||
sudo sed -i "s/^\($i:x:[0-9]*:.*\)/\1,${ADD_USER}/g" \
|
|
||||||
"${ROOT_FS_DIR}"/etc/group
|
|
||||||
done
|
|
||||||
|
|
||||||
sudo mkdir -p "${ROOT_FS_DIR}/home/${ADD_USER}"
|
|
||||||
sudo chown 1000.1000 "${ROOT_FS_DIR}/home/${ADD_USER}"
|
|
||||||
cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/sudoers" conv=notrunc oflag=append
|
|
||||||
%adm ALL=(ALL) ALL
|
|
||||||
$ADD_USER ALL=(ALL) ALL
|
|
||||||
EOF
|
|
||||||
sudo chmod 0440 "${ROOT_FS_DIR}/etc/sudoers"
|
|
||||||
echo "# Allow chronos user to renice processes so that chrome will adjust tab priorities" | \
|
|
||||||
sudo dd of="${ROOT_FS_DIR}/etc/security/limits.conf" conv=notrunc oflag=append
|
|
||||||
echo "chronos hard nice 0" | \
|
|
||||||
sudo dd of="${ROOT_FS_DIR}/etc/security/limits.conf" conv=notrunc oflag=append
|
|
||||||
|
|
||||||
# Set CHROMEOS_VERSION_DESCRIPTION here (uses vars set in chromeos_version.sh)
|
|
||||||
# Was removed from chromeos_version.sh which can also be run outside of chroot
|
|
||||||
# where CHROMEOS_REVISION is set
|
|
||||||
# We have to set (in build_image.sh) and use REAL_USER due to many nested
|
|
||||||
# chroots which lose $USER state.
|
|
||||||
. "${SCRIPTS_DIR}/chromeos_version.sh"
|
|
||||||
if [ ${CHROMEOS_OFFICIAL:-0} = 1 ]; then
|
|
||||||
export CHROMEOS_VERSION_DESCRIPTION="${CHROMEOS_VERSION_STRING} (Official Build ${CHROMEOS_REVISION:?})"
|
|
||||||
elif [ "$REAL_USER" = "chrome-bot" ]
|
|
||||||
then
|
|
||||||
export CHROMEOS_VERSION_DESCRIPTION="${CHROMEOS_VERSION_STRING} (Continuous Build ${CHROMEOS_REVISION:?} - Builder: ${BUILDBOT_BUILD:-"N/A"})"
|
|
||||||
else
|
|
||||||
# Use the $USER passthru via $CHROMEOS_RELEASE_CODENAME
|
|
||||||
export CHROMEOS_VERSION_DESCRIPTION="${CHROMEOS_VERSION_STRING} (Developer Build ${CHROMEOS_REVISION:?} - $(date) - $CHROMEOS_RELEASE_CODENAME)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set google-specific version numbers:
|
|
||||||
# CHROMEOS_RELEASE_CODENAME is the codename of the release.
|
|
||||||
# CHROMEOS_RELEASE_DESCRIPTION is the version displayed by Chrome; see
|
|
||||||
# chrome/browser/chromeos/chromeos_version_loader.cc.
|
|
||||||
# CHROMEOS_RELEASE_NAME is a human readable name for the build.
|
|
||||||
# CHROMEOS_RELEASE_TRACK and CHROMEOS_RELEASE_VERSION are used by the software
|
|
||||||
# update service.
|
|
||||||
# TODO(skrul): Remove GOOGLE_RELEASE once Chromium is updated to look at
|
|
||||||
# CHROMEOS_RELEASE_VERSION for UserAgent data.
|
|
||||||
cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/lsb-release"
|
|
||||||
CHROMEOS_RELEASE_CODENAME=$CHROMEOS_VERSION_CODENAME
|
|
||||||
CHROMEOS_RELEASE_DESCRIPTION=$CHROMEOS_VERSION_DESCRIPTION
|
|
||||||
CHROMEOS_RELEASE_NAME=$CHROMEOS_VERSION_NAME
|
|
||||||
CHROMEOS_RELEASE_TRACK=$CHROMEOS_VERSION_TRACK
|
|
||||||
CHROMEOS_RELEASE_VERSION=$CHROMEOS_VERSION_STRING
|
|
||||||
GOOGLE_RELEASE=$CHROMEOS_VERSION_STRING
|
|
||||||
CHROMEOS_AUSERVER=$CHROMEOS_VERSION_AUSERVER
|
|
||||||
CHROMEOS_DEVSERVER=$CHROMEOS_VERSION_DEVSERVER
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Turn user metrics logging on for official builds only.
|
|
||||||
if [ ${CHROMEOS_OFFICIAL:-0} -eq 1 ]; then
|
|
||||||
sudo touch "${ROOT_FS_DIR}/etc/send_metrics"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set timezone symlink
|
|
||||||
sudo rm -f "${ROOT_FS_DIR}/etc/localtime"
|
|
||||||
sudo ln -s /mnt/stateful_partition/etc/localtime "${ROOT_FS_DIR}/etc/localtime"
|
|
||||||
|
|
||||||
# make a mountpoint for stateful partition
|
|
||||||
sudo mkdir -p "$ROOT_FS_DIR"/mnt/stateful_partition
|
|
||||||
sudo chmod 0755 "$ROOT_FS_DIR"/mnt
|
|
||||||
sudo chmod 0755 "$ROOT_FS_DIR"/mnt/stateful_partition
|
|
||||||
|
|
||||||
# Copy everything from the rootfs_static_data directory to the corresponding
|
|
||||||
# place on the filesystem. Note that this step has to occur after we've
|
|
||||||
# installed all of the packages.
|
|
||||||
TMP_STATIC=$(mktemp -d)
|
|
||||||
sudo cp -r "${SRC_ROOT}/rootfs_static_data/common/." "$TMP_STATIC"
|
|
||||||
# TODO: Copy additional arch-platform-specific subdirectories.
|
|
||||||
sudo chmod -R a+rX "$TMP_STATIC/."
|
|
||||||
sudo cp -r "$TMP_STATIC/." "$ROOT_FS_DIR"
|
|
||||||
sudo rm -rf "$TMP_STATIC"
|
|
||||||
|
|
||||||
# Fix issue where alsa-base (dependency of alsa-utils) is messing up our sound
|
|
||||||
# drivers. The stock modprobe settings worked fine.
|
|
||||||
# TODO: Revisit when we have decided on how sound will work on chromeos.
|
|
||||||
! sudo rm "${ROOT_FS_DIR}/etc/modprobe.d/alsa-base.conf"
|
|
||||||
|
|
||||||
# Remove unneeded fonts.
|
|
||||||
sudo rm -rf "${ROOT_FS_DIR}/usr/share/fonts/X11"
|
|
||||||
|
|
||||||
# The udev daemon takes a long time to start up and settle so we defer it until
|
|
||||||
# after X11 has been started. In order to be able to mount the root file system
|
|
||||||
# and start X we pre-populate some devices. These are copied into /dev by the
|
|
||||||
# chromeos_startup script.
|
|
||||||
# TODO: Hopefully some of this can be taken care of by devtmpfs.
|
|
||||||
DEVICES_DIR="${ROOT_FS_DIR}/lib/chromiumos/devices"
|
|
||||||
sudo mkdir -p "$DEVICES_DIR"/dri
|
|
||||||
sudo mkdir -p "$DEVICES_DIR"/input
|
|
||||||
sudo mkdir -p "$DEVICES_DIR"/pts
|
|
||||||
sudo mkdir -p "$DEVICES_DIR"/shm
|
|
||||||
sudo ln -sf /proc/self/fd "$DEVICES_DIR"/fd
|
|
||||||
sudo ln -sf /proc/self/fd/0 "$DEVICES_DIR"/stdin
|
|
||||||
sudo ln -sf /proc/self/fd/1 "$DEVICES_DIR"/stdout
|
|
||||||
sudo ln -sf /proc/self/fd/2 "$DEVICES_DIR"/stderr
|
|
||||||
sudo mknod --mode=0600 "$DEVICES_DIR"/initctl p
|
|
||||||
sudo mknod --mode=0640 "$DEVICES_DIR"/mem c 1 1
|
|
||||||
sudo mknod --mode=0666 "$DEVICES_DIR"/null c 1 3
|
|
||||||
sudo mknod --mode=0666 "$DEVICES_DIR"/zero c 1 5
|
|
||||||
sudo mknod --mode=0666 "$DEVICES_DIR"/random c 1 8
|
|
||||||
sudo mknod --mode=0666 "$DEVICES_DIR"/urandom c 1 9
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/tty0 c 4 0
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/tty1 c 4 1
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/tty2 c 4 2
|
|
||||||
sudo mknod --mode=0666 "$DEVICES_DIR"/tty c 5 0
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/ttyMSM2 c 252 2
|
|
||||||
sudo mknod --mode=0600 "$DEVICES_DIR"/console c 5 1
|
|
||||||
sudo mknod --mode=0666 "$DEVICES_DIR"/ptmx c 5 2
|
|
||||||
sudo mknod --mode=0666 "$DEVICES_DIR"/loop0 b 7 0
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/sda b 8 0
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/sda1 b 8 1
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/sda2 b 8 2
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/sda3 b 8 3
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/sda4 b 8 4
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/sdb b 8 16
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/sdb1 b 8 17
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/sdb2 b 8 18
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/sdb3 b 8 19
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/sdb4 b 8 20
|
|
||||||
sudo mknod --mode=0640 "$DEVICES_DIR"/input/mouse0 c 13 32
|
|
||||||
sudo mknod --mode=0640 "$DEVICES_DIR"/input/mice c 13 63
|
|
||||||
sudo mknod --mode=0640 "$DEVICES_DIR"/input/event0 c 13 64
|
|
||||||
sudo mknod --mode=0640 "$DEVICES_DIR"/input/event1 c 13 65
|
|
||||||
sudo mknod --mode=0640 "$DEVICES_DIR"/input/event2 c 13 66
|
|
||||||
sudo mknod --mode=0640 "$DEVICES_DIR"/input/event3 c 13 67
|
|
||||||
sudo mknod --mode=0640 "$DEVICES_DIR"/input/event4 c 13 68
|
|
||||||
sudo mknod --mode=0640 "$DEVICES_DIR"/input/event5 c 13 69
|
|
||||||
sudo mknod --mode=0640 "$DEVICES_DIR"/input/event6 c 13 70
|
|
||||||
sudo mknod --mode=0640 "$DEVICES_DIR"/input/event7 c 13 71
|
|
||||||
sudo mknod --mode=0640 "$DEVICES_DIR"/input/event8 c 13 72
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/fb0 c 29 0
|
|
||||||
sudo mknod --mode=0660 "$DEVICES_DIR"/dri/card0 c 226 0
|
|
||||||
sudo chown root.tty "$DEVICES_DIR"/tty*
|
|
||||||
sudo chown root.kmem "$DEVICES_DIR"/mem
|
|
||||||
sudo chown root.disk "$DEVICES_DIR"/sda*
|
|
||||||
sudo chown root.video "$DEVICES_DIR"/fb0
|
|
||||||
sudo chown root.video "$DEVICES_DIR"/dri/card0
|
|
||||||
|
|
||||||
# Since we may mount read-only, our mtab should symlink to /proc
|
|
||||||
sudo ln -sf /proc/mounts "${ROOT_FS_DIR}/etc/mtab"
|
|
||||||
|
|
||||||
# For the most part, we use our own set of Upstart jobs that were installed
|
|
||||||
# in /etc/init.chromeos so as not to mingle with jobs installed by various
|
|
||||||
# packages. We fix that up now.
|
|
||||||
sudo cp "${ROOT_FS_DIR}/etc/init/tty2.conf" "${ROOT_FS_DIR}/etc/init.chromeos"
|
|
||||||
sudo rm -rf "${ROOT_FS_DIR}/etc/init"
|
|
||||||
sudo mv "${ROOT_FS_DIR}/etc/init.chromeos" "${ROOT_FS_DIR}/etc/init"
|
|
||||||
|
|
||||||
# By default, xkb writes computed configuration data to
|
|
||||||
# /var/lib/xkb. It can re-use this data to reduce startup
|
|
||||||
# time. In addition, if it fails to write we've observed
|
|
||||||
# keyboard issues. We add a symlink to allow these writes.
|
|
||||||
sudo rm -rf "${ROOT_FS_DIR}/var/lib/xkb"
|
|
||||||
sudo ln -s /var/cache "${ROOT_FS_DIR}/var/lib/xkb"
|
|
||||||
|
|
||||||
# This is needed so that devicekit-disks has a place to
|
|
||||||
# put its sql lite database. Since we do not need to
|
|
||||||
# retain this information across boots, we are just
|
|
||||||
# putting it in /var/tmp
|
|
||||||
sudo rm -rf "${ROOT_FS_DIR}/var/lib/DeviceKit-disks"
|
|
||||||
sudo ln -s /var/tmp "${ROOT_FS_DIR}/var/lib/DeviceKit-disks"
|
|
||||||
|
|
||||||
# dbus-uuidgen writes machine-id to /var/lib/dbus.
|
|
||||||
sudo rm -f "${ROOT_FS_DIR}/var/lib/dbus/machine-id"
|
|
||||||
sudo ln -s /var/cache/machine-id "${ROOT_FS_DIR}/var/lib/dbus/machine-id"
|
|
||||||
|
|
||||||
# Remove pam-mount's default entry in common-auth and common-session
|
|
||||||
sudo sed -i 's/^\(.*pam_mount.so.*\)/#\1/g' "${ROOT_FS_DIR}"/etc/pam.d/common-*
|
|
||||||
|
|
||||||
# A nice fake hostname to keep things happy.
|
|
||||||
echo "localhost" | sudo dd of="${ROOT_FS_DIR}/etc/hostname"
|
|
||||||
|
|
||||||
# Clear the network settings. This must be done last, since it prevents
|
|
||||||
# any subsequent steps from accessing the network.
|
|
||||||
cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/network/interfaces"
|
|
||||||
auto lo
|
|
||||||
iface lo inet loopback
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/resolv.conf"
|
|
||||||
# Use the connman dns proxy.
|
|
||||||
nameserver 127.0.0.1
|
|
||||||
EOF
|
|
||||||
sudo chmod a-wx "${ROOT_FS_DIR}/etc/resolv.conf"
|
|
@ -1,184 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
|
||||||
# found in the LICENSE file.
|
|
||||||
|
|
||||||
# This script can be used to replace the "dpkg" binary as far as the
|
|
||||||
# "apt-get install" command is concerned. When "apt-get install foo"
|
|
||||||
# runs it will make two calls to dpkg like:
|
|
||||||
# dpkg --status-fd ## --unpack --auto-deconfigure /path/to/foo.deb
|
|
||||||
# dpkg --status-fd ## --configure foo
|
|
||||||
# This script will extract the .deb file and make it appear to be installed
|
|
||||||
# successfully. It will skip the maintainer scripts and configure steps.
|
|
||||||
#
|
|
||||||
# As a one-off test, you can run like:
|
|
||||||
# apt-get -o="Dir::Bin::dpkg=/path/to/this" install foo
|
|
||||||
|
|
||||||
# Load common constants. This should be the first executable line.
|
|
||||||
# The path to common.sh should be relative to your script's location.
|
|
||||||
. "$(dirname "$0")/common.sh"
|
|
||||||
|
|
||||||
# Flags
|
|
||||||
DEFINE_string root "" \
|
|
||||||
"The target rootfs directory in which to install packages."
|
|
||||||
DEFINE_boolean dpkg_fallback $FLAGS_TRUE \
|
|
||||||
"Run normal dpkg if maintainer scripts are not whitelisted."
|
|
||||||
DEFINE_string status_fd "" \
|
|
||||||
"The file descriptor to report status on; ignored."
|
|
||||||
DEFINE_string whitelist "${SRC_ROOT}/package_scripts/package.whitelist" \
|
|
||||||
"The whitelist file to use."
|
|
||||||
DEFINE_boolean unpack $FLAGS_FALSE "Is the action 'unpack'?"
|
|
||||||
DEFINE_boolean configure $FLAGS_FALSE "Is the action 'configure'?"
|
|
||||||
DEFINE_boolean remove $FLAGS_FALSE "Is the action 'remove'?"
|
|
||||||
DEFINE_boolean auto_deconfigure $FLAGS_FALSE "Ignored"
|
|
||||||
DEFINE_boolean force_depends $FLAGS_FALSE "Ignored"
|
|
||||||
DEFINE_boolean force_remove_essential $FLAGS_FALSE "Ignored"
|
|
||||||
|
|
||||||
# Fix up the command line and parse with shflags.
|
|
||||||
FIXED_FLAGS="$@"
|
|
||||||
FIXED_FLAGS=${FIXED_FLAGS/status-fd/status_fd}
|
|
||||||
FIXED_FLAGS=${FIXED_FLAGS/auto-deconfigure/auto_deconfigure}
|
|
||||||
FIXED_FLAGS=${FIXED_FLAGS/force-depends/force_depends}
|
|
||||||
FIXED_FLAGS=${FIXED_FLAGS/force-remove-essential/force_remove_essential}
|
|
||||||
FLAGS $FIXED_FLAGS || exit 1
|
|
||||||
eval set -- "${FLAGS_ARGV}"
|
|
||||||
|
|
||||||
# Die on any errors.
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Returns true if either of the two given files exist and are not whitelisted.
|
|
||||||
#
|
|
||||||
# $1 - The package name.
|
|
||||||
# $2 - The path to the preinst file if it were to exist.
|
|
||||||
# $3 - The path to the postinst file if it were to exist.
|
|
||||||
has_missing_whitelist() {
|
|
||||||
local package=$1
|
|
||||||
local preinst=$2
|
|
||||||
local postinst=$3
|
|
||||||
local missing_whitelist=0
|
|
||||||
|
|
||||||
if [ -f "$preinst" ]; then
|
|
||||||
if ! is_whitelisted "$preinst"; then
|
|
||||||
missing_whitelist=1
|
|
||||||
echo "Warning: Missing whitelist entry for ${package}.preinst"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [ -f "$postinst" ]; then
|
|
||||||
if ! is_whitelisted "$postinst"; then
|
|
||||||
missing_whitelist=1
|
|
||||||
echo "Warning: Missing whitelist entry for ${package}.postinst"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
test $missing_whitelist -ne 0
|
|
||||||
}
|
|
||||||
|
|
||||||
do_configure() {
|
|
||||||
local dpkg_info="$FLAGS_root/var/lib/dpkg/info/"
|
|
||||||
local fallback_packages=""
|
|
||||||
|
|
||||||
for p in "$@"; do
|
|
||||||
echo "Configuring: $p"
|
|
||||||
|
|
||||||
# Make sure that any .preinst or .postinst files are whitelisted.
|
|
||||||
local preinst="${dpkg_info}/${p}.preinst"
|
|
||||||
local postinst="${dpkg_info}/${p}.postinst"
|
|
||||||
if has_missing_whitelist "$p" "$preinst" "$postinst"; then
|
|
||||||
if [ $FLAGS_dpkg_fallback -eq $FLAGS_TRUE ]; then
|
|
||||||
echo "** Warning: Will run full maintainer scripts for ${p}."
|
|
||||||
fallback_packages="$fallback_packages $p"
|
|
||||||
continue
|
|
||||||
else
|
|
||||||
# TODO: Eventually should be upgraded to a full error.
|
|
||||||
echo "** Warning: Ignoring missing whitelist for ${p}."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run our maintainer script for this package if we have one.
|
|
||||||
local chromium_postinst="${SRC_ROOT}/package_scripts/${p}.postinst"
|
|
||||||
if [ -f "$chromium_postinst" ]; then
|
|
||||||
echo "Running: $chromium_postinst"
|
|
||||||
ROOT="$FLAGS_root" SRC_ROOT="$SRC_ROOT" $chromium_postinst
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -n "$fallback_packages" ]; then
|
|
||||||
dpkg --root="$FLAGS_root" --configure $fallback_packages
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
do_unpack() {
|
|
||||||
local dpkg_status="$FLAGS_root/var/lib/dpkg/status"
|
|
||||||
local dpkg_info="$FLAGS_root/var/lib/dpkg/info/"
|
|
||||||
|
|
||||||
if [ ! -d "$dpkg_info" ]
|
|
||||||
then
|
|
||||||
mkdir -p "$dpkg_info"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for p in "$@"; do
|
|
||||||
local package=$(dpkg-deb --field "$p" Package)
|
|
||||||
local tmpdir=$(mktemp -d)
|
|
||||||
|
|
||||||
dpkg-deb --control "$p" "$tmpdir"
|
|
||||||
|
|
||||||
local preinst="${tmpdir}/preinst"
|
|
||||||
local postinst="${tmpdir}/postinst"
|
|
||||||
if has_missing_whitelist "$package" "$preinst" "$postinst"; then
|
|
||||||
if [ $FLAGS_dpkg_fallback -eq $FLAGS_TRUE ]; then
|
|
||||||
echo "** Warning: Running full maintainer scripts for ${package}."
|
|
||||||
dpkg --root="$FLAGS_root" --unpack --auto-deconfigure "$p"
|
|
||||||
rm -rf "$tmpdir"
|
|
||||||
continue
|
|
||||||
else
|
|
||||||
# TODO: Eventually should be upgraded to a full error.
|
|
||||||
echo "** Warning: Ignoring missing whitelist for ${p}."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Copy the info files
|
|
||||||
local files=$(ls "$tmpdir" | grep -v control)
|
|
||||||
for f in $files; do
|
|
||||||
cp "${tmpdir}/${f}" "${dpkg_info}/${package}.${f}"
|
|
||||||
done
|
|
||||||
dpkg -c "$p" | sed 's,.* \.\/,/,; s/ -> .*//; s,^/$,/.,; s,/$,,' > \
|
|
||||||
"${dpkg_info}/${package}.list"
|
|
||||||
|
|
||||||
# Mark the package as installed successfully.
|
|
||||||
echo "Status: install ok installed" >> "$dpkg_status"
|
|
||||||
cat "${tmpdir}/control" >> "$dpkg_status"
|
|
||||||
echo "" >> "$dpkg_status"
|
|
||||||
|
|
||||||
rm -rf "$tmpdir"
|
|
||||||
|
|
||||||
# Run our maintainer script for this package if we have one.
|
|
||||||
local chromium_preinst="${SRC_ROOT}/package_scripts/${package}.preinst"
|
|
||||||
if [ -f "$chromium_preinst" ]; then
|
|
||||||
echo "Running: ${chromium_preinst}"
|
|
||||||
ROOT="$FLAGS_root" SRC_ROOT="$SRC_ROOT" $chromium_preinst
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Unpacking: $p"
|
|
||||||
dpkg-deb --extract "$p" "$FLAGS_root"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# This script requires at least "--root="
|
|
||||||
if [ -z "$FLAGS_root" ]; then
|
|
||||||
echo "dpkg_no_scripts: Missing root directory."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $FLAGS_configure -eq $FLAGS_TRUE ]; then
|
|
||||||
do_configure $@
|
|
||||||
elif [ $FLAGS_unpack -eq $FLAGS_TRUE ]; then
|
|
||||||
do_unpack $@
|
|
||||||
elif [ $FLAGS_remove -eq $FLAGS_TRUE ]; then
|
|
||||||
# We log but ignore remove requests.
|
|
||||||
echo "Ignoring remove: $@"
|
|
||||||
else
|
|
||||||
echo "dpkg_no_scripts.sh: Unknown or missing command."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
|
@ -1,313 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
|
||||||
# found in the LICENSE file.
|
|
||||||
|
|
||||||
# Script to install packages into the target root file system.
|
|
||||||
#
|
|
||||||
# NOTE: This script should be called by build_image.sh. Do not run this
|
|
||||||
# on your own unless you know what you are doing.
|
|
||||||
|
|
||||||
# Load common constants. This should be the first executable line.
|
|
||||||
# The path to common.sh should be relative to your script's location.
|
|
||||||
. "$(dirname "$0")/common.sh"
|
|
||||||
|
|
||||||
# Script must be run inside the chroot
|
|
||||||
assert_inside_chroot
|
|
||||||
assert_not_root_user
|
|
||||||
|
|
||||||
DEFAULT_PKGLIST="${SRC_ROOT}/package_repo/package-list-prod.txt"
|
|
||||||
|
|
||||||
# Flags
|
|
||||||
DEFINE_string output_dir "" \
|
|
||||||
"The location of the output directory to use [REQUIRED]."
|
|
||||||
DEFINE_string root "" \
|
|
||||||
"The root file system to install packages in."
|
|
||||||
DEFINE_string arch "x86" \
|
|
||||||
"The target architecture to build for. One of { x86, armel }."
|
|
||||||
DEFINE_string build_root "$DEFAULT_BUILD_ROOT" \
|
|
||||||
"Root of build output"
|
|
||||||
DEFINE_string package_list "$DEFAULT_PKGLIST" \
|
|
||||||
"Comma separated set of package-list files to use."
|
|
||||||
DEFINE_string mirror "$DEFAULT_IMG_MIRROR" \
|
|
||||||
"The upstream package mirror to use."
|
|
||||||
DEFINE_string suite "$DEFAULT_IMG_SUITE" \
|
|
||||||
"The upstream package suite to use."
|
|
||||||
DEFINE_string mirror2 "" "Additional package mirror to use (URL only)."
|
|
||||||
DEFINE_string suite2 "" "Package suite for additional mirror."
|
|
||||||
|
|
||||||
# Parse command line
|
|
||||||
FLAGS "$@" || exit 1
|
|
||||||
eval set -- "${FLAGS_ARGV}"
|
|
||||||
|
|
||||||
# Die on any errors.
|
|
||||||
set -e
|
|
||||||
|
|
||||||
KERNEL_DEB_PATH=$(find "${FLAGS_build_root}/${FLAGS_arch}/local_packages" \
|
|
||||||
-name "linux-image-*.deb")
|
|
||||||
KERNEL_DEB=$(basename "${KERNEL_DEB_PATH}" .deb | sed -e 's/linux-image-//' \
|
|
||||||
-e 's/_.*//')
|
|
||||||
KERNEL_VERSION=${KERNEL_VERSION:-${KERNEL_DEB}}
|
|
||||||
|
|
||||||
if [[ -z "$FLAGS_output_dir" ]]; then
|
|
||||||
echo "Error: --output_dir is required."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
OUTPUT_DIR=$(readlink -f "$FLAGS_output_dir")
|
|
||||||
SETUP_DIR="${OUTPUT_DIR}/local_repo"
|
|
||||||
ROOT_FS_DIR="${OUTPUT_DIR}/rootfs"
|
|
||||||
if [[ -n "$FLAGS_root" ]]; then
|
|
||||||
ROOT_FS_DIR=$(readlink -f "$FLAGS_root")
|
|
||||||
fi
|
|
||||||
mkdir -p "$OUTPUT_DIR" "$SETUP_DIR" "$ROOT_FS_DIR"
|
|
||||||
|
|
||||||
# Make sure anything mounted in the rootfs is cleaned up ok on exit.
|
|
||||||
cleanup_rootfs_mounts() {
|
|
||||||
# Occasionally there are some daemons left hanging around that have our
|
|
||||||
# root image file system open. We do a best effort attempt to kill them.
|
|
||||||
PIDS=`sudo lsof -t "$ROOT_FS_DIR" | sort | uniq`
|
|
||||||
for pid in $PIDS
|
|
||||||
do
|
|
||||||
local cmdline=`cat /proc/$pid/cmdline`
|
|
||||||
echo "Killing process that has open file on our rootfs: $cmdline"
|
|
||||||
! sudo kill $pid # Preceded by ! to disable ERR trap.
|
|
||||||
done
|
|
||||||
|
|
||||||
# Sometimes the volatile directory is left mounted and sometimes it is not,
|
|
||||||
# so we precede by '!' to disable the ERR trap.
|
|
||||||
! sudo umount "$ROOT_FS_DIR"/lib/modules/2.6.*/volatile/ > /dev/null 2>&1
|
|
||||||
|
|
||||||
sudo umount "${ROOT_FS_DIR}/proc"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set up repository for locally built packages; these take highest precedence.
|
|
||||||
mkdir -p "${SETUP_DIR}/local_packages"
|
|
||||||
cp "${FLAGS_build_root}/${FLAGS_arch}/local_packages"/*.deb \
|
|
||||||
"${SETUP_DIR}/local_packages"
|
|
||||||
cd "$SETUP_DIR"
|
|
||||||
dpkg-scanpackages local_packages/ /dev/null | \
|
|
||||||
gzip > local_packages/Packages.gz
|
|
||||||
cd -
|
|
||||||
|
|
||||||
# Create the temporary apt source.list used to install packages.
|
|
||||||
APT_SOURCE="${OUTPUT_DIR}/sources.list"
|
|
||||||
cat <<EOF > "$APT_SOURCE"
|
|
||||||
deb copy:"$SETUP_DIR" local_packages/
|
|
||||||
deb $FLAGS_mirror $FLAGS_suite main restricted multiverse universe
|
|
||||||
EOF
|
|
||||||
if [ -n "$FLAGS_mirror2" ] && [ -n "$FLAGS_suite2" ]; then
|
|
||||||
cat <<EOF >> "$APT_SOURCE"
|
|
||||||
deb $FLAGS_mirror2 $FLAGS_suite2 main restricted multiverse universe
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
# Look for official file and use it if it exists
|
|
||||||
if [ -f ${SRC_ROOT}/package_repo/sources-official.list ]; then
|
|
||||||
cat ${SRC_ROOT}/package_repo/sources-official.list >> "$APT_SOURCE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Cache directory for APT to use. This cache is re-used across builds. We
|
|
||||||
# rely on the cache to reduce traffic to the hosted repositories.
|
|
||||||
APT_CACHE_DIR="${FLAGS_build_root}/apt_cache-${FLAGS_arch}/"
|
|
||||||
mkdir -p "${APT_CACHE_DIR}/archives/partial"
|
|
||||||
|
|
||||||
if [ "${FLAGS_arch}" = x86 ]; then
|
|
||||||
APT_ARCH=i386
|
|
||||||
else
|
|
||||||
APT_ARCH="${FLAGS_arch}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create the apt configuration file. See "man apt.conf"
|
|
||||||
APT_PARTS="${OUTPUT_DIR}/apt.conf.d"
|
|
||||||
mkdir -p "$APT_PARTS" # An empty apt.conf.d to avoid other configs.
|
|
||||||
export APT_CONFIG="${OUTPUT_DIR}/apt.conf"
|
|
||||||
cat <<EOF > "$APT_CONFIG"
|
|
||||||
APT
|
|
||||||
{
|
|
||||||
Install-Recommends "0";
|
|
||||||
Install-Suggests "0";
|
|
||||||
Get
|
|
||||||
{
|
|
||||||
Assume-Yes "1";
|
|
||||||
AllowUnauthenticated "1";
|
|
||||||
};
|
|
||||||
Architecture "${APT_ARCH}";
|
|
||||||
};
|
|
||||||
Dir
|
|
||||||
{
|
|
||||||
Bin {
|
|
||||||
dpkg "${SCRIPTS_DIR}/dpkg_no_scripts.sh";
|
|
||||||
};
|
|
||||||
Cache "$APT_CACHE_DIR";
|
|
||||||
Cache {
|
|
||||||
archives "${APT_CACHE_DIR}/archives";
|
|
||||||
};
|
|
||||||
Etc
|
|
||||||
{
|
|
||||||
sourcelist "$APT_SOURCE";
|
|
||||||
parts "$APT_PARTS";
|
|
||||||
};
|
|
||||||
State "${ROOT_FS_DIR}/var/lib/apt/";
|
|
||||||
State
|
|
||||||
{
|
|
||||||
status "${ROOT_FS_DIR}/var/lib/dpkg/status";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
DPkg
|
|
||||||
{
|
|
||||||
options {"--root=${ROOT_FS_DIR}";};
|
|
||||||
};
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# TODO: Full audit of the apt conf dump to make sure things are ok.
|
|
||||||
apt-config dump > "${OUTPUT_DIR}/apt.conf.dump"
|
|
||||||
|
|
||||||
# We do a rough equivalent to debootstrap that installs the minimal
|
|
||||||
# packages needed to be able to run apt to install the rest. We don't
|
|
||||||
# use debootstrap since it is geared toward having a second stage that
|
|
||||||
# needs to run package maintainer scripts. This is also simpler.
|
|
||||||
|
|
||||||
# The set of required packages before apt can take over.
|
|
||||||
PACKAGES="debconf libacl1 libattr1 libc6 libgcc1 libselinux1"
|
|
||||||
|
|
||||||
# Set of packages that we need to install early so that other packages
|
|
||||||
# maintainer scripts can still basically run.
|
|
||||||
#
|
|
||||||
# login - So that groupadd will work
|
|
||||||
# base-passwd/passwd - So that chmod and useradd/groupadd will work
|
|
||||||
# bash - So that scripts can run
|
|
||||||
# libpam-runtime/libuuid1 - Not exactly sure why
|
|
||||||
# sysv-rc - So that we can overwrite invoke-rc.d, update-rc.d
|
|
||||||
EXTRA_PACKAGES="base-files base-passwd bash libpam-runtime libuuid1 login passwd sysv-rc mawk"
|
|
||||||
|
|
||||||
# Prep the rootfs to work with dpgk and apt
|
|
||||||
sudo mkdir -p "${ROOT_FS_DIR}/var/lib/dpkg/info"
|
|
||||||
sudo touch "${ROOT_FS_DIR}/var/lib/dpkg/available" \
|
|
||||||
"${ROOT_FS_DIR}/var/lib/dpkg/diversions" \
|
|
||||||
"${ROOT_FS_DIR}/var/lib/dpkg/status"
|
|
||||||
sudo mkdir -p "${ROOT_FS_DIR}/var/lib/apt/lists/partial" \
|
|
||||||
"${ROOT_FS_DIR}/var/lib/dpkg/updates"
|
|
||||||
|
|
||||||
# Download the initial packages into the apt cache if necessary.
|
|
||||||
REPO="${APT_CACHE_DIR}/archives"
|
|
||||||
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive apt-get update
|
|
||||||
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \
|
|
||||||
apt-get --download-only install $PACKAGES $EXTRA_PACKAGES
|
|
||||||
|
|
||||||
# Install initial packages directly with dpkg_no_scripts.sh
|
|
||||||
ARCH="$FLAGS_arch"
|
|
||||||
if [ "$ARCH" = "x86" ]; then
|
|
||||||
ARCH="i?86" # Match i386 | i686
|
|
||||||
fi
|
|
||||||
for p in $PACKAGES $EXTRA_PACKAGES; do
|
|
||||||
PKG=$(ls "${REPO}"/${p}_*_$ARCH.deb || /bin/true)
|
|
||||||
if [ -z "$PKG" ]; then
|
|
||||||
PKG=$(ls "${REPO}"/${p}_*_all.deb)
|
|
||||||
fi
|
|
||||||
sudo ARCH="$FLAGS_arch" "${SCRIPTS_DIR}"/dpkg_no_scripts.sh \
|
|
||||||
--root="$ROOT_FS_DIR" --nodpkg_fallback --unpack "$PKG"
|
|
||||||
sudo ARCH="$FLAGS_arch" "${SCRIPTS_DIR}"/dpkg_no_scripts.sh \
|
|
||||||
--root="$ROOT_FS_DIR" --nodpkg_fallback --configure "$p"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Make sure that apt is ready to work. We use --fix-broken to trigger apt
|
|
||||||
# to install additional critical packages. If there are any of these, we
|
|
||||||
# disable the maintainer scripts so they install ok.
|
|
||||||
TMP_FORCE_NO_SCRIPTS="-o=DPkg::options::=--nodpkg_fallback"
|
|
||||||
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive ARCH="$FLAGS_arch"\
|
|
||||||
apt-get $TMP_FORCE_NO_SCRIPTS --force-yes --fix-broken install
|
|
||||||
|
|
||||||
# TODO: Remove these hacks when we stop having maintainer scripts altogether.
|
|
||||||
sudo cp -a /dev/* "${ROOT_FS_DIR}/dev"
|
|
||||||
sudo cp -a /etc/resolv.conf "${ROOT_FS_DIR}/etc/resolv.conf"
|
|
||||||
sudo ln -sf /bin/true "${ROOT_FS_DIR}/usr/sbin/invoke-rc.d"
|
|
||||||
sudo ln -sf /bin/true "${ROOT_FS_DIR}/usr/sbin/update-rc.d"
|
|
||||||
|
|
||||||
# Set up mounts for working within the rootfs. We copy some basic
|
|
||||||
# network information from the host so that maintainer scripts can
|
|
||||||
# access the network as needed.
|
|
||||||
# TODO: All of this rootfs mount stuff can be removed as soon as we stop
|
|
||||||
# running the maintainer scripts on install.
|
|
||||||
sudo mount -t proc proc "${ROOT_FS_DIR}/proc"
|
|
||||||
trap cleanup_rootfs_mounts EXIT
|
|
||||||
|
|
||||||
filter_pkgs() {
|
|
||||||
pkglist="$1"
|
|
||||||
arch="$2"
|
|
||||||
|
|
||||||
# to read list of package + version skipping empty lines and comments, and
|
|
||||||
# convert "foo 1.2-3" to "foo=1.2-3", use:
|
|
||||||
#pkgs="$(grep '^[^#]' "$pkglist" | cut -d ' ' -f 1-2 | sed 's/ /=/')"
|
|
||||||
|
|
||||||
# read list of "package [optional arch list]" skipping empty lines and
|
|
||||||
# comments
|
|
||||||
grep '^[^#]' "$pkglist" | while read pkg archspec; do
|
|
||||||
case "$archspec" in
|
|
||||||
""|"[$arch "*|"[$arch]"|*" $arch]")
|
|
||||||
echo "$pkg"
|
|
||||||
;;
|
|
||||||
*"!$arch "*|*"!$arch]")
|
|
||||||
:
|
|
||||||
;;
|
|
||||||
"["*"!"*"]")
|
|
||||||
echo "$pkg"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Install packages from the given package-lists
|
|
||||||
PACKAGE_LISTS=$(echo "$FLAGS_package_list" | sed -e 's/,/ /g')
|
|
||||||
PKG_LIST_ARCH="$FLAGS_arch"
|
|
||||||
if [ "$PKG_LIST_ARCH" = "x86" ]; then
|
|
||||||
PKG_LIST_ARCH="i386"
|
|
||||||
FORCE_NO_SCRIPTS=""
|
|
||||||
else
|
|
||||||
# For armel we forcefully disable all maintainer scripts.
|
|
||||||
# TODO: Remove this when everything is whitelisted for all build variants.
|
|
||||||
FORCE_NO_SCRIPTS="-o=DPkg::options::=--nodpkg_fallback"
|
|
||||||
fi
|
|
||||||
for p in $PACKAGE_LISTS; do
|
|
||||||
COMPONENTS=$(filter_pkgs "$p" "$PKG_LIST_ARCH")
|
|
||||||
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \
|
|
||||||
ARCH="$FLAGS_arch" \
|
|
||||||
apt-get $FORCE_NO_SCRIPTS --force-yes install $COMPONENTS
|
|
||||||
done
|
|
||||||
|
|
||||||
# Create kernel installation configuration to suppress warnings,
|
|
||||||
# install the kernel in /boot, and manage symlinks.
|
|
||||||
cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/kernel-img.conf"
|
|
||||||
link_in_boot = yes
|
|
||||||
do_symlinks = yes
|
|
||||||
minimal_swap = yes
|
|
||||||
clobber_modules = yes
|
|
||||||
warn_reboot = no
|
|
||||||
do_bootloader = no
|
|
||||||
do_initrd = yes
|
|
||||||
warn_initrd = no
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Install the kernel.
|
|
||||||
# TODO: Support for armel kernels.
|
|
||||||
if [ "$FLAGS_arch" = "x86" ]; then
|
|
||||||
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive ARCH="$FLAGS_arch"\
|
|
||||||
apt-get --force-yes install "linux-image-${KERNEL_VERSION}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install optionally present rootfs static data. This can be used to blast
|
|
||||||
# custom firmware, kernel modules, etc. onto the image.
|
|
||||||
# TODO: Remove this hack at some point.
|
|
||||||
LOCAL_ASSETS="${FLAGS_build_root}/${FLAGS_arch}/local_assets"
|
|
||||||
OPTIONAL_ROOTFS_DATA="${LOCAL_ASSETS}/rootfs_data.tgz"
|
|
||||||
if [ -f "${OPTIONAL_ROOTFS_DATA}" ]; then
|
|
||||||
sudo tar -zxvf "${OPTIONAL_ROOTFS_DATA}" -C "${ROOT_FS_DIR}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# List all packages installed so far, since these are what the local
|
|
||||||
# repository needs to contain.
|
|
||||||
# TODO: Replace with list_installed_packages.sh when it is fixed up.
|
|
||||||
dpkg --root="${ROOT_FS_DIR}" -l > \
|
|
||||||
"${OUTPUT_DIR}/package_list_installed.txt"
|
|
||||||
|
|
||||||
cleanup_rootfs_mounts
|
|
||||||
trap - EXIT
|
|
139
recursive_dep.py
139
recursive_dep.py
@ -1,139 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
# Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
|
||||||
# found in the LICENSE file.
|
|
||||||
|
|
||||||
from sets import Set
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
|
|
||||||
preferred_virtual_pkg_providers = {
|
|
||||||
'<debconf-2.0>': 'debconf',
|
|
||||||
'<libgl1>': 'libgl1-mesa-glx',
|
|
||||||
'<modutils>': 'module-init-tools',
|
|
||||||
'<x-terminal-emulator>': 'xvt',
|
|
||||||
'<xserver-xorg-input-4>': 'xserver-xorg-input-kbd',
|
|
||||||
'<xserver-xorg-video-5>': 'xserver-xorg-video-dummy'
|
|
||||||
}
|
|
||||||
|
|
||||||
# if we have a set of packages to choose from, we see if any packages we
|
|
||||||
# can choose from are in this list (starting from element 0). if we find a
|
|
||||||
# match, we use that, otherwise the script just picks one from the set
|
|
||||||
preferred_packages = [
|
|
||||||
'debconf',
|
|
||||||
'debconf-english',
|
|
||||||
'ttf-bitstream-vera',
|
|
||||||
'libgl1-mesa-glx',
|
|
||||||
'module-init-tools',
|
|
||||||
'<x-terminal-emulator>',
|
|
||||||
'xserver-xorg-input-kbd',
|
|
||||||
'xserver-xorg-video-dummy',
|
|
||||||
'<xserver-xorg-input-4>',
|
|
||||||
'<xserver-xorg-video-5>',
|
|
||||||
'udev'
|
|
||||||
]
|
|
||||||
|
|
||||||
def isVirtualPackage(packagename):
|
|
||||||
return packagename.startswith('<') and packagename.endswith('>')
|
|
||||||
|
|
||||||
def providerForVirtualPkg(packagename):
|
|
||||||
# check for any pre-chosen packages
|
|
||||||
if packagename in preferred_virtual_pkg_providers:
|
|
||||||
return preferred_virtual_pkg_providers[packagename]
|
|
||||||
|
|
||||||
name = packagename.strip('<>')
|
|
||||||
lines = subprocess.Popen(['apt-cache', 'showpkg', name],
|
|
||||||
stdout=subprocess.PIPE).communicate()[0].split('\n')
|
|
||||||
if len(lines) < 2:
|
|
||||||
print 'too few lines!', packagename
|
|
||||||
sys.exit(1)
|
|
||||||
got_reverse_provides_line = False
|
|
||||||
for line in lines:
|
|
||||||
if got_reverse_provides_line:
|
|
||||||
# just take the first one
|
|
||||||
provider = line.split(' ')[0]
|
|
||||||
if provider == '':
|
|
||||||
print 'no provider for', packagename
|
|
||||||
sys.exit(1)
|
|
||||||
print '"' + provider + '" provides "' + packagename + '"'
|
|
||||||
return provider
|
|
||||||
got_reverse_provides_line = line.startswith('Reverse Provides:')
|
|
||||||
print 'didn\'t find a provider for', packagename
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
def getDepsFor(packagename):
|
|
||||||
results = subprocess.Popen(['apt-cache', 'depends', packagename],
|
|
||||||
stdout=subprocess.PIPE).communicate()[0]
|
|
||||||
lines = results.split('\n')
|
|
||||||
if len(lines) < 2:
|
|
||||||
print 'too few lines!', packagename
|
|
||||||
sys.exit(1)
|
|
||||||
ret = Set()
|
|
||||||
prefix = ' Depends: '
|
|
||||||
# If a package depends on any in a set of packages then each possible package
|
|
||||||
# in the set, except for the last one, will have a pipe before Depends.
|
|
||||||
# For example:
|
|
||||||
# Depends: foo
|
|
||||||
# Depends: bar
|
|
||||||
# |Depends: baz
|
|
||||||
# |Depends: bat
|
|
||||||
# |Depends: flower
|
|
||||||
# Depends: candle
|
|
||||||
# Depends: trunk
|
|
||||||
# means this package depends on foo, bar, trunk, and any one of baz, bat,
|
|
||||||
# flower, and candle.
|
|
||||||
# I couldn't find this documented anywhere.
|
|
||||||
set_prefix = ' |Depends: '
|
|
||||||
dep_set = Set()
|
|
||||||
for line in lines:
|
|
||||||
if line.startswith(set_prefix):
|
|
||||||
dep_set.add(line[len(set_prefix):])
|
|
||||||
continue
|
|
||||||
if not line.startswith(prefix):
|
|
||||||
dep_set.clear()
|
|
||||||
continue
|
|
||||||
pkgname = line[len(prefix):]
|
|
||||||
if len(dep_set) > 0:
|
|
||||||
dep_set.add(pkgname)
|
|
||||||
# we need to pick one from dep_set
|
|
||||||
found_pref = False
|
|
||||||
for pref in preferred_packages:
|
|
||||||
if pref in dep_set:
|
|
||||||
print 'using pref to choose "' + pref + '" from set ' + str(dep_set)
|
|
||||||
pkgname = pref
|
|
||||||
found_pref = True
|
|
||||||
break
|
|
||||||
if not found_pref:
|
|
||||||
print 'chose "' + pkgname + '" from set ' + str(dep_set)
|
|
||||||
dep_set.clear()
|
|
||||||
ret.add(pkgname)
|
|
||||||
print packagename + ' has deps: ' + str(ret)
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def main(argv):
|
|
||||||
checked = Set()
|
|
||||||
unchecked = Set()
|
|
||||||
for arg in argv[1:]:
|
|
||||||
unchecked.add(arg)
|
|
||||||
while True:
|
|
||||||
directdeps = Set()
|
|
||||||
for pkg in unchecked:
|
|
||||||
if isVirtualPackage(pkg):
|
|
||||||
pkg = providerForVirtualPkg(pkg)
|
|
||||||
directdeps = directdeps.union(getDepsFor(pkg))
|
|
||||||
checked.add(pkg)
|
|
||||||
directdeps = directdeps.difference(checked)
|
|
||||||
unchecked = directdeps
|
|
||||||
if len(unchecked) == 0:
|
|
||||||
print 'done'
|
|
||||||
checked_list = list(checked)
|
|
||||||
checked_list.sort()
|
|
||||||
print 'all:', checked_list
|
|
||||||
print 'total of ' + str(len(checked_list)) + ' items'
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main(sys.argv)
|
|
Loading…
x
Reference in New Issue
Block a user