aboutsummaryrefslogtreecommitdiff
path: root/contrib/kiss-chroot
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-07-24 09:45:05 +0000
committermerakor <cem@ckyln.com>2020-07-24 09:45:05 +0000
commita5742ec0d46f60fcbeec141744a2e35a9e5dd6d5 (patch)
tree653077a372cea7a5842db627546d2fab72c5f7e2 /contrib/kiss-chroot
parent453a27cc1b956246c9639555268631abf0687e40 (diff)
downloadcpt-a5742ec0d46f60fcbeec141744a2e35a9e5dd6d5.tar.gz
contrib: rename scripts
FossilOrigin-Name: d35a756a5d603ac894873aeb0a30826cb4b3fe9e257ecf21298225e07f517ddd
Diffstat (limited to 'contrib/kiss-chroot')
-rwxr-xr-xcontrib/kiss-chroot68
1 files changed, 0 insertions, 68 deletions
diff --git a/contrib/kiss-chroot b/contrib/kiss-chroot
deleted file mode 100755
index 7d0585c..0000000
--- a/contrib/kiss-chroot
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/bin/sh -e
-# Enter a chroot
-
-log() {
- printf '\033[32m->\033[m %s.\n' "$*"
-}
-
-usage() { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [dir]" ; exit 0 ;}
-
-die() {
- log "$*" >&2
- exit 1
-}
-
-clean() {
- log Unmounting /dev, /proc and /sys from chroot; {
- umount "$1/dev" ||:
- umount "$1/proc" ||:
- umount "$1/sys" ||:
- }
-
- log Cleaning leftover host files; {
- rm -f "$1/root/.ash_history"
- }
-}
-
-main() {
- case "$1" in ''|--help|-h) usage; esac
- [ -d "$1" ] || die Given path does not exist
- [ "$(id -u)" = 0 ] || die Script needs to be run as root
-
- [ "$2" ] || {
- march=$(uname -m 2>/dev/null) ||:
- case "$march" in
- '') march=native ;;
- x86_64) march=x86-64 ;;
- i*86) march=i686 ;;
- esac
- }
-
- trap 'clean "$1"' EXIT INT
-
- log Mounting /dev, /proc and /sys from host; {
- mountpoint -q "$1/dev" || mount -o bind /dev "$1/dev"
- mountpoint -q "$1/proc" || mount -t proc proc "$1/proc"
- mountpoint -q "$1/sys" || mount -t sysfs sys "$1/sys"
-
- }
-
- log Copying /etc/resolv.conf from host; {
- [ -f "$1/etc/resolv.conf" ] || cp /etc/resolv.conf "$1/etc"
- }
-
- log Entering chroot; {
- chroot "$1" /usr/bin/env -i \
- HOME=/root \
- TERM="$TERM" \
- SHELL=/bin/sh \
- USER=root \
- KISS_ASROOT=1 \
- CFLAGS="${CFLAGS:--march=$march -mtune=generic -pipe -Os}" \
- CXXFLAGS="${CXXFLAGS:--march=$march -mtune=generic -pipe -Os}" \
- MAKEFLAGS="${MAKFLAGS:--j$(nproc 2>/dev/null || echo 1)}" \
- /bin/sh -l
- }
-}
-
-main "$@"