/usr/bin/ubuntu-defaults-image is in ubuntu-defaults-builder 0.30.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | #! /bin/sh
# Build an image based on an Ubuntu flavour plus a defaults package.
#
# Authors: Colin Watson <cjwatson@ubuntu.com>
# Martin Pitt <martin.pitt@ubuntu.com>
# Copyright: (C) 2011 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
LOCALE=
PACKAGE=
ARCH=
COMPONENTS=
PPA=
FLAVOUR=ubuntu
SUITE=$(lsb_release -sc)
DELETE_APT_LISTS="rm -vf /var/lib/apt/lists/*_*"
if which dpkg-architecture >/dev/null 2>&1; then
ARCH="$(dpkg-architecture -qDEB_HOST_ARCH)"
fi
help () {
cat >&2 <<EOF
Usage: $0 {--locale code|--package name} [options]
Options:
--locale ll_CC : Same as --package ubuntu-defaults-ll-cc
--package : Install additional package; can be a name or path to a local .deb
--arch : Architecture [default: $ARCH]
--release RELEASE : Ubuntu release the image is based on [default: $SUITE]
--components COMPONENTS : List of archive components to enable [default: main,restricted]
--ppa USER/PPANAME : Enable additional PPA [default: none]
--keep-apt : Do not remove apt indexes from live system
--keep-apt-components COMPONENTS :
Do not remove apt indexes for selected components from live
system [default: none]
EOF
}
# add $PPA
add_ppa () {
local FINGERPRINT=`wget -q -O- https://launchpad.net/api/1.0/~${PPA%/*}/+archive/${PPA#*/}/signing_key_fingerprint`
if ! expr match "$FINGERPRINT" '^\"[a-zA-Z0-9]\{16,\}"$' >/dev/null; then
echo "Invalid fingerprint returned by Launchpad: $FINGERPRINT" >&2
exit 1
fi
# chop off enclosing quotes
FINGERPRINT=${FINGERPRINT%'"'}
FINGERPRINT=${FINGERPRINT#'"'}
# fetch GPG key
gpg --no-default-keyring --primary-keyring config/archives/ubuntu-defaults.chroot.key --keyserver keyserver.ubuntu.com --recv-key "$FINGERPRINT"
# add PPA apt source
local DEB_PPA="deb http://ppa.launchpad.net/$PPA/ubuntu $SUITE main"
echo "$DEB_PPA" > config/archives/ubuntu-defaults.chroot.list
echo "$DEB_PPA" > config/archives/ubuntu-defaults.binary.list
}
eval set -- "$(getopt -o '' -l help,locale:,keep-apt,keep-apt-components:,package:,arch:,release:,components:,ppa: -- "$@")" || { help; exit 1; }
while :; do
case $1 in
--help)
help
exit 0
;;
--locale)
LOCALE="$2"
shift 2
;;
--package)
PACKAGE="$2"
shift 2
;;
--arch)
ARCH="$2"
shift 2
;;
--release)
SUITE="$2"
shift 2
;;
--components)
COMPONENTS="$(echo "$2" | sed 's/,/ /g' | tr -s ' ')"
shift 2
;;
--ppa)
PPA="$2"
if ! expr match "$PPA" '^[[:alnum:]-]\+/[[:alnum:]-]\+$' >/dev/null; then
echo "Invalid PPA specification, must be lp_username/ppaname" >&2
exit 1
fi
shift 2
;;
--keep-apt)
DELETE_APT_LISTS="rm -vf /var/lib/apt/lists/*_Translation-*"
shift
;;
--keep-apt-components)
components="$(echo "$2" | sed 's/,/ /g')"
DELETE_APT_LISTS="rm -vf /var/lib/apt/lists/*_Translation-*
rm -vf /var/lib/apt/lists/*_main_*
rm -vf /var/lib/apt/lists/*_restricted_*
rm -vf /var/lib/apt/lists/*_universe_*
rm -vf /var/lib/apt/lists/*_multiverse_*"
for comp in $components; do
case $comp in
main|restricted|universe|multiverse)
DELETE_APT_LISTS=$(echo "$DELETE_APT_LISTS" | grep -v $comp)
;;
*)
echo "ERROR: unknown component $comp"
exit 1
;;
esac
done
shift 2
;;
--)
shift
break
;;
*)
help
exit 1
;;
esac
done
if ([ -z "$LOCALE" ] && [ -z "$PACKAGE" ]) || [ -z "$ARCH" ]; then
help
exit 1
fi
if [ "$LOCALE" ] && [ -z "$PACKAGE" ]; then
PACKAGE="ubuntu-defaults-$(echo "$LOCALE" | tr '_A-Z' '-a-z')"
fi
if [ "$(id -u)" = 0 ]; then
SUDO=env
else
SUDO=sudo
fi
# Make sure all our dependencies (which are Recommends of our package) are
# installed. This is a bit dubious long-term, but seems to be needed to
# make autobuilds reliable.
case $ARCH in
*amd64|*i386)
$SUDO apt-get -y install syslinux-themes-ubuntu gfxboot-theme-ubuntu memtest86+ syslinux
;;
esac
$SUDO apt-get -y install genisoimage
rm -rf auto
mkdir -p auto
for f in config build clean; do
ln -s "/usr/share/livecd-rootfs/live-build/auto/$f" auto/
done
$SUDO lb clean
rm -f .stage/config
SUITE="$SUITE" PROJECT="$FLAVOUR" ARCH="$ARCH" \
IMAGEFORMAT=squashfs BINARYFORMAT=iso-hybrid lb config
if [ "$COMPONENTS" ]; then
sed -i "s/^\\(LB_PARENT_ARCHIVE_AREAS=\\).*/\\1\"$COMPONENTS\"/" \
config/bootstrap
fi
sed -i "s/^\\(LB_SYSLINUX_THEME=\\).*/\\1\"ubuntu-$SUITE\"/" config/binary
if [ "${PACKAGE%.deb}" = "$PACKAGE" ]; then
# package name, apt-get'able
echo "$PACKAGE" >> config/package-lists/ubuntu-defaults.chroot_install.list
else
# local deb
cp "$PACKAGE" config/chroot_packages/
fi
if [ -n "$PPA" ]; then
add_ppa
fi
PACKAGENAME=${PACKAGE%%_*}
PACKAGENAME=${PACKAGENAME##*/}
# install language support hook (try the one from the source tree first)
HOOK=$(dirname $(readlink -f $0))/../lib/language-support-hook
if ! [ -e "$HOOK" ]; then
HOOK=/usr/share/ubuntu-defaults-builder/language-support-hook
fi
sed "s/#DEFAULTS_PACKAGE#/$PACKAGENAME/" < "$HOOK" > config/chroot_local-hooks/00_language-support
# work around live-build failure with lzma initramfs (Debian #637979)
sed -i 's/^LB_INITRAMFS_COMPRESSION="lzma"/LB_INITRAMFS_COMPRESSION="gzip"/' config/common
# run hooks from defaults package
cat <<EOF > config/chroot_local-hooks/10_ubuntu-defaults
#!/bin/sh
set -e
HOOK=/usr/share/$PACKAGENAME/hooks/chroot
if [ -x \$HOOK ]; then
\$HOOK
fi
EOF
# clean up files that we do not need
cat <<EOF > config/chroot_local-hooks/90_cleanup
#!/bin/sh
set -e
echo "$0: Removing unnecessary files..."
rm -vf /var/cache/apt/*cache.bin
$DELETE_APT_LISTS
rm -vrf /tmp/*
EOF
# rename kernel and initrd to what syslinux expects
cat <<EOF > config/binary_local-hooks/rename-kernel
#!/bin/sh -e
if [ ! -e binary/casper/initrd.lz ]; then
zcat binary/casper/initrd.img-* | lzma -c > binary/casper/initrd.lz
rm binary/casper/initrd.img-*
fi
if [ ! -e binary/casper/vmlinuz ]; then
mv binary/casper/vmlinuz-* binary/casper/vmlinuz
fi
EOF
# set default language
cat <<EOF > config/binary_local-hooks/default-language
#!/bin/sh -e
LOC=chroot/usr/share/$PACKAGENAME/language.txt
if [ -e "\$LOC" ]; then
cp "\$LOC" binary/isolinux/lang
echo >> binary/isolinux/lang
fi
EOF
DISPLAY= $SUDO PROJECT="$FLAVOUR" ARCH="$ARCH" lb build
|