#!/bin/sh -efu # configure hasher (implies that 30-users has been run already) ARCH="$(rpm --eval '%_host_cpu')" [ -n "$ARCH" ] || exit 2 gray="$(echo -ne "\\033[0;37m")" white="$(echo -ne "\\033[1;37m")" cyan="$(echo -ne "\\033[1;36m")" # root cat >> /root/.bash_profile << EOF ram="\$(awk '/^MemTotal/ { print int(\$2/1024+0.5) }' /proc/meminfo)" swap="\$(awk '/^SwapTotal/ { print int(\$2/1024+0.5) }' /proc/meminfo)" tmpfs="\$(df -kT /tmp 2>/dev/null \\ | awk '/^[a-zA-Z_0-9/-]+[[:space:]]+tmpfs/ { print int(\$3/1024); }')" cat << EOH Welcome to live builder host system! Memory: $cyan\${ram}M$gray, swap: $cyan\${swap}M$gray Autoconfigured tmpfs on /tmp: $cyan\${tmpfs}M$gray Run ${white}swapon${gray}(8) on any local swaps you might like to employ followed by ${white}service livecd-tmpfs restart${gray} to reconfigure tmpfs EOH EOF # predefined passwordless livecd user USER="kometa" if ! id "$USER" >&/dev/null; then echo "No such user '$USER'" >&2 exit fi # ~ HOME="/home/$USER" install -dm750 -o "$USER" -g "$USER" "$HOME" # http://altlinux.org/tmpfs TMP="/tmp/.private/$USER" # we honestly don't know much more if type -t git && type -t su; then su - -c "git config --global user.email $USER@localhost" "$USER" su - -c "git config --global user.name 'live builder'" "$USER" fi >&/dev/null # developer should feel comfortable, eh? ;-) ZSHELL="/bin/zsh" if [ -x "$ZSHELL" ]; then chsh -s "$ZSHELL" "$USER" install -m644 -o "$USER" -g "$USER" /dev/null "$HOME/.zshrc" cat >> "$HOME/.zsh_history" <<-EOF git clone git://git.altlinux.org/gears/m/mkimage-profiles.git && cd mkimage-profiles && make help/distro make -C /usr/share/mkimage-profiles grub.iso git clone git://git.altlinux.org/gears/h/hello.git && cd hello && gear-hsh EOF fi if type -t screen; then cat >> "$HOME/.screenrc" <<-EOF caption always "%{+b rk}%H%{gk} |%c %{yk}%d.%m.%Y | %72=Load: %l %{wk}" defscrollback 1000 EOF fi >&/dev/null cat >> "$HOME/.profile" << EOF alias l='ls -l' alias m='cd /usr/share/mkimage-profiles' clear cat << EOH Welcome to live builder environment! Here are some ALT package/image build tools prepared for you: * ${white}gear${gray}(1) -- see ${cyan}http://en.altlinux.org/gear${gray}; * ${white}hsh${gray}(1) -- see ${cyan}http://en.altlinux.org/hasher${gray}; * ${white}mkimage${gray} -- see ${cyan}http://en.altlinux.org/mkimage${gray}; * ${white}mkimage-profiles${gray} described in Russian at ${cyan}http://altlinux.org/m-p${gray} Examples (use right/middle mouse button to paste; see ~/hasher/repo/): * ${white}git clone git://git.altlinux.org/gears/h/hello.git && cd hello && gear-hsh${gray} * ${white}make -C /usr/share/mkimage-profiles grub.iso${gray} EOH EOF # rpm sed -i '/^%_tmppath.*tmp$/d' "$HOME/.rpmmacros" cat << EOF >> "$HOME/.rpmmacros" %packager Unknown %_target_cpu $ARCH %_tmppath $TMP %_sourcedir %{_topsrcdir}/SOURCES/%name EOF # hasher WORKDIR="$TMP/hasher" ln -s "$WORKDIR" "$HOME/hasher" mkdir "$HOME/.hasher" cat >> "$HOME/.hasher/config" << EOF packager="\$(rpm --eval %packager)" def_target=$ARCH export GCC_USE_CCACHE=1 mkdir -p "$WORKDIR" EOF # create apt.conf for supported ARCHES and BRANCHES # use format: $BRANCH-$ARCH create_apt_conf () { local PORTS= local SIGN= local BRANCH=$(echo "$1" | cut -f1 -d '-') local ARCH=$(echo "$1" | cut -f2 -d '-') local EXT_BRANCH=$(echo "$1" | cut -f3 -d '-') [ -n "$ARCH" ] || [ -n "$BRANCH" ] || exit 1 [ -z "$EXT_BRANCH" ] || [ "$EXT_BRANCH" = port ] || exit 1 [ "$EXT_BRANCH" = port ] && PORTS=1 if [ "$BRANCH" = sisyphus ]; then BRANCH_PATH=Sisyphus SIGN='[alt]' else BRANCH_PATH=$BRANCH/branch SIGN="[$BRANCH]" fi if [ -n "$PORTS" ]; then BRANCH_PATH=ports/$ARCH/$BRANCH SIGN="[$BRANCH-$ARCH]" fi mkdir -p "$HOME/apt/lists/partial" \ "$HOME/apt/cache/$BRANCH/$ARCH/archives/partial" \ "$HOME/apt/cache/$BRANCH/noarch/archives/partial" cat > "$HOME/apt/apt.conf.$BRANCH.$ARCH" << EOF Dir::Etc::main "/dev/null"; Dir::Etc::SourceParts "/var/empty"; Dir::Etc::SourceList "$HOME/apt/sources.list.$BRANCH.$ARCH"; Dir::State::lists "$HOME/apt/lists/"; Dir::Cache "$HOME/apt/cache/$BRANCH/$ARCH"; ;Debug::pkgMarkInstall "true"; ;Debug::pkgProblemResolver "true"; EOF cat > "$HOME/apt/sources.list.$BRANCH.$ARCH" << EOF rpm-dir file://$HOME/hasher/repo $ARCH hasher # Official repo (slow) #rpm $SIGN http://ftp.altlinux.org/pub/distributions/ALTLinux/$BRANCH_PATH $ARCH classic #rpm $SIGN http://ftp.altlinux.org/pub/distributions/ALTLinux/$BRANCH_PATH noarch classic # Yandex mirror (fast) rpm $SIGN http://mirror.yandex.ru/altlinux/$BRANCH_PATH $ARCH classic rpm $SIGN http://mirror.yandex.ru/altlinux/$BRANCH_PATH noarch classic EOF } target_apt_confs=" sisyphus-x86_64 sisyphus-i586 sisyphus-aarch64 sisyphus-armh sisyphus-ppc64le sisyphus-mipsel-port sisyphus-riscv64-port p10-x86_64 p10-i586 p10-aarch64 p10-armh p10-ppc64le p9-x86_64 p9-i586 p9-aarch64 p9-armh p9-ppc64le p9-mipsel-port " for target_apt_conf in $target_apt_confs; do create_apt_conf "$target_apt_conf" done # setup mkimage-profiles settings # add mkimage-profiles settings mkdir -p $HOME/.mkimage cat > $HOME/.mkimage/profiles.mk << EOF ifneq (,\$(BRANCH)) APTCONF = ~/apt/apt.conf.\$(BRANCH).\$(ARCH) IMAGEDIR = ~/out/\$(BRANCH)/\$(shell date +%Y%m%d) else APTCONF = ~/apt/apt.conf.sisyphus.\$(ARCH) IMAGEDIR = ~/out/sisyphus/\$(shell date +%Y%m%d) endif CLEAN = 1 DEBUG = 1 REPORT = 1 NO_SYMLINK = 1 #NICE = 1 #QUIET = 1 EOF # fix owner:group chown $USER:$USER -R "$HOME" # online repo needs network not isolation echo "export share_network=1" >> /etc/profile.d/hasher.sh chmod +x /etc/profile.d/hasher.sh # squashfs-tools 4.3+ echo "allowed_mountpoints=/proc" >> /etc/hasher-priv/system # requisite hasher-useradd "$USER"