#!/bin/bash # # This script is intended to configure a user's home directory # and config files so they can build rpms as a user. It should # be run as that user. # # Todd Lyons # v1.0 05-Aug-2003 RPMRC="$HOME/.rpmrc" RPMMACROS="$HOME/.rpmmacros" unset FORCE echo # NO NO NO Root is NOT allowed if [ `id -u` -eq "0" ]; then echo "Not allowed to run this as root!" echo "Building RPMs as root is dangerous!" echo "Login as a regular user to run this" echo "script and to build RPMs." echo exit 1 fi if [ ! "$1" ]; then echo "Default setting is to keep existing files." else case "$1" in -f|--force) echo "WARNING: Will overwrite if files if they already exist." FORCE=set ;; -h|--help) echo "`basename $0` parameters" echo "-f --force force overwrite of existing files" echo "-h --help this help screen" ;; *) echo "Unknown option $1. For help:" echo "`basename $0` --help" echo exit 2 ;; esac fi cat << _AOL This script will set up your home directory to allow you to build RPMs as a regular user. Your home is configured as: $HOME Press N if this is incorrect or the ENTER key to continue. _AOL read input1 case "$input1" in n|N) echo "Exiting." exit 0 ;; esac if [ ! -e $RPMRC -o -n "$FORCE" ]; then cat << _BOL > $RPMRC buildarchtranslate: i386: i586 buildarchtranslate: i486: i586 buildarchtranslate: i586: i586 buildarchtranslate: i686: i586 _BOL echo "File $RPMRC created." else echo "File $RPMRC already exists. Skipping." fi if [ ! -e $RPMMACROS -o -n "$FORCE" ]; then cat << _COL > $RPMMACROS %_target linux %_topdir %(echo \$HOME)/RPM %_tmppath %(echo \$HOME)/RPM/tmp # Provided as a reference # %_signature gpg # %_gpg_name 9716DB0A # %_gpg_path %(echo \$HOME)/.gnupg %distribution Mandrake %vendor Personal build of %(echo \$USER)@%(echo \$HOSTNAME) _COL echo "File $RPMMACROS created." else echo "File $RPMMACROS already exists. Skipping." fi mkdir -p ~/RPM/{BUILD,SOURCES,SPECS,SRPMS,tmp} mkdir -p ~/RPM/RPMS/{i586,noarch} cat << _DOL When source RPMs are installed, the sources will be in $HOME/RPM/SOURCES and the spec files will be in $HOME/RPM/SPECS When using either -bp, -bc, -bi, -bb, or -ba to build RPMs, the building occurs in $HOME/RPM/BUILD and the "chrooted installation" occurs in $HOME/RPM/tmp Built RPMs will be in either $HOME/RPM/BUILD/i586 or $HOME/RPM/BUILD/noarch _DOL