archlinux: do not use additional sudo inside scripts_archlinux/*

The whole build process is started as root (check Makefile), so there is
no need for additional sudo. This makes some things much simpler
(for example appending to some files).
This commit is contained in:
Marek Marczykowski 2013-04-28 22:50:18 +02:00
parent 75a63613bc
commit d13a4eff88
6 changed files with 41 additions and 39 deletions

View File

@ -14,11 +14,11 @@ gpg --verify "$SCRIPTSDIR/archlinux-$ISO_VERSION-dual.iso.sig" "$CACHEDIR/archli
if [ "$CACHEDIR/archlinux-$ISO_VERSION-dual.iso" -nt $CACHEDIR/root-image.fs ]; then if [ "$CACHEDIR/archlinux-$ISO_VERSION-dual.iso" -nt $CACHEDIR/root-image.fs ]; then
echo "Extracting squash filesystem from DVD..." echo "Extracting squash filesystem from DVD..."
mkdir mnt_archlinux_dvd mkdir mnt_archlinux_dvd
sudo mount -o loop "$CACHEDIR/archlinux-$ISO_VERSION-dual.iso" mnt_archlinux_dvd mount -o loop "$CACHEDIR/archlinux-$ISO_VERSION-dual.iso" mnt_archlinux_dvd
cp mnt_archlinux_dvd/arch/x86_64/root-image.fs.sfs $CACHEDIR/ cp mnt_archlinux_dvd/arch/x86_64/root-image.fs.sfs $CACHEDIR/
sudo umount mnt_archlinux_dvd umount mnt_archlinux_dvd
sudo mount -o loop $CACHEDIR/root-image.fs.sfs mnt_archlinux_dvd mount -o loop $CACHEDIR/root-image.fs.sfs mnt_archlinux_dvd
cp mnt_archlinux_dvd/root-image.fs $CACHEDIR/ cp mnt_archlinux_dvd/root-image.fs $CACHEDIR/
sudo umount mnt_archlinux_dvd umount mnt_archlinux_dvd
rm $CACHEDIR/root-image.fs.sfs rm $CACHEDIR/root-image.fs.sfs
fi fi

View File

@ -4,23 +4,23 @@ set -e
echo "Mounting archlinux install system into mnt_archlinux_dvd..." echo "Mounting archlinux install system into mnt_archlinux_dvd..."
mkdir -p mnt_archlinux_dvd mkdir -p mnt_archlinux_dvd
sudo mount $CACHEDIR/root-image.fs mnt_archlinux_dvd mount $CACHEDIR/root-image.fs mnt_archlinux_dvd
echo "Creating chroot bootstrap environment" echo "Creating chroot bootstrap environment"
sudo mount --bind $INSTALLDIR mnt_archlinux_dvd/mnt mount --bind $INSTALLDIR mnt_archlinux_dvd/mnt
sudo cp /etc/resolv.conf mnt_archlinux_dvd/etc cp /etc/resolv.conf mnt_archlinux_dvd/etc
echo "-> Initializing pacman keychain" echo "-> Initializing pacman keychain"
sudo ./mnt_archlinux_dvd/usr/bin/arch-chroot mnt_archlinux_dvd/ pacman-key --init ./mnt_archlinux_dvd/usr/bin/arch-chroot mnt_archlinux_dvd/ pacman-key --init
sudo ./mnt_archlinux_dvd/usr/bin/arch-chroot mnt_archlinux_dvd/ pacman-key --populate ./mnt_archlinux_dvd/usr/bin/arch-chroot mnt_archlinux_dvd/ pacman-key --populate
echo "-> Installing core pacman packages..." echo "-> Installing core pacman packages..."
sudo ./mnt_archlinux_dvd/usr/bin/arch-chroot mnt_archlinux_dvd/ sh -c 'pacstrap /mnt base' ./mnt_archlinux_dvd/usr/bin/arch-chroot mnt_archlinux_dvd/ sh -c 'pacstrap /mnt base'
echo "-> Cleaning up bootstrap environment" echo "-> Cleaning up bootstrap environment"
sudo umount mnt_archlinux_dvd/mnt umount mnt_archlinux_dvd/mnt
sudo umount mnt_archlinux_dvd umount mnt_archlinux_dvd
cp $SCRIPTSDIR/resolv.conf $INSTALLDIR/etc cp $SCRIPTSDIR/resolv.conf $INSTALLDIR/etc

View File

@ -3,13 +3,13 @@
set -e set -e
echo "Mounting archlinux install system into mnt_archlinux_dvd..." echo "Mounting archlinux install system into mnt_archlinux_dvd..."
sudo mount $CACHEDIR/root-image.fs mnt_archlinux_dvd mount $CACHEDIR/root-image.fs mnt_archlinux_dvd
PKGGROUPS=`cat $SCRIPTSDIR/packages.list` PKGGROUPS=`cat $SCRIPTSDIR/packages.list`
echo "-> Installing archlinux package groups..." echo "-> Installing archlinux package groups..."
echo "-> Selected packages:" echo "-> Selected packages:"
echo "$PKGGROUPS" echo "$PKGGROUPS"
sudo ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR pacman --needed --noconfirm -S $PKGGROUPS ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR pacman --needed --noconfirm -S $PKGGROUPS
sudo umount mnt_archlinux_dvd umount mnt_archlinux_dvd

View File

@ -4,7 +4,7 @@ set -e
echo "Mounting archlinux install system into mnt_archlinux_dvd..." echo "Mounting archlinux install system into mnt_archlinux_dvd..."
mkdir -p mnt_archlinux_dvd mkdir -p mnt_archlinux_dvd
sudo mount $CACHEDIR/root-image.fs mnt_archlinux_dvd mount $CACHEDIR/root-image.fs mnt_archlinux_dvd
# Note: Enable x86 repos # Note: Enable x86 repos
su -c "echo '[multilib]' >> $INSTALLDIR/etc/pacman.conf" su -c "echo '[multilib]' >> $INSTALLDIR/etc/pacman.conf"
@ -13,34 +13,36 @@ su -c "echo 'Include = /etc/pacman.d/mirrorlist' >> $INSTALLDIR/etc/pacman.conf"
echo "--> Registering Qubes custom repository" echo "--> Registering Qubes custom repository"
sudo tee -a $INSTALLDIR/etc/pacman.conf <<EOF cat >> $INSTALLDIR/etc/pacman.conf <<EOF
[qubes] [qubes]
SigLevel = Optional TrustAll SigLevel = Optional TrustAll
Server = file:///mnt/qubes-rpms-mirror-repo/pkgs Server = file:///mnt/qubes-rpms-mirror-repo/pkgs
EOF EOF
export CUSTOMREPO=$PWD/yum_repo_qubes/archlinux export CUSTOMREPO=$PWD/yum_repo_qubes/archlinux
sudo mkdir -p $INSTALLDIR/mnt/qubes-rpms-mirror-repo mkdir -p $INSTALLDIR/mnt/qubes-rpms-mirror-repo
sudo mount --bind $CUSTOMREPO $INSTALLDIR/mnt/qubes-rpms-mirror-repo mount --bind $CUSTOMREPO $INSTALLDIR/mnt/qubes-rpms-mirror-repo
sudo ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR sh -c "cd /mnt/qubes-rpms-mirror-repo/;repo-add pkgs/qubes.db.tar.gz pkgs/*.pkg.tar.xz" ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR sh -c "cd /mnt/qubes-rpms-mirror-repo/;repo-add pkgs/qubes.db.tar.gz pkgs/*.pkg.tar.xz"
chown -R --reference=$CUSTOMREPO $CUSTOMREPO chown -R --reference=$CUSTOMREPO $CUSTOMREPO
sudo ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR sh -c "pacman -Sy" ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR sh -c "pacman -Sy"
echo "--> Installing qubes-packages..." echo "--> Installing qubes-packages..."
sudo ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR sh -c "pacman -S --noconfirm qubes-vm-xen" ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR sh -c "pacman -S --noconfirm qubes-vm-xen"
sudo ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR sh -c "pacman -S --noconfirm qubes-vm-core" ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR sh -c "pacman -S --noconfirm qubes-vm-core"
sudo ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR sh -c "pacman -S --noconfirm qubes-vm-gui" ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR sh -c "pacman -S --noconfirm qubes-vm-gui"
echo "--> Updating template fstab file..." echo "--> Updating template fstab file..."
sudo su -c "echo '/dev/mapper/dmroot / ext4 defaults,noatime 1 1' >> $INSTALLDIR/etc/fstab" cat >> $INSTALLDIR/etc/fstab <<EOF
sudo su -c "echo '/dev/xvdb /rw ext4 defaults,noatime 1 2' >> $INSTALLDIR/etc/fstab" /dev/mapper/dmroot / ext4 defaults,noatime 1 1
sudo su -c "echo '/dev/xvdc1 swap swap defaults 0 0' >> $INSTALLDIR/etc/fstab" /dev/xvdb /rw ext4 defaults,noatime 1 2
sudo su -c "echo '/rw/home /home none noauto,bind,defaults 0 0' >> $INSTALLDIR/etc/fstab" /dev/xvdc1 swap swap defaults 0 0
sudo su -c "echo '/dev/xvdd /usr/lib/modules ext3 defaults,noatime 0 0' >> $INSTALLDIR/etc/fstab" /rw/home /home none noauto,bind,defaults 0 0
/dev/xvdd /usr/lib/modules ext3 defaults,noatime 0 0
EOF
echo "--> Cleaning up..." echo "--> Cleaning up..."
sudo umount $INSTALLDIR/mnt/qubes-rpms-mirror-repo umount $INSTALLDIR/mnt/qubes-rpms-mirror-repo
sudo umount mnt_archlinux_dvd umount mnt_archlinux_dvd

View File

@ -3,25 +3,25 @@
set -e set -e
echo "Mounting archlinux install system into mnt_archlinux_dvd..." echo "Mounting archlinux install system into mnt_archlinux_dvd..."
sudo mount $CACHEDIR/root-image.fs mnt_archlinux_dvd mount $CACHEDIR/root-image.fs mnt_archlinux_dvd
echo "--> Starting cleanup actions" echo "--> Starting cleanup actions"
# Remove unused packages and their dependencies (make dependencies) # Remove unused packages and their dependencies (make dependencies)
cleanuppkgs=`sudo ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR pacman -Qdt | cut -d " " -f 1` cleanuppkgs=`./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR pacman -Qdt | cut -d " " -f 1`
echo "--> Packages that can be cleaned up: $cleanuppkgs" echo "--> Packages that can be cleaned up: $cleanuppkgs"
if [ -n "$cleanuppkgs" ] ; then if [ -n "$cleanuppkgs" ] ; then
sudo ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR pacman --noconfirm -Rsc $cleanuppkgs ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR pacman --noconfirm -Rsc $cleanuppkgs
fi fi
# Remove non required linux kernel # Remove non required linux kernel
echo "--> Cleaning up linux kernel" echo "--> Cleaning up linux kernel"
sudo ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR pacman --noconfirm -Rsc linux ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR pacman --noconfirm -Rsc linux
sudo ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR pacman --noconfirm -S linux-firmware ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR pacman --noconfirm -S linux-firmware
# Clean pacman cache # Clean pacman cache
sudo ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR pacman --noconfirm -Scc ./mnt_archlinux_dvd/usr/bin/arch-chroot $INSTALLDIR pacman --noconfirm -Scc
sudo umount mnt_archlinux_dvd umount mnt_archlinux_dvd
#rm -f $INSTALLDIR/var/lib/rpm/__db.00* $INSTALLDIR/var/lib/rpm/.rpm.lock #rm -f $INSTALLDIR/var/lib/rpm/__db.00* $INSTALLDIR/var/lib/rpm/.rpm.lock
#yum -c $PWD/yum.conf $YUM_OPTS clean packages --installroot=$INSTALLDIR #yum -c $PWD/yum.conf $YUM_OPTS clean packages --installroot=$INSTALLDIR

View File

@ -9,4 +9,4 @@ yum install -c $PWD/yum.conf $YUM_OPTS -y --installroot=$(pwd)/mnt @qubes-vm
echo "--> Installing 3rd party apps" echo "--> Installing 3rd party apps"
$SCRIPTSDIR/add_3rd_party_software.sh $SCRIPTSDIR/add_3rd_party_software.sh
sudo umount $PWD/mnt/proc umount $PWD/mnt/proc