Drop classic scripts used for kernel module building
This commit is contained in:
parent
2222eb8d36
commit
f51669d17b
4 changed files with 0 additions and 149 deletions
|
|
@ -1,63 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
ROOT=$SNAP_COMMON/classic
|
||||
|
||||
# $1: source
|
||||
# $2: target
|
||||
# $3: if not empty, bind mount will be read-only
|
||||
# note that we do NOT clean these up at the end, as the user might start many
|
||||
# classic shells in parallel; we could start all of them in their own mount
|
||||
# namespace, but that would make the classic shell less useful for
|
||||
# developing/debugging the snappy host
|
||||
do_bindmount() {
|
||||
if ! mountpoint -q "$ROOT/$2"; then
|
||||
if [ -d "$1" -a ! -L "$1" ]; then
|
||||
mkdir -p "$ROOT/$2"
|
||||
fi
|
||||
mount --make-rprivate --rbind -o rbind "$1" "$ROOT/$2"
|
||||
if [ -n "${3:-}" ]; then
|
||||
mount --rbind -o remount,ro "$1" "$ROOT/$2"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "needs to run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d $ROOT ]; then
|
||||
# IMPORTANT: do not run the classic.create as this will run it with
|
||||
# snap-confine again and this will cause havoc with current
|
||||
# snap-confine
|
||||
$SNAP/bin/create
|
||||
fi
|
||||
|
||||
# FIXME: confinement will prevent this
|
||||
do_bindmount /home /home
|
||||
do_bindmount /run /run
|
||||
do_bindmount /proc /proc
|
||||
do_bindmount /sys /sys
|
||||
do_bindmount /dev /dev
|
||||
do_bindmount / /snappy
|
||||
|
||||
SUDO_USER=root
|
||||
|
||||
# fix LP: #1619455
|
||||
cp -a /var/lib/extrausers/* $ROOT/var/lib/extrausers/
|
||||
cp -a /etc/sudoers.d/* $ROOT/etc/sudoers.d/
|
||||
|
||||
# assemble command line
|
||||
DEVPTS="mount -o mode=666,ptmxmode=666 -t devpts devpts /dev/pts"
|
||||
SUDOCMD="sudo debian_chroot=classic -u ${SUDO_USER} -i $@"
|
||||
# FIXME: workaround for https://bugs.launchpad.net/snappy/+bug/1611493
|
||||
SCRIPT="script --quiet --return --command \"$SUDOCMD\" /dev/null"
|
||||
|
||||
CMD="$DEVPTS; $SCRIPT"
|
||||
|
||||
systemd-run --quiet --scope --unit=classic-$$.scope --description="Classic shell" chroot "$ROOT" sh -c "$CMD"
|
||||
|
||||
# kill leftover processes after exiting, if it's still around
|
||||
systemctl stop classic-$$.scope 2>/dev/null || true
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
ROOT=$SNAP_COMMON/classic
|
||||
|
||||
if [ -d $ROOT ]; then
|
||||
echo "classic already enabled"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $(id -u) -ne 0 ]; then
|
||||
echo "This script needs to be called as root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CORE=""
|
||||
if [ -e /snap/core/current ]; then
|
||||
CORE="core"
|
||||
elif [ -e /snap/ubuntu-core/current ]; then
|
||||
CORE="ubuntu-core"
|
||||
else
|
||||
echo "Cannot find core snap"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# FIXME: confinement will prevent this
|
||||
echo "Creating classic environment"
|
||||
VERSION="$(/bin/readlink /snap/${CORE}/current)"
|
||||
SNAPROOT="/var/lib/snapd/snaps/${CORE}_${VERSION}.snap"
|
||||
/usr/bin/unsquashfs -d $ROOT $SNAPROOT
|
||||
mkdir $ROOT/snappy
|
||||
|
||||
# enable
|
||||
sudo chroot $ROOT /var/lib/classic/enable.sh
|
||||
|
||||
# copy important config
|
||||
for f in hostname timezone localtime; do
|
||||
cp -a /etc/writable/$f $ROOT/etc/writable
|
||||
done
|
||||
for f in hosts; do
|
||||
cp -a /etc/$f $ROOT/etc/
|
||||
done
|
||||
|
||||
|
||||
# don't start services in the chroot on apt-get install
|
||||
cat <<EOF > "$ROOT/usr/sbin/policy-rc.d"
|
||||
#!/bin/sh
|
||||
while true; do
|
||||
case "\$1" in
|
||||
-*) shift ;;
|
||||
makedev) exit 0;;
|
||||
x11-common) exit 0;;
|
||||
*) exit 101;;
|
||||
esac
|
||||
done
|
||||
EOF
|
||||
chmod 755 "$ROOT/usr/sbin/policy-rc.d"
|
||||
|
||||
# workaround bug in livecd-rootfs
|
||||
chmod 1777 "$ROOT/tmp"
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
ROOT=$SNAP_COMMON/classic
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "needs to run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for d in /home /run /proc /sys /dev /var/lib/extrausers /etc/sudoers /etc/sudoers.d /snappy; do
|
||||
if mountpoint -q "$ROOT/$d"; then
|
||||
umount "$ROOT/$d"
|
||||
fi
|
||||
done
|
||||
|
||||
# cleanup
|
||||
rm -rf $ROOT
|
||||
|
|
@ -29,16 +29,10 @@ parts:
|
|||
scripts/snap-wrapper.sh: bin/anbox-wrapper.sh
|
||||
scripts/container-manager.sh: bin/container-manager.sh
|
||||
scripts/anbox-bridge.sh: bin/anbox-bridge.sh
|
||||
scripts/classic: bin/classic
|
||||
scripts/classic-create: bin/classic-create
|
||||
scripts/classic-reset: bin/classic-reset
|
||||
snap:
|
||||
- bin/anbox-bridge.sh
|
||||
- bin/anbox-wrapper.sh
|
||||
- bin/container-manager.sh
|
||||
- bin/classic
|
||||
- bin/classic-create
|
||||
- bin/classic-reset
|
||||
apparmor:
|
||||
plugin: nil
|
||||
stage-packages:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue