summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolás Reynolds <fauno@kiwwwi.com.ar>2012-08-04 14:12:15 -0300
committerNicolás Reynolds <fauno@kiwwwi.com.ar>2012-08-04 14:12:15 -0300
commitb8d0640c2d882e514a583e372bb26280a60aa604 (patch)
treeddb06422e51fdb960c31405d37b319adb0588b2a
parent049a81f6764ffb22fa91d1f85626de780e6a9787 (diff)
New root creation scripts
-rwxr-xr-xnewchroot36
-rwxr-xr-xnewroot49
2 files changed, 85 insertions, 0 deletions
diff --git a/newchroot b/newchroot
new file mode 100755
index 0000000..fbfebbf
--- /dev/null
+++ b/newchroot
@@ -0,0 +1,36 @@
+#!/bin/bash
+# Copyleft 2012 - Nicolás Reynolds <fauno@parabola.nu>
+# Bootstraps a Parabola build root
+# Note: this is a very basic script that let's you do whatever you want, so
+# it's not foolproof ;)
+
+# Attempt to provide some help
+if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
+ echo "Installs a Parabola build root on the current dir"
+ echo "Usage: newchroot [custom package1 ...]"
+ echo "Tip: pass 'distcc ccache' to speed up builds"
+ echo ""
+ echo "Environment variables:"
+ echo -e "WORKDIR \tThe install dir"
+ echo -e "LOGFILE \tAn alternate logfile ($PWD/pacman.log)"
+ echo -e "PACCACHE\tThe pacman cache (guessed)"
+ exit
+fi
+
+. "$(dirname $0)"/newroot
+
+pacman -S base-devel $@
+
+# No need to fiddle with /etc/resolv.conf if you're changing networks
+echo -e "80.87.131.252\trepo.parabolagnulinux.org" >> "${WORKDIR}"/etc/hosts
+
+# Only use up to date repos
+echo 'Server = http://repo.parabolagnulinux.org/$repo/os/$arch' > "${WORKDIR}"/etc/pacman.d/mirrorlist
+
+echo 'Add this to your fstab:'
+echo -e "# chroot
+none\t${WORKDIR}/proc\tproc\tdefaults
+none\t${WORKDIR}/sys\tsysfs\tdefaults
+/dev\t${WORKDIR}/dev\tnone\trbind
+# cache
+${PACCACHE}\t${WORKDIR}/var/cache/pacman/pkg\tnone\tbind"
diff --git a/newroot b/newroot
new file mode 100755
index 0000000..dff1003
--- /dev/null
+++ b/newroot
@@ -0,0 +1,49 @@
+#!/bin/bash
+# Copyleft 2012 - Nicolás Reynolds <fauno@parabola.nu>
+# Bootstraps a Parabola root, useful for base systems, build chroots, etc.
+# Note: this is a very basic script that let's you do whatever you want, so
+# it's not foolproof ;)
+
+# Attempt to provide some help
+if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
+ echo "Installs a Parabola root on the current dir"
+ echo "Usage: newroot [custom package1 ...]"
+ echo ""
+ echo "Environment variables:"
+ echo -e "WORKDIR \tThe install dir"
+ echo -e "LOGFILE \tAn alternate logfile ($PWD/pacman.log)"
+ echo -e "PACCACHE\tThe pacman cache (guessed)"
+ exit
+fi
+
+# Fail at any error
+set -E
+
+if [ ! -w / ]; then echo "Run as root."; exit 1; fi
+
+# Should work unless you have a messy pacman.conf
+function find_cache() {
+ grep "CacheDir\s*=\s*" /etc/pacman.conf | tail -n1 | cut -d"=" -f2 | tr -d " "
+}
+
+# Build on the current dir or WORKDIR env var
+WORKDIR="${WORKDIR:-${PWD}}"
+LOGFILE="${LOGFILE:-${WORKDIR}/pacman.log}"
+PACCACHE="${PACCACHE:-$(find_cache)}"
+# Do a last attempt to have a pacman cache
+PACCACHE="${PACCACHE:-/var/cache/pacman/pkg}"
+
+export WORKDIR LOGFILE PACCACHE
+
+function pacman() {
+ pacman -r "${WORKDIR}" \
+ --logfile "${LOGFILE}" \
+ --noconfirm \
+ --cachedir "${PACCACHE}" \
+ --config /etc/pacman.conf $@
+}
+
+# Bootstrap!
+mkdir -p "${WORKDIR}"/var/lib/pacman
+
+pacman -Sy base ${@}