Quick Custom Installation
From ArchWiki
Installation of Arch Linux to a clean directory or partition using a custom package selection
This is really very out of date. One might consider removing it. Current existing options include the official arch installer and the new framework AIF (available in the Arch repositories - but I think they will probably only normally run on an Arch system), and the successor(s) to the script presented here which are available in the larch package, which should also run on non-Arch systems. You probably need the static build of pacman (AUR) if not running on Arch, which larch should manage more or less automatically.
Please refer to Using_the_quickinst_Script_to_Install_Arch_Linux for more general details about installation using such a script. Install_Arch_from_within_another_distro might also be useful. The method described here allows much easier customization of the package selection, but you need internet access for downloading the packages, or a cache containing them.
The script newarch installs a 'clean', unconfigured Arch Linux system to a convenient location. It gets the required packages using the normal pacman method - downloading, from the cache, etc. - according to configuration and environment. It should run from within any Linux system. If necessary it will download pacman and use the static version, 'pacman.static'. It can be used to create customized installations directly on fresh partitions, for example. The script takes no arguments, most configuration details are in the script itself, at the top. In addition, a pacman.conf file for pacman is required. Here is an example:
# # pacman.conf - for newarch # put it in the same directory as newarch # # NOTE: If you find a mirror that is geographically close to you, please # move it to the top of the server list, so pacman will choose it # first. # # See the pacman manpage for option directives # # GENERAL OPTIONS # [options] LogFile = /var/log/pacman.log NoUpgrade = etc/passwd etc/group etc/shadow etc/sudoers NoUpgrade = etc/fstab etc/raidtab etc/ld.so.conf NoUpgrade = etc/rc.conf etc/rc.local NoUpgrade = etc/modprobe.d/modprobe.conf etc/modules.conf NoUpgrade = etc/lilo.conf boot/grub/menu.lst HoldPkg = pacman glibc #XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u # # REPOSITORIES # - can be defined here or included from another file # - pacman will search repositories in the order defined here. # - local/custom mirrors can be added here or in separate files # #[testing] #Server = ftp://ftp.archlinux.org/testing/os/i686 [core] # Add your preferred servers here, they will be used first Server = ftp://ftp.archlinux.org/core/os/i686 Server = ftp://ftp.heanet.ie/mirrors/ftp.archlinux.org/core/os/i686 Server = ftp://ftp.nluug.nl/pub/metalab/distributions/archlinux/core/os/i686 [extra] # Add your preferred servers here, they will be used first Server = ftp://ftp.archlinux.org/extra/os/i686 Server = ftp://ftp.heanet.ie/mirrors/ftp.archlinux.org/extra/os/i686 Server = ftp://ftp.nluug.nl/pub/metalab/distributions/archlinux/extra/os/i686 #[unstable] # Add your preferred servers here, they will be used first #Server = ftp://ftp.nluug.nl/pub/metalab/distributions/archlinux/unstable/os/i686 #[community] # Add your preferred servers here, they will be used first #Server = ftp://ftp.heanet.ie/mirrors/ftp.archlinux.org/community/os/i686 #Server = ftp://ftp.nluug.nl/pub/metalab/distributions/archlinux/community/os/i686 # An example of a custom package repository. See the pacman manpage for # tips on creating your own repositories. #[custom] #Server = file:///home/custompkgs
Choosing the packages to be installed
If you want more than the base set of packages to be installed, you need to provide the file 'addedpacks'. A simple example of this is also provided below. Pretty well any packages you like can be included in here, and dependencies will be handled automatically by pacman.
# addedpacks - a simple list of packages (just package name, not file # name, e.g. 'python'), one per line, _no other content!_ This is the primary # place for configuring which packages are installed. # place this file in the same directory as 'newarch' # You'll need a kernel! kernel26 # Just some suggestions #for abs: cvsup # generally useful tools which don't require X: openssh rsync dosfstools lynx mc unzip zip fakeroot alsa-lib alsa-oss alsa-utils
The exact location (directory name, DESTDIR) for the installlation can be set as a configuration detail in newarch. It need not be on a separate partition, but if it is, you could use that as the basis for a fresh Arch installation there. If you do use a separate partition, set DESTDIR to the mount point (and remember to mount the partition, with exec and dev options.
When the above files have been set up to meet your requirements, simply run newarch (as root) and you should end up with an (unconfigured, pristine) Arch system at the selected location. If you set up your configuration wrong (or if you or I made some other mistake ...), you might find you have destroyed some important data and/or your system doesn't work any more. If everything went well, you will be asked if you want to make a tar-ball of the installed system, which might be useful for subsequent installations.
Remember the system which gets installed here is completely unconfigured. As an absolute bare minimum you would need to edit its /etc/fstab (put the root partition in it), but probably several other things too (/etc/rc.conf, lilo/grub, etc.).
#! /bin/bash
#
# newarch
#
# Author: gradgrind <mt.42@web.de>
#
# This file is part of the larch project.
#
# larch 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 2 of the License, or
# (at your option) any later version.
#
# larch 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 larch; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #
#----------------------------------------------------------------------------
#
#----------------------------- CONFIGURATION ------------------
# WARNING! Relative paths (those not starting with /) are relative
# to the directory containing this file, and should be processed
# with 'readlink -f' in order to make them absolute, e.g.:
# VAR1=$( readlink -f ../dir/file )
# Allows customizing of the cache for downloaded packages, default:
#PKGCACHE=/var/cache/pacman/pkg
# setting it to "" will cause the cache to be built and left in
# the destination directory
#PKGCACHE=""
PKGCACHE=/var/cache/pacman/pkg
# directory to contain the freshly installed Arch Linux
DESTDIR=/home/ArchImage
# pacman version, for ease of maintaining in case it get's updated.
PACVER="3.0.6-2"
# choose method for acquiring list of base packages
#getbasepacks=basepacks_cvs
getbasepacks=basepacks_ftp
# list of base packages which should NOT be installed
# e.g. BASEVETO="pkga pkgb"
BASEVETO="devfsd lshwd"
# devfsd is deprecated, but apparently still in base
# lshwd is buggy and not usually needed any more
#----------------------------- END OF CONFIGURATION -----------
# Get path to directory containing this script
SCRIPTDIR="`dirname \`readlink -f $0\``"
echo "Changing current directory to $SCRIPTDIR"
cd $SCRIPTDIR
echo
echo "newarch will do an automated Archlinux installation to the directory"
echo " $DESTDIR"
echo
echo "It only installs the packages, without configuration."
echo
echo "It runs two stages:"
echo " install base packages - should generally be left unaltered"
echo " (optional) install additional packages - main point of customization"
echo
if [ "$(whoami)" != 'root' ]; then
echo "You must run this as 'root'"
exit 1
fi
if [ -z "`echo $DESTDIR | grep '^/'`" ]; then
DESTDIR=`pwd`/$DESTDIR
fi
echo "**********************************************************"
echo "This will delete EVERYTHING under"
echo
echo " $DESTDIR"
echo
echo "I really mean it ... Are you sure you want to do this?"
echo "**********************************************************"
# Await yes or no
read -p "[y/N]: " ans
if [ -z "`echo $ans | grep '^ *[yY]'`" ]; then exit 0; fi
echo
echo "Downloaded packages will be cached at $PKGCACHE"
echo
# Await yes or no
read -p "OK? [y/N]: " ans
if [ -z "`echo $ans | grep '^ *[yY]'`" ]; then exit 0; fi
if [ ! -d $DESTDIR ]; then
mkdir -p $DESTDIR
else
rm -rf $DESTDIR/*
if [ $? -ne 0 ]; then
echo "ERROR: couldn't remove $DESTDIR"
exit 1
fi
fi
if [ -x /usr/bin/pacman ]; then
PACMAN="pacman --config pacman.conf --noconfirm"
else
echo
echo "Downloading pacman"
echo
# use wget to download pacman
# Updated to core and removed the setup/ subdir as noted in the discussion.
# Please note: Apparently somebody removed the 'pacman.pkg.tar.gz' file, I'm
# changing to it's current version. I would appreciate if somebody re-upload
# the pacman.pkg.tar.gz or give me a better solution. :-) -- Felipe Mendes
wget ftp://ftp.archlinux.org/core/os/i686/pacman-$PACVER-i686.pkg.tar.gz
(($? > 0)) && echo 'Looks like your pacman download failed. Please ensure the PACVER \
variable is set to the latest pacman version and release.' && exit 1
tar -xzf pacman-$PACVER-i686.pkg.tar.gz -O usr/bin/pacman.static >pacman.static
chmod 755 pacman.static
PACMAN="./pacman.static --config pacman.conf --noconfirm"
fi
# Generate the list of base packages using cvs.archlinux.org
basepacks_cvs ()
{
echo
echo "*********** Getting base package list from cvs.archlinux.org ***********"
echo
# Download index.html file for current/base
rm -f index.html
wget http://cvs.archlinux.org/cgi-bin/viewcvs.cgi/base/
# bad style, but working thou
# There was a problem with this function. Somebody forgot to close sed quotes:
cat index.html | grep '^<a name="[^A]' | sed 's|.*name="\(.\+\)" h.*|\1|' > packages.temp
BASEPKGS=`cat packages.temp | sed 's|-|[^-]\+-[0-9].[0-9]\+\.pkg.*||'`
}
# Generate the list of base packages from ftp.archlinux.org/.../packages.txt
basepacks_ftp ()
{
echo
echo "** Getting base package list from ftp.archlinux.org/.../packages.txt **"
echo
rm -f packages.txt
wget ftp://ftp.archlinux.org/core/os/i686/packages.txt
# The sed regexp didn't worked with versions such as:
# pam-0.99.8.1-3.1.pkg.tar.gz
# and gcc-4.2.1-3.1.pkg.tar.gz
# So I adapted it.
BASEPKGS=`cat packages.txt | egrep '^base/' | \
sed 's|^.*/||;s/-[0-9]\+.*//'`
}
# Fetch the list of packages from core/base to BASEPKGS
$getbasepacks
# Build basepacks by filtering BASEPKGS
echo -n "" > basepacks
#
# I'm sure this next bit (filter out vetoed packages) can be done better,
# any ideas? bash has so much weird syntax ... too complicated for me.
#
for p in $BASEPKGS; do
for v in $BASEVETO; do
if [ "$v" == "$p" ]; then
p=""
break
fi
done
if [ -n "$p" ]; then
echo $p >> basepacks
fi
done
doInstall() {
echo "Installing following packages:"
echo $PKGLIST
$PACMAN -r $DESTDIR -S $PKGLIST
if [ $? -gt 0 ]; then
echo
echo "Package installation from $pklist FAILED."
echo
exit 1
fi
}
# This redirects the package cache, so that an existing one can be used.
if [ -n "$PKGCACHE" ]; then
mkdir -p $DESTDIR/var/cache/pacman
mkdir -p $PKGCACHE
ln -s $PKGCACHE $DESTDIR/var/cache/pacman/pkg
fi
echo
echo "************** Synchronising package dbs **************"
echo
$PACMAN -r $DESTDIR -Sy
echo
echo "************** Installing base package set **************"
echo
pklist="basepacks"
PKGLIST=`cat $pklist | grep -v "#"`
doInstall
echo
echo "************** Additional packages **************"
echo
pklist="addedpacks"
if [ -f $pklist ]; then
PKGLIST=`cat $pklist | grep -v "#"`
doInstall
else
echo " ... package list file 'addedpacks' not found"
echo
fi
if [ -n "$PKGCACHE" ]; then
# Remove the package cache redirection
rm $DESTDIR/var/cache/pacman/pkg
fi
echo
echo "Would you like to create a 'tar.gz' of the installation?"
# Await yes or no
read -p "[y/N]: " ans
if [ -z "`echo $ans | grep '^ *[yY]'`" ]; then exit 0; fi
echo "Doing tar -czf archiball.tar.gz -C $DESTDIR ."
echo "This could take a while ..."
tar -czf archiball.tar.gz -C $DESTDIR .
echo
echo "+++ All done! +++"
echo