F15 ARMv5 Building On F13 Builders

This script can be distributed to multiple builders to build the various Fedora packages with mock. The setup commands for the server side are included (but commented) in the script below. Note: The script now requires an apache server to be running which allows for the new fedora-release package information to be retrieved for correct build tagging.

> httpd.conf

Alias /builds/ "/tmp/builds/"

<Directory "/tmp/builds">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

> arm-builder.sh

#!/bin/bash

# COMMON: variable definitions for this script

SSHDHOST="1.2.3.4"
SSHDUSER="builder"
SSHDPASS="/tmp/sshkey"
SSHDROOT="/tmp/builds"
LOCLTEMP="/tmp/work"

SSHDPRIO="${SSHDROOT}/prio"
SSHDPKGS="${SSHDROOT}/pkgs"
SSHDWORK="${SSHDROOT}/work"
SSHDDONE="${SSHDROOT}/done"

# SERVER: local and remote account setup

#passwd ; chsh -s /bin/bash
#mkdir -p ~/.ssh ; echo 'ssh-pub-key@local' > ~/.ssh/authorized_keys
#chmod 700 ~/.ssh ~/.ssh/authorized_keys

# SERVER: build directory creation

#mkdir -p ${SSHDPRIO} ${SSHDPKGS} ${SSHDWORK} ${SSHDDONE}

# SERVER: create intial build package files

#koji list-tagged dist-f15 --latest > /tmp/list.txt
#cd ${SSHDPKGS} ; tail -n +3 /tmp/list.txt | awk '{ print $1 }' | while read line ; do touch "$line" ; done

# SERVER: initialize the most basic repo containing F15 release information

#urls="http://kojipkgs.fedoraproject.org/packages/fedora-release/15/1"
#cd ${SSHDDONE} ; wget "${urls}/src/fedora-release-15-1.src.rpm" "${urls}/noarch/fedora-release-15-1.noarch.rpm" "${urls}/noarch/fedora-release-rawhide-15-1.noarch.rpm" ; createrepo --update -d ${SSHDDONE}

# CLIENT: save the ssh key for auto logins

(echo '-----BEGIN ssh-pri-key-----') > ${SSHDPASS}
chmod 700 ${SSHDPASS}

# CLIENT: create a custom fedora repo file for the mock builds

echo "
config_opts['root'] = 'fedora-15-arm'
config_opts['target_arch'] = 'armv5tel'
config_opts['legal_host_arches'] = ('armv5tel', 'armv6l', 'armv7l')
config_opts['chroot_setup_cmd'] = 'groupinstall buildsys-build'
config_opts['dist'] = 'fc15'
config_opts['plugin_conf']['root_cache_enable'] = False
config_opts['plugin_conf']['yum_cache_enable'] = False

config_opts['yum.conf'] = \"\"\"
[main]
cachedir=/var/cache/yum
debuglevel=1
reposdir=/dev/null
logfile=/var/log/yum.log
retries=20
obsoletes=1
gpgcheck=0
assumeyes=1
syslog_ident=mock
syslog_device=

# repos

[custom]
name=fedora-custom
baseurl=http://${SSHDHOST}/builds/done/
enabled=1

### NOTE : USE A VAR HERE FOR THE PATH INSTEAD ###

[f15-arm-koji]
name=fedora15-arm-koji
baseurl=http://arm.koji.fedoraproject.org/repos/dist-f15-build/latest/arm/
enabled=1

[fedora]
name=fedora
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-13&arch=arm
failovermethod=priority

[updates-released]
name=updates
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f13&arch=arm
failovermethod=priority
\"\"\"
" > /etc/mock/fedora-15-arm.cfg
chmod 755 /etc/mock/fedora-15-arm.cfg

# CLIENT: create a tmp working directory for the pkg builds

mkdir -p ${LOCLTEMP}
chmod 777 ${LOCLTEMP}
cd ${LOCLTEMP}

# CLIENT: ensure that the mock user is in the mock group (not just primary)

useradd -g mock mock
usermod -G mock mock
chsh -s /bin/bash mock

# CLIENT: loop to keep building pkgs

while true
do
	# CLIENT: check for a random pkg and move it out of the directory so it can be worked on
	
	for dirn in ${SSHDPRIO} ${SSHDPKGS}
	do
		pkgn=$(ssh -i ${SSHDPASS} ${SSHDUSER}@${SSHDHOST} "pkgn=\$(ls -t ${dirn} | tail -n 1) ; if [ \"\${pkgn}\" != \"\" ] ; then mv ${dirn}/\${pkgn} ${SSHDWORK}/ ; echo \${pkgn} ; fi")
		
		if [ "${pkgn}" != "" ]
		then
			break
		fi
	done
	
	# CLIENT: remove any old build files
	
	rm -frv ${LOCLTEMP}/*
	
	# CLIENT: if we have a pkg then try to download the source
	
	if [ "${pkgn}" != "" ]
	then
		# CLIENT: download and build the package
		
		echo "Building [${dirn}/${pkgn}] in [`pwd`]"
		
		# CLIENT: download the source rpm pkg from the server
		
		scp -i ${SSHDPASS} ${SSHDUSER}@${SSHDHOST}:${SSHDWORK}/${pkgn} ./
		
		if [ ! -s "${pkgn}" ]
		then
			# CLIENT: pkg prep
			
			rm -frv ${LOCLTEMP}/*
			pkgn=$(echo "${pkgn}" | sed -e 's/\.src\.rpm$//g')
			
			#koji download-build --arch=src "${pkgn}"
			urln=`python -c "import rpmUtils.miscutils ; (n,v,r,e,a)=rpmUtils.miscutils.splitFilename('${pkgn}') ; print('http://kojipkgs.fedoraproject.org/packages/%s/%s/%s.%s/src/${pkgn}.src.rpm' % (n,v,r,a))"`
			wget "${urln}"
		fi
	fi
	
	# CLIENT: check for and make any build files readable
	
	file=$(echo *)
	
	# CLIENT: if we have a source pkg then try to build it
	
	if [ -e "${file}" ]
	then
		# CLIENT: pkg prep
		
		chmod 755 *
		
		# CLIENT: build the source rpm in mock
		
		su -c "mock -vr fedora-15-arm --resultdir=${LOCLTEMP}/mock.${pkgn} ${LOCLTEMP}/${file}" - mock
		
		# CLIENT: copy any mock results back to the server
		
		scp -i ${SSHDPASS} -r mock.${pkgn} ${SSHDUSER}@${SSHDHOST}:${SSHDDONE}/
	fi
	
	sleep 60
done

> repo.py

import os
import sys
import time

repo = "/var/export/f15v5.0/repo"
temp = "/var/export/f15v5.0/temp"

def syse(comd, show=True):
	if (show):
		print(comd)
	
	os.system(comd)

while (1):
	syse("find %s -type f -iname '*.[rx][pm][ml]' -exec ls --time-style='+%%s' -l {} \; 2> /dev/null | tr -s ' ' | cut -d ' ' -f 6- | sort -nr | head -n 1 | grep -i '.*\.rpm$' > /tmp/repo.txt" % (repo))
	
	fobj = open("/tmp/repo.txt", "r")
	chek = fobj.read().strip()
	fobj.close()
	
	if (chek != ""):
		syse("echo \"Starting on [ `date` ]\" | tee -a ~/repo.log")
		
		syse("mkdir \"%s\" 2> /dev/null" % (temp)) # make sure the temp repo directory exists
		syse("rm -fr %s/* 2> /dev/null" % (temp)) # clear the temp repo directory
		
		for item in os.listdir(repo):
			syse("ln -s \"%s/%s\" \"%s/%s\"" % (repo, item, temp, item), show=False)
		
		syse("rm -fr \"%s/repodata\"" % (temp)) # remove any temp repo data links
		syse("cp -fr \"%s/repodata\" \"%s/\"" % (repo, temp)) # copy over the current repo data
		syse("createrepo --update -d \"%s\" --exclude=*debuginfo* --exclude=*.src.rpm" % (temp)) # create/update the new repo data
		syse("rm -fr \"%s/repodata\"" % (repo)) # remove the old repodata files
		syse("cp -fr \"%s/repodata\" \"%s/\"" % (temp, repo)) # copy over the new repo data
		
		syse("echo \"Ending on [ `date` ]\" | tee -a ~/repo.log")
	
	time.sleep(60) # sleep loop or risk fire!
Advertisements
F15 ARMv5 Building On F13 Builders

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s