Updated 30 Nov 2022
This page shows how Gentoo Studio is built. Comments and suggestions are welcome.
In the beginning, Gentoo Studio was an audio-for-Gentoo guide. Then I started manually creating stage4’s. Then I migrated to Catalyst. Somewhere along the way, NeddySeagoon created a sticky on forums.gentoo.org for Gentoo Studio. Thanks, Neddy!
The stage4 tarball is built with Catalyst on a virtual machine. The tarball is then test-installed in another virtual machine, followed by a test install on a spare physical computer if I have one.
Below are the files used to produce Gentoo Studio. (I may put these on github.)
stage1.spec
subarch: amd64
target: stage1
version_stamp: latest
rel_type: default
profile: default/linux/amd64/17.1/systemd
snapshot: latest
source_subpath: default/stage3seed
update_seed: yes
update_seed_command: --update --deep --newuse --autounmask-write @system @world
stage2.spec
subarch: amd64
target: stage2
version_stamp: latest
rel_type: default
profile: default/linux/amd64/17.1/systemd
snapshot: latest
source_subpath: default/stage1-amd64-latest
stage3.spec
subarch: amd64
target: stage3
version_stamp: latest
rel_type: default
profile: default/linux/amd64/17.1/systemd
snapshot: latest
source_subpath: default/stage2-amd64-latest
portage_confdir: /home/audiodef/catalyst/etc/portage
stage4.spec
subarch: amd64
version_stamp: latest
target: stage4
rel_type: default
profile: default/linux/amd64/17.1/desktop/systemd
snapshot: latest
source_subpath: default/stage3-amd64-latest
portage_confdir: /home/audiodef/catalyst/etc/portage
portage_overlay: /var/lib/layman/audio-overlay
# Use flags we want that aren't here are provided by the desktop profile globally
# At some point these should all be checked out to make sure they're still in use (qt3support?)
stage4/use:
aacplus
audacious
cddb
cdio
consolekit
corefonts
dssi
encode
equalizer
faac
ffmpeg
fftw
fluidsynth
freesound
gudev
gtk3
hwdb
id3
id3tag
ieee1394
jack
ladspa
lame
libsamplerate
lv2
matroska
midi
minizip
mpg123
musepack
musicbrainz
netjack
opus
pcre16
python
python_targets_python3_5
qt3support
quicktime
realtime
rubberband
shine
shout
skins
sndfile
soundtouch
taglib
theora
timidity
twolame
vamp
vcd
vst
wav
wavpack
xine
xkb
xvfb
xvmc
-pulseaudio
-xscreensaver
# Notes:
# /dev/vcs-git required for eix-sync to work
# Some of these packages are from audio-overlay
# Check the devnotes file for packages that failed to compile during stage4
stage4/packages:
app-admin/syslog-ng
app-editors/nano
app-portage/cpuid2cpuflags
app-portage/eix
app-portage/gentoolkit
app-portage/smart-live-rebuild
app-portage/ufed
dev-vcs/git
gnome-extra/nm-applet
media-plugins/adlplug
media-plugins/alsa-plugins
media-plugins/artyfx
media-plugins/bitrot
media-plugins/calf
media-plugins/deteriorate-lv2
media-plugins/distrho-ports
media-plugins/dragonfly-reverb
media-plugins/fabla
media-plugins/opnplug
media-plugins/sorcer
media-sound/a2jmidid
media-sound/alsa-tools
media-sound/alsa-utils
media-sound/amsynth
media-sound/ardour
media-sound/audacious
media-sound/audacity
media-sound/bristol
media-sound/cadence
media-sound/chuck
media-sound/fluidsynth
media-sound/frescobaldi
media-sound/hydrogen
media-sound/jack-rack
media-sound/jack2
media-sound/jamin
media-sound/linuxsampler
media-sound/lmms
media-sound/luppp
media-sound/musescore
media-sound/new-session-manager
media-sound/pure-data
media-sound/qjackctl
media-sound/qsampler
media-sound/rosegarden
net-misc/dhcpcd
net-misc/networkmanager
sys-apps/usbutils
sys-boot/grub
sys-kernel/genkernel
sys-kernel/linux-firmware
sys-kernel/rt-sources
x11-base/xorg-server
x11-misc/lightdm
xfce-base/xfce4-meta
xfce-extra/xfce4-alsa-plugin
xfce-base/xfce4-power-manager
# Don't use stage4/empty. We might need relevant dirs in fsscript.
stage4/fsscript: /home/audiodef/catalyst/fsscript.sh
fsscript.sh
#!/bin/bash
### SYSTEM FILES ###
# fstab should be done by the installer script because we don't know yet whether the user has legacy or EFI.
# This section should precede system updates so eix-sync will pick up the overlay.
# Using /var/lib/layman makes this compatible in case the user installs layman.
mkdir -p /etc/portage/repos.conf
cat > /etc/sysctl.conf <<EOF
vm.swappiness = 10
dev.rtc.max-user-freq=3072
dev.hpet.max-user-freq=3072
EOF
cat > /etc/security/limits.d/audio.conf <<EOF
@audio - rtprio 95
@audio - memlock unlimited
EOF
cat > /etc/udev/rules.d/firewire.rules <<EOF
KERNEL=="fw0", GROUP="audio", MODE="0664"
KERNEL=="fw1", GROUP="audio", MODE="0664"
KERNEL=="fw2", GROUP="audio", MODE="0664"
EOF
cat > /etc/udev/rules.d/timer-permissions.rules <<EOF
KERNEL=="rtc0", GROUP="audio"
KERNEL=="hpet", GROUP="audio"
EOF
cat > /etc/portage/repos.conf/audio-overlay.conf <<EOF
[audio-overlay]
location = /var/lib/layman/audio-overlay
sync-type = git
sync-uri = https://github.com/gentoo-audio/audio-overlay.git
auto-sync = yes
EOF
cat > /etc/conf.d/display-manager <<EOF
CHECKVT=7
DISPLAYMANAGER="lightdm"
EOF
cat >> /etc/portage/make.conf <<EOF
ALSA_CARDS="*"
EMERGE_DEFAULT_OPTS="--quiet"
CONFIG_PROTECT="protect-owned"
MAKEOPTS="-j2"
EOF
# TODO: Check if snd-seq is now auto-loaded. It wasn't in previous iterations.
### SYSTEM UPDATES ###
cp /usr/share/portage/config/repos.conf /etc/portage/repos.conf/gentoo.conf
emerge-webrsync
eix-sync
emerge -uDN --keep-going --with-bdeps=y --backtrack=250 @system @world
smart-live-rebuild
emerge --depclean
revdep-rebuild
### KERNEL ***
# Kernel would not compile in stage4.spec due to not finding /tmp/kerncache/rt/sources.
# Kernel has to be genkernelled now to generate a .config, unless we can find a shorter way to do this.
# Make bzImage only to save time.
eselect kernel set 1
genkernel bzImage
# In order to get full preemption, we need to:
# replace
# CONFIG_PREEMPT_VOLUNTARY=y
# CONFIG_PREEMPT is not set
# with
# CONFIG_PREEMPT=y
# CONFIG_PREEMPT_COUNT=y
# CONFIG_PREEMPTION=y
sed -i 's/CONFIG_PREEMPT_VOLUNTARY=y/CONFIG_PREEMPT=y\nCONFIG_PREEMPT_COUNT=y\nCONFIG_PREEMPTION=y/' /usr/src/linux/.config
sed -i 's/# CONFIG_PREEMPT is not set//' /usr/src/linux/.config
# Save a cp of the config for safekeeping.
cp /usr/src/linux/.config /usr/src/linux/.config_full_preempt
# Now run genkernel again to make this take effect.
# genkernel will run a silent make oldconfig, accepting the default changes relevant to config_preempt.
genkernel --kernel-config=/usr/src/linux/.config_full_preempt all
# Get rid of old kernels from previous build runs
rm /boot/*.old
# Old news shouldn't concern new users
eselect news read all
### STAGE4/EMPTY REPLACEMENT ***
# This reduces the tarball size by rm'ing !needed files.
rm /var/cache/distfiles/*
rm -rf /usr/src/linux/*
### ENABLE SERIVCES
systemctl enable lightdm
systemctl enable NetworkManager
CUSTOMIZE DEFAULT APPEARANCE FOR NEW USERS
# Make sure that the system update in the installer happens after a new user is created
wget https://gentoostudio.org/src/xfce4-desktop.xml
wget https://gentoostudio.org/src/GentooStudio2023.png
mv xfce4-desktop.xml /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/
mv GentooStudio2023.png /usr/share/backgrounds/xfce/
catalyst.conf
# /etc/catalyst/catalyst.conf
digests="blake2 sha512"
contents="auto"
distdir="/var/cache/distfiles"
envscript="/etc/catalyst/catalystrc"
hash_function="crc32"
options="bindist kerncache pkgcache seedcache"
portdir="/var/db/repos/gentoo"
repo_basedir="/var/db/repos"
repo_name="gentoo"
target_distdir="/var/cache/distfiles"
target_pkgdir="/var/cache/binpkgs"
sharedir="/usr/share/catalyst"
shdir="%(sharedir)s/targets"
snapshot_cache="/var/tmp/catalyst/snapshot_cache"
storedir="/var/tmp/catalyst"
source_matching="strict"
buildall.sh
#!/bin/sh
### GLOBAL VARS
url="https://distfiles.gentoo.org/releases/amd64/autobuilds/"
txtfile="latest-stage3-amd64-desktop-systemd.txt"
email="webmaster@gentoostudio.org"
### ERROR HANDLING
# Usage: create_mailmsg "Subject" "message_body"
create_mailmsg(){
echo -e "Subject: $1" > mail_msg
echo -e "\n" >> mail_msg
echo -e "$2" >> mail_msg
ssmtp -v $email < mail_msg
echo "Mail sent to $email because: $2"
rm mail_msg
}
### PART 1: UPDATE SEED
# Get text file describing latest stage3 tarball.
# -O option circumvents wget creating a new file on every run and gives us a fixed filename to use.
# The wget -S option is --server-response, which can be grepped.
# ssmtp.conf has been configured.
if [[ `wget -S --spider $url$txtfile 2>&1 | grep 'HTTP/1.1 200 OK'` ]];
then wget -O latest.txt $url$txtfile;
else
create_mailmsg "wget failed (text file)" "wget failed to fetch text file at: $url$txtfile"
exit 1;
fi
# Parse text file for URL
# Use tail cmd to read last line of file, which is all we need,
# then use sed to chop off everything after the space in that line
# When wget is done, move the file to where its needed
# (The mv destination is a symlink)
# Not sure we need an ifelse here. If the above check passes, this wget should work.
latest=$(tail -n 1 latest.txt | sed 's#[[:space:]].*##')
wget -O stage3seed.tar.xz $url$latest
if [ $? != 0 ]; then
create_mailmsg "wget failed to fetch seed" "wget failed to fetch seed at: $url$latest"
exit 1;
fi
# Trailing slash prevents mv'ing seed to a new file.
mv stage3seed.tar.xz builddir/
if [ $? != 0 ]; then
# Not sure why this would fail, except for hardware issues, but just in case...
create_mailmsg "Failed to mv seed" "Seed file could not be moved to build dir."
exit 1;
fi
### PART 2: SYNC
emaint -a sync
if [ $? != 0 ]; then
# Not sure why this would fail unless the emaint command changes.
create_mailmsg "emaint failed" "emaint -a sync failed."
exit 1;
fi
emerge -uDN --keep-going --backtrack=250 @world
if [ $? != 0 ]; then
# Portage returns != 0 if any packages are skipped, but this is non-critical.
create_mailmsg "System update failed" "Portage failed to complete a system update, but catalyst was allowed to continue."
# No need to exit, catalyst can still proceed.
fi
catalyst -s latest
if [ $? != 0 ]; then
create_mailmsg "Catalyst snapshot failed" "Catalyst failed to create the latest snapshot."
exit 1;
fi
### PART 3: STAGES
catalyst -af stage1.spec
if [ $? != 0 ]; then
create_mailmsg "Catalyst stage1 failed" "Catalyst failed to build stage1."
exit 1;
fi
catalyst -af stage2.spec
if [ $? != 0 ]; then
create_mailmsg "Catalyst stage2 failed" "Catalyst failed to build stage2."
exit 1;
fi
catalyst -af stage3.spec
if [ $? != 0 ]; then
create_mailmsg "Catalyst stage3 failed" "Catalyst failed to build stage3."
exit 1;
fi
catalyst -af stage4.spec
if [ $? != 0 ]; then
create_mailmsg "Catalyst stage4 failed" "Catalyst failed to build stage4/fscript."
exit 1;
fi
# scp tarball to host.
sshpass -vp "(password)" scp builddir/stage4-amd64-latest.tar.bz2 audiodef@(IP):/home/audiodef/
if [ $? != 0 ]; then
create_mailmsg "scp failed" "Could not scp the completed tarball to the host."
exit 1;
fi
# Notify that the build is done.
completion_time=$(date)
create_mailmsg "Catalyst build complete" "The latest catalyst build completed at $completion_time."
install.sh
#!/bin/bash
##########################
# Steps in this installer
# 1. User enters disk to install onto
# 2. Disk is partitioned and formatted
# 3. Tarball is installed
# 4. Prepare for chroot and call chroot_install to take over
##########################
# Cannot use comments inside heredoc, so they are here for reference:
# fdisk (device)
# g # Create GPT label
# n # New partition
# 1 # Partition number
# # Default first block (press Enter)
# +256M # Partition size
# t # Set partition type
# 1 # Only one partition, fdisk assumes this one, set it to type 1, EFI
# n # New partition
# 2 # Partition 2
# # Default first block (press Enter)
# +512M # Partition size
# t # Set partition type
# 2 # Choose partition 2
# 19 # Set partition to type swap
# n # New partition
# 3 # Partition 3
# # Default first block (press Enter)
# # Default last block (press Enter)
# w # Save partition table & quit
### USER MUST ENTER DISK TO INSTALL ONTO
echo "NOTE THAT THIS INSTALLER ASSUMES A MODERN EFI SYSTEM."
echo "If you want to dual-boot with Windows, exit installer and use manuall install instructions."
echo "You need to choose a disk to install Gentoo Studio on."
echo "You should choose a disk that is either blank or does not contain data you want to keep."
echo "!!!! ONCE YOU SELECT A DISK, EVERYTHING ON IT WILL BE ERASED !!!!"
echo "The installer will show you the available disks on your system."
echo "Look for the line that says 'logical name'."
echo "This installer assumes you know how to choose a disk to install on."
# Read output of lshw into var
alldisks=$(lshw -class disk | grep '*-disk\|*-namespace\|description\|logical name\|size:')
#echo "$alldisks" # Uncomment for testing
# Strip away anything named "namespace". We want disks only
disksonly=${alldisks//\*-namespace*}
echo "$disksonly\n"
# Ask user to enter device
echo "Enter logical name of device (ex: /dev/sda):"
read installdevice
# Check if device exists, if not, ask user to check for typos
echo "Validating $installdevice: "
if [[ $(file -s $installdevice) == *"No such"* ]]; then
echo "No such device. Check your typing and try again."
echo "Installer will exit. Re-run when ready."
exit 1;
else
echo "Device confirmed. Proceeding with install."
fi
### PARTITION DISK, SEE COMMENTS ABOVE
fdisk /dev/sda << FDISK_CMDS
g
n
1
+256M
t
1
n
2
+512M
t
2
19
n
3
w
FDISK_CMDS
### Create filesystems
mkfs.fat -F 32 /dev/sda1
mkfs.ext4 /dev/sda3
mkswap /dev/sda2
swapon /dev/sda2
### Install base system
mkdir -p /mnt/gentoo/boot
mount /dev/sda3 /mnt/gentoo
cd /mnt/gentoo
wget https://gentoostudio.org/src/stage4-amd64-latest.tar.bz2
tar xvjpf stage4-amd64-latest.tar.bz2 --xattrs --numeric-owner
cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf
cp -L /etc/resolv.conf /mnt/gentoo/etc/
# Kernel is in /boot, so we need to move kernel files out of the way to mount sda1
mkdir /mnt/gentoo/kernfiles
mv /mnt/gentoo/boot/* /mnt/gentoo/kernfiles/
mount /dev/sda1 /mnt/gentoo/boot
mv /mnt/gentoo/kernfiles/* /mnt/gentoo/boot/
### Chroot into system and run chroot_install
mount -t proc /proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
mount --make-rslave /mnt/gentoo/sys
mount --make-rslave /mnt/gentoo/dev
mount --bind /run /mnt/gentoo/run
mount --make-slave /mnt/gentoo/run
wget -O chroot_install.sh https://gentoostudio.org/src/chroot_install.sh
chmod +x chroot_install.sh
echo "$installdevice" > installdevice.txt
chroot /mnt/gentoo/ ./chroot_install.sh
### We're done here. The rest is handled by chroot_install
chroot_install.sh
#!/bin/sh
#################################
# STEPS THIS INSTALLER TAKES
# 1. . /etc/profile
# 2. Read install device (ex: /dev/sda)
# 3. Configure fstab
# 4. Configure grub
# 5. Users and passwords
# 6. Configure make.conf
# 7. System update
# 8. Cleanup
# 9. Parting advice
#################################
source /etc/profile
# Read from the install device file set pre-chroot
file="installdevice.txt"
while read -r line; do
installdevice="$line"
done <$file
### TESTING STEP
#echo "Installing to: $installdevice"
#exit 1;
# /etc/fstab
# Store parts in vars, otherwise bash will think the numbers are part of the vars
bootpart="1"
rootpart="3"
swappart="2"
cat > /etc/fstab <<EOF
$installdevice$bootpart /boot vfat defaults,noatime 0 2
$installdevice$rootpart / ext4 noatime 0 1
$installdevice$swappart none swap sw 0 0
EOF
### TESTING STEP
#less /etc/fstab
#exit 1;
# Grub
grub-install --target=x86_64-efi --efi-directory=/boot --removable
grub-mkconfig -o /boot/grub/grub.cfg
### TESTING STEP
# Nothing really to do except exit so I can read the output of grub to make sure it didn't fail.
#exit 1;
#Passwords
echo "Enter a password for root:"
passwd
echo "Enter a regular username to use:"
read reguser
useradd -m -G users,wheel,audio,plugdev -s /bin/bash $reguser
echo "Enter a password for $reguser:"
passwd $reguser
# Config make.conf
cpuflags=$(cpuid2cpuflags)
flags=${cpuflags/: /=\"}
endquote="\""
echo "$flags$endquote" >> /etc/portage/make.conf
echo "EMERGE_DEFAULT_OPTS=\"--quiet\"" >> /etc/portage/make.conf
numjobs=$(($(nproc)-1))
echo "MAKEOPTS=\"-j$numjobs\"" >> /etc/portage/make.conf
# System update to incorporate newly set flags
echo "Installer will now perform a system update. This could take a while."
echo "It is highly recommended to update your system regularly,"
echo "such as weekly or monthly."
echo "Gentoo is a rolling release system so waiting too long to update"
echo "could make it problematic."
read -p "Press Enter to continue"
emerge-webrsync
eix-sync
# Hold off on this until testing is complete
emerge -auDN --keep-going --with-bdeps=y --backtrack=250 @system @world
# Cleanup
rm installdevice.txt
rm -rv /kernfiles
rm stage4-amd64-latest.tar.bz2
# Final notices
echo "######################################"
echo "Install complete. Remove/disable the boot medium you used and reboot."
echo "Don't forget to select Xfce4 in the upper right corner when you first log in."
echo "######################################"
Links
More from Gentoo Studio
References
-
Recent Posts
Recent Comments
- audiodef on Development Continues
- Peter on Development Continues
- audiodef on Development Continues
- gentoo noob on Development Continues
- Stefan on Development Continues
Archives