Since Han is working on an updated skeleton file, I thought some of you
might be interested in this.

This is a little script that I use all the time to make a non-root RPM
building environment (directories, .rpmrc, .rpmmacros).

It's not perfect and anyone is welcome to improve it, but it would be
handy to have included with the other Mandrake RPM tools.  Also feel
free to come up with a better name.  :-)

Austin

P.S. At the very least, this should be installed on klama!
-- 
                        Austin Acton Hon.B.Sc.
             Synthetic Organic Chemist, Teaching Assistant
           Department of Chemistry, York University, Toronto
             MandrakeClub Volunteer (www.mandrakeclub.com)
                     homepage: www.groundstate.ca
#!/bin/bash

# RPM Build Environment Generator

# Copyright 2003 Austin Acton <[EMAIL PROTECTED]>
# This software may be freely redistributed under the terms of the GNU
# public license.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

printhelp () {
echo 'usage: rpm-begen [-f] [username]'
echo 'creates an RPM building direcory tree in the users home directory'
echo 'and sets .rpmrc and .rpmmacros'
echo 'username is optional and defaults to current user'
echo '-f forces overwrite of .rpmrc and .rpmmacros'
}

#discover options
if [ $1 = "-h" ]
then
	printhelp
	exit
fi
if [ $1 = "-f" ]
then
	FORCE=1
	if [ "$#" = "2" ]
	then
		USERNAME=$2
	else
		USERNAME=${USER}
	fi
else
	if [ "$#" = "1" ]
	then
		USERNAME=$1
	else
		USERNAME=${USER}
	fi
fi

#build tree
for i in BUILD SRPMS RPMS/i586 tmp SPECS
do
	mkdir -p /home/${USERNAME}/rpm/$i
done
chown -R $USERNAME /home/${USERNAME}/rpm
chgrp -R $USERNAME /home/${USERNAME}/rpm
echo "Done building /home/${USERNAME}/rpm tree"

#define config files
rpmrc () {
echo 'buildarchtranslate: i386: i586' > /home/${USERNAME}/.rpmrc
echo 'buildarchtranslate: i486: i586' >> /home/${USERNAME}/.rpmrc
echo 'buildarchtranslate: i586: i586' >> /home/${USERNAME}/.rpmrc
echo 'buildarchtranslate: i686: i586' >> /home/${USERNAME}/.rpmrc
echo "/home/${USERNAME}/.rpmrc created"
}
rpmmacros () {
echo "%_topdir /home/${USERNAME}/rpm" > /home/${USERNAME}/.rpmmacros
echo "%_tmppath /home/${USERNAME}/rpm/tmp" >> /home/${USERNAME}/.rpmmacros
echo "%_signature gpg" >> /home/${USERNAME}/.rpmmacros
echo "%_gpg_name ${USER} <${USER}@${HOSTNAME}>
%_gpg_path ~/.gnupg" >> /home/${USERNAME}/.rpmmacros
echo "%distribution Mandrake Linux" >> /home/${USERNAME}/.rpmmacros
echo "%vendor MandrakeSoft" >> /home/${USERNAME}/.rpmmacros
echo "/home/${USERNAME}/.rpmmacros created (please verify gpg information)"
}

#write config files
for i in rpmrc rpmmacros
do
	if [ -f ".$i" ]
	then
		if [ "${FORCE}" = 1 ]
		then
			$i
		else
			echo "/home/${USERNAME}/.$i exists, use -f to overwrite"
		fi
	else
		$i
	fi
done

Reply via email to