Created
February 27, 2009 02:13
-
-
Save viogus/71241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
############################################ | |
# PFG (Portage Free Gentoo) Script STABLE # | |
############################################ | |
# Written by Brandon Berhent | |
# A project of zen-sources.org 2009 | |
# STABLE is for * stable gentoo installations or standard gentoo/funtoo stable tarballs | |
VERSION="0.6" | |
# Pretty printing functions | |
eerror() { | |
echo -e "\033[0m\033[1;31m!!!!!\033[0m \033[0m\033[1;35m$*\033[0m \033[0m\033[1;31m!!!!!\033[0m" | |
} | |
ewarn() { | |
echo -e "\033[0m\033[1;33m* \033[0m$*" | |
} | |
einfo() { | |
echo -e "\033[0m\033[1;32m* \033[0m$*" | |
} | |
equery() { | |
echo -ne "\033[0m\033[1;32m? \033[0m$*" | |
} | |
# <--------------- Arguments ---------------> | |
if [[ ${1} == "-h" || ${1} == "--help" || ${1} == "" ]] ; then | |
einfo "USAGE: ${0} [OPTION]" | |
einfo "" | |
einfo "Options:" | |
einfo "--normal, -n Run in normal mode. Proceeds through all steps" | |
einfo "--expert, -e Run in expert mode. Choose which steps to perform" | |
einfo "--rm-portage, -rp Only remove portage (requires paludis)." | |
einfo "--help, -h Print this help dialog." | |
exit 0 | |
elif [[ ${1} != "-n" && ${1} != "--normal" && ${1} != "-e" && ${1} != "--expert" && ${1} != "-rp" && ${1} != "--rm-portage" ]] ; then | |
eerror "Invalid Option: ${1}" | |
exit 0 | |
fi | |
# ~~~ Fail out of -rp right away if paludis isn't installed | |
if [[ ${1} == "-rp" && ! -x /usr/bin/paludis || ${1} == "--rm-portage" && ! -x /usr/bin/paludis ]] ; then | |
echo | |
eerror "\033[0m\033[1mPaludis Executable Not Found, Aborting\033[0m" | |
echo | |
exit 0 | |
fi | |
# ~~~ Introduction Stuff | |
if [[ ${1} == "-n" || ${1} == "--normal" || ${1} == "-e" || ${1} == "--expert" || ${1} == "-rp" || ${1} == "--rm-portage" ]] ; then | |
einfo "\033[0m\033[1mPortage Free Gentoo ${VERSION}\033[0m" | |
einfo "\033[0m\033[1mEliminate portage from STABLE installations or official gentoo/funtoo stable stage3's\033[0m" | |
einfo "\033[0m\033[1mReplace with Paludis! More information at: http://paludis.pioto.org/\033[0m" | |
echo | |
eerror "\033[0m\033[1mDO NOT BOTHER CIARANM, OR ANYONE ELSE PALUDIS DEV OR NOT ABOUT PALUDIS USAGE OR OTHER DUMB QUESTIONS\033[0m" | |
echo | |
ewarn "\033[0m\033[1mCTRL ^ Z Quits at ANY time!\033[0m" | |
echo | |
if [[ ${1} == "-rp" || ${1} == "--rm-portage" ]] ; then | |
ewarn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | |
ewarn "!!! You specified --rm-portage !!!" | |
ewarn "!!! Make sure you KNOW what you are doing !!!" | |
ewarn "!!! This step WILL NOT work without paludis !!!" | |
ewarn "!!! IT will ERROR OUT, soon there will be !!!" | |
ewarn "!!! Support for pkgcore --rm-portage. !!!" | |
ewarn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | |
echo | |
elif [[ ${1} == "-e" || ${1} == "--expert" ]] ; then | |
ewarn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | |
ewarn "!!! You specified --expert !!!" | |
ewarn "!!! For each step chosen the NORMAL procedure will be taken !!!" | |
ewarn "!!! instead of the RM_PORTAGE procedure !!!" | |
ewarn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | |
echo | |
elif [[ ${1} == "-n" || ${1} == "--normal" ]] ; then | |
einfo "--normal mode selected" | |
echo | |
fi | |
# <---------------- Actually Begin -----------------> | |
einfo "\033[0m\033[1mMake sure your environment is properly setup\033[0m" | |
ewarn "1) Make sure you can go on the internet" | |
ewarn "2) Make sure /dev and /proc are mounted" | |
ewarn "3) Make sure you have already run emerge --sync" | |
echo | |
equery "type \033[0m\033[1mYES\033[0m if this is correct: " | |
read input | |
if [ "$input" != "YES" ] ; then | |
echo | |
eerror "\033[0m\033[1mAborted by user\033[0m" | |
echo | |
exit 0 | |
fi | |
echo | |
einfo "\033[0m\033[1mThe procedure of this script is as follows:\033[0m" | |
einfo "XXX before procedure means that it is done differently than NORMAL procedure" | |
echo | |
einfo " 1) keyword and install paludis (USE="inquisitio ruby-bindings" emerge paludis) (NORMAL)" | |
einfo " 2) run portage2paludis (Will not overwrite existing paludis configs) (NORMAL)" | |
einfo " 3) make directories, and chmod as appropriate (tmpdir, distfiles, repository) (NORMAL/XXX_RM_PORTAGE)" | |
einfo " 4) Copy /usr/portage to /var/paludis/repositories/gentoo (NORMAL/RM_PORTAGE)" | |
einfo " 5) make repo configurations for paludis (NORMAL/RM_PORTAGE)" | |
einfo " 6) edit the gentoo base profile to strip portage dependency (NORMAL/RM_PORTAGE)" | |
einfo " 7) sync paludis, masks and keywords for paludis (NORMAL/XXX_RM_PORTAGE)" | |
einfo " 8) Strip all portage directories, save the world (NORMAL/RM_PORTAGE)" | |
einfo " 9) Importare portage because portage bug in pre-2.1.2 makes some ebuilds depend on it (NORMAL/RM_PORTAGE)" | |
einfo " 10) Install eselect-config module (NORMAL/RM_PORTAGE)" | |
echo | |
equery "Type \033[0m\033[1mQUIT\033[0m to quit, any other key to continue: " | |
read input | |
if [ "$input" == "QUIT" ] ; then | |
echo | |
eerror "\033[0m\033[1mAborted by user\033[0m" | |
echo | |
exit 0 | |
fi | |
echo | |
ewarn "\033[0m\033[1mIMPORTANT PRECAUTIONS:\033[0m" | |
ewarn "\033[0m\033[1m - This script implies a couple of things. If this is not the case for you, then you need to STOP now and edit the script by hand to make it work for you\033[0m" | |
ewarn "\033[0m\033[1m The following is all presumed to be correct by the script, anything else can cause failure!\033[0m" | |
ewarn | |
ewarn "PORT_DIR=/usr/portage" | |
ewarn "/var/lib/portage/world = location of world file" | |
if [[ ${1} == "-rp" || ${1} == "--rm-portage" ]] ; then | |
ewarn "Paludis is installed and configured correctly" | |
fi | |
echo | |
equery "Would you like to continue? (y/n): " | |
read input | |
if [ $input == "n" ] ; then | |
echo | |
eerror "\033[0m\033[1mAborted by user\033[0m" | |
echo | |
exit | |
fi | |
fi | |
if [[ ${1} == "-e" || ${1} == "--expert" ]] ; then | |
echo | |
equery "Proceed with Step 1 -- 'Installing Paludis' (y/n): " | |
read expert | |
fi | |
if [[ ${1} == "-n" || ${1} == "--normal" || ${1} == "-e" && $expert == "y" || ${1} == "--expert" && $expert == "y" ]] ; then | |
echo | |
einfo "\033[0m\033[1mStep 1\033[0m - Installing Paludis" | |
echo | |
equery "Is paludis already installed/compiled? (y/n): " | |
read input | |
if [ $input == "y" ] ; then | |
einfo "Skipping paludis install..." | |
else | |
einfo "Making paludis keyword" | |
mkdir /etc/portage; echo "sys-apps/paludis **" >> /etc/portage/package.keywords | |
equery "Would you like \033[0m\033[35mpink\033[0m paludis? (y/n): " | |
read pink | |
if [ "$pink" == "y" ] ; then | |
USE="inquisitio pink ruby-bindings" emerge paludis | |
else | |
USE="inquisitio ruby-bindings" emerge paludis | |
fi | |
fi | |
if [[ ! -x /usr/bin/paludis ]] ; then | |
echo | |
eerror "\033[0m\033[1mPaludis Executable Not Found, Aborting\033[0m" | |
echo | |
exit 0 | |
else | |
echo | |
einfo "Step 1 Successful!" | |
fi | |
fi | |
if [[ ${1} == "-e" || ${1} == "--expert" ]] ; then | |
echo | |
equery "Proceed with Step 2 -- 'Run portage2paludis' (y/n): " | |
read expert | |
fi | |
if [[ ${1} == "-n" || ${1} == "--normal" || ${1} == "-e" && $expert == "y" || ${1} == "--expert" && $expert == "y" ]] ; then | |
echo | |
einfo "\033[0m\033[1mStep 2\033[0m - Run portage2paludis" | |
echo | |
einfo " Now portage2paludis will download and run" | |
einfo " You will need to be present until the script is complete (< 1 minute)" | |
equery "type \033[0m\033[1mQUIT\033[0m to exit, anything else or enter to continue: " | |
read input | |
if [ "$input" == "QUIT" ] ; then | |
echo | |
eerror "\033[0m\033[1mAborted by user\033[0m" | |
echo | |
exit 0 | |
fi | |
einfo "Fetching portage2paludis script....." | |
wget http://zen-sources.org/files/portage2paludis.txt > /dev/null 2>&1 | |
if [[ ! -e portage2paludis.txt ]] ; then | |
eerror "Failed to get portage2paludis script from zen-sources.org" | |
exit 0 | |
fi | |
chmod +x portage2paludis.txt | |
einfo "Starting portage2paludis" | |
./portage2paludis.txt | |
rm portage2paludis.txt | |
fi | |
if [[ ${1} == "-e" || ${1} == "--expert" ]] ; then | |
echo | |
equery "Proceed with Step 3 -- 'Making directories and adjusting permissions' (y/n): " | |
read expert | |
fi | |
if [[ ${1} == "-n" || ${1} == "--normal" || ${1} == "-rp" || ${1} == "--rm-portage" || ${1} == "-e" && $expert == "y" || ${1} == "--expert" && $expert == "y" ]] ; then | |
echo | |
einfo "\033[0m\033[1mStep 3\033[0m - Making directories and adjusting permissions" | |
echo | |
equery "Do you have PORTAGE_TMPDIR somewhere else besides the default? [default: /var/tmp] (y/n): " | |
read oldtmpdir | |
if [ $oldtmpdir == "y" ] ; then | |
equery "Enter the location of PORTAGE_TMPDIR [default: /var/tmp]: " | |
read oldtmpdir | |
else | |
oldtmpdir="/var/tmp" | |
fi | |
if [[ ${1} == "-rp" || ${1} == "--rm-portage" ]] ; then | |
equery "Is PALUDIS_TMPDIR somewhere besides the default? [default: /var/tmp] (y/n): " | |
read newtmpdir | |
if [ $newtmpdir == "y" ] ; then | |
equery "Enter the location of PALUDIS_TMPDIR [default: /var/tmp]: " | |
read newtmpdir | |
else | |
newtmpdir="/var/tmp" | |
fi | |
einfo "Making directories" | |
mkdir -p /var/paludis/repositories/gentoo/.cache/names/gentoo/ | |
mkdir /var/paludis/distfiles | |
mkdir -p /var/db/paludis/repositories/installed-unpackaged/ | |
einfo "Adjusting permisions to tmpdir and distdir" | |
chmod g+wx $newtmpdir/paludis | |
chown -R paludisbuild:paludisbuild /var/paludis/distfiles | |
chown -R paludisbuild:paludisbuild $newtmpdir/paludis | |
else | |
equery "Would you like PALUDIS_TMPDIR somewhere else besides the default? [/var/tmp] (y/n): " | |
read newtmpdir | |
if [ $newtmpdir == "y" ] ; then | |
equery "Enter the desired location of PALUDIS_TMPDIR: " | |
read newtmpdir | |
mkdir -p $newtmpdir/paludis | |
echo "PALUDIS_TMPDIR="$newtmpdir"" >> /etc/paludis/bashrc | |
else | |
newtmpdir="/var/tmp" | |
mkdir -p $newtmpdir | |
fi | |
einfo "Making paludis directories" | |
mkdir -p /var/cache/paludis/write-cache | |
mkdir /var/cache/paludis/names-cache | |
mkdir -p /var/paludis/repositories/gentoo/.cache/names/gentoo/ | |
mkdir /var/paludis/distfiles /var/paludis/packages /var/paludis/rpm | |
mkdir -p /var/db/paludis/repositories/installed-unpackaged/ | |
einfo "Adjusting permisions to tmpdir and distdir" | |
chmod g+wx $newtmpdir/paludis | |
chown -R paludisbuild:paludisbuild /var/paludis/distfiles | |
chown -R paludisbuild:paludisbuild $newtmpdir/paludis | |
chown -R root:root /etc/paludis | |
chmod -R 775 /etc/paludis | |
fi | |
fi | |
if [[ ${1} == "-e" || ${1} == "--expert" ]] ; then | |
echo | |
equery "Proceed with Step 4 -- 'Copy /usr/portage to /var/paludis/repositories/gentoo' (y/n): " | |
read expert | |
fi | |
if [[ ${1} == "-n" || ${1} == "--normal" || ${1} == "-rp" || ${1} == "--rm-portage" || ${1} == "-e" && $expert == "y" || ${1} == "--expert" && $expert == "y" ]] ; then | |
echo | |
einfo "\033[0m\033[1mStep 4\033[0m - Copying gentoo tree to /var/paludis/repositories/gentoo" | |
cp -a /usr/portage/* /var/paludis/repositories/gentoo/ | |
fi | |
if [[ ${1} == "-e" || ${1} == "--expert" ]] ; then | |
echo | |
equery "Proceed with Step 5 -- 'Making repository files for paludis' (y/n): " | |
read expert | |
fi | |
if [[ ${1} == "-n" || ${1} == "--normal" || ${1} == "-rp" || ${1} == "--rm-portage" || ${1} == "-e" && $expert == "y" || ${1} == "--expert" && $expert == "y" ]] ; then | |
echo | |
einfo "\033[0m\033[1mStep 5\033[0m - Making repository files for paludis" | |
echo | |
# gentoo.conf | |
rm -rf /etc/paludis/repositories/gentoo.conf | |
echo "location = /var/paludis/repositories/gentoo" >> /etc/paludis/repositories/gentoo.conf | |
echo "sync = rsync://rsync.gentoo.org/gentoo-portage" >> /etc/paludis/repositories/gentoo.conf | |
echo "sync_options = --exclude-from=/etc/paludis/repositories/sync.exclude" >> /etc/paludis/repositories/gentoo.conf | |
echo "profiles = /var/paludis/repositories/gentoo/profiles/default/linux/amd64/2008.0" >> /etc/paludis/repositories/gentoo.conf | |
echo "distdir = /var/paludis/distfiles" >> /etc/paludis/repositories/gentoo.conf | |
echo "format = ebuild" >> /etc/paludis/repositories/gentoo.conf | |
echo "names_cache = /var/paludis/repositories/gentoo/.cache/names" >> /etc/paludis/repositories/gentoo.conf | |
echo "write_cache = /var/cache/paludis/metadata" >> /etc/paludis/repositories/gentoo.conf | |
# installed-unpackaged.conf | |
rm -rf /etc/paludis/repositories/installed-unpackages.conf | |
echo "format = installed_unpackaged" >> /etc/paludis/repositories/installed-unpackaged.conf | |
echo "location = /var/db/paludis/repositories/installed-unpackaged" >> /etc/paludis/repositories/installed-unpackaged.conf | |
fi | |
if [[ ${1} == "-e" || ${1} == "--expert" ]] ; then | |
echo | |
equery "Proceed with Step 6 -- 'Edit the base profile' (y/n): " | |
read expert | |
fi | |
if [[ ${1} == "-n" || ${1} == "--normal" || ${1} == "-rp" || ${1} == "--rm-portage" || ${1} == "-e" && $expert == "y" || ${1} == "--expert" && $expert == "y" ]] ; then | |
echo | |
einfo "\033[0m\033[1mStep 6\033[0m - Edit base profile" | |
echo | |
einfo "Fetching packages file from zen-sources.org....." | |
wget http://zen-sources.org/files/packages.txt > /dev/null 2>&1 | |
if [[ ! -e packages.txt ]] ; then | |
eerror "Failed to get packages file from zen-sources.org" | |
exit 0 | |
fi | |
mv packages.txt /var/paludis/repositories/gentoo/profiles/base/packages | |
echo "profiles" >> /etc/paludis/repositories/sync.exclude | |
fi | |
if [[ ${1} == "-e" || ${1} == "--expert" ]] ; then | |
echo | |
equery "Proceed with Step 7 -- 'Sync paludis, edit some configuration files' (y/n): " | |
read expert | |
fi | |
if [[ ${1} == "-n" || ${1} == "--normal" || ${1} == "-rp" || ${1} == "--rm-portage" || ${1} == "-e" && $expert == "y" || ${1} == "--expert" && $expert == "y" ]] ; then | |
echo | |
einfo "\033[0m\033[1mStep 7\033[0m - Sync paludis, edit some configuration files" | |
echo | |
# sync | |
paludis -s | |
# configurations | |
if [[ ${1} == "-n" || ${1} == "--normal" || ${1} == "-e" && $expert == "y" || ${1} == "--expert" && $expert == "y" ]] ; then | |
echo "world="/var/db/pkg/world"" >> /etc/paludis/environment.conf | |
echo "PALUDIS_NO_WRITE_CACHE_CLEAN=yes" >> /etc/paludis/environment.conf | |
if [ "$pink" == "y" ] ; then | |
echo "sys-apps/paludis inquisitio pink ruby-bindings" >> /etc/paludis/use.conf | |
else | |
echo "sys-apps/paludis inquisitio ruby-bindings" >> /etc/paludis/use.conf | |
fi | |
fi | |
fi | |
if [[ ${1} == "-e" || ${1} == "--expert" ]] ; then | |
echo | |
equery "Proceed with Step 8 -- 'Save the world, and remove portage completely' (y/n): " | |
read expert | |
fi | |
if [[ ${1} == "-n" || ${1} == "--normal" || ${1} == "-rp" || ${1} == "--rm-portage" || ${1} == "-e" && $expert == "y" || ${1} == "--expert" && $expert == "y" ]] ; then | |
echo | |
einfo "\033[0m\033[1mStep 8\033[0m - Save the world, and remove portage completely" | |
echo | |
# save the world | |
mv /var/db/pkg/world /var/db/pkg/world.BACKUP | |
cp /var/lib/portage/world /var/db/pkg | |
cp /etc/make.globals /make.globals # save make.globals | |
# portage cleanse begin | |
paludis -u portage --permit-unsafe-uninstalls | |
if [[ -x /usr/bin/emerge ]] ; then | |
echo | |
eerror "\033[0m\033[1mFailed to Uninstall Portage\033[0m" | |
echo | |
exit 0 | |
fi | |
# portage cleanse finish | |
rm -rf /etc/make.conf* /etc/make.profile /etc/portage /usr/portage /usr/lib/portage /usr/lib64/portage /usr/lib32/portage /var/lib/portage /var/log/portage /var/cache/edb/dep/usr/portage $oldtmpdir/portage | |
echo | |
# make make.globals, define some things for portage commands to work | |
rm /etc/make.globals; mv /make.globals /etc | |
echo "PORTDIR=/var/paludis/repositories/gentoo" >> /etc/make.globals | |
echo "DISTDIR=/var/paludis/distfiles" >> /etc/make.globals | |
echo "PKGDIR=/var/paludis/packages" >> /etc/make.globals | |
echo "RPMDIR=/var/paludis/rpm" >> /etc/make.globals | |
fi | |
if [[ ${1} == "-e" || ${1} == "--expert" ]] ; then | |
echo | |
equery "Proceed with Step 9 -- 'Importare portage and finish up' (y/n): " | |
read expert | |
fi | |
if [[ ${1} == "-n" || ${1} == "--normal" || ${1} == "-rp" || ${1} == "--rm-portage" || ${1} == "-e" && $expert == "y" || ${1} == "--expert" && $expert == "y" ]] ; then | |
echo | |
einfo "\033[0m\033[1mStep 9\033[0m - Importare portage and finish up" | |
echo | |
# importare needed until no more ebuilds hold the portage dependency | |
mkdir dir | |
importare -il dir/ sys-apps/portage 2.1.6.7 0 | |
rm -rf dir | |
# mask any newer portage upgrades | |
echo ">sys-apps/portage-2.1.6.7" >> /etc/paludis/package_mask.conf | |
fi | |
if [[ ${1} == "-e" || ${1} == "--expert" ]] ; then | |
echo | |
equery "Proceed with Step 10 -- 'Install eselect config module' (y/n): " | |
read expert | |
fi | |
if [[ ${1} == "-n" || ${1} == "--normal" || ${1} == "-rp" || ${1} == "--rm-portage" || ${1} == "-e" && $expert == "y" || ${1} == "--expert" && $expert == "y" ]] ; then | |
echo | |
einfo "\033[0m\033[1mStep 10\033[0m - Install eselect config module" | |
echo | |
einfo "Fetching zen-overlay/installing eselect-config" | |
equery "Proceed? (y/n): " | |
read proceed | |
if [[ ${proceed} == "y" ]] ; then | |
einfo "Creating configuration with playman" | |
playman -a zen-overlay | |
if [[ ! -e /etc/paludis/repositories/zen-overlay.conf ]] ; then | |
eerror "Failed to get zen-overlay with playman" | |
exit 0 | |
else | |
mkdir /var/paludis/repositories/zen-overlay/.cache | |
fi | |
einfo "Syncing zen-overlay" | |
paludis -s x-zen-overlay | |
einfo "Installing eselect-config" | |
paludis -i eselect-config::zen-overlay | |
else | |
eerror "Aborted by user" | |
exit 0 | |
fi | |
echo | |
fi | |
if [[ ${1} == "-n" || ${1} == "--normal" || ${1} == "-e" || ${1} == "--expert" || ${1} == "-rp" || ${1} == "--rm-portage" ]] ; then | |
einfo "<----- \033[0m\033[1mScript Finished, Time to exit\033[0m ------>" | |
fi | |
# <----------- Script End -------------> | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment