You are not logged in.

#1 2006-02-02 21:54:58

shadowhand
Member
From: MN, USA
Registered: 2004-02-19
Posts: 1,142
Website

Repository package building script

I've been using a script to build all the packages for my repo for some time, but it was pretty hacked together, so I decided to rewrite it today. I made it so that it works with both makepkg and versionpkg. The assumption is that you make a directory with this script and two directories (make and version). The "make" directory contains directories with only "makepkg" packages, and "version" contains directories with "versionpkg" packages. You execute the script in the top directory, an it will recurse though "make" and "version" and build all the packages to a single location.

It Works for Me! (tm)

An example building directory structure:

buildall.sh
builtlog.log
make
- any2dvd
- gimp-devel
- gmrun
version
- xfwm4-svn
- xfmedia-svn
- gaim-cvs

Script:

#!/bin/bash
#############################################################

REPO_PACKAGES=/path/to/built/packages
REPO_ARCHIVES=/path/to/archive

LOGFILE=builtlog.log #change this to whatever you want the logfile to be called

#############################################################
############ DO NOT EDIT BELOW THIS LINE! ###################
#############################################################
TOP_DIR=`pwd`

if [ -e "$LOGFILE" ]; then
  echo "Previous log found, saving as ${LOGFILE}.old"
  mv ${LOGFILE} ${LOGFILE}.old
fi
echo "Creating new log: ${LOGFILE}"
touch ${LOGFILE}

if [ ! -d "$REPO_ARCHIVES" ]; then
  mkdir ${REPO_ARCHIVES}
fi

for i in `ls`; do
if [ -d "$i" ]; then
  BUILD_COMMAND=`basename "$i"`pkg
  HOLDING_DIR=`pwd`
  cd $i
  
  for p in `ls`; do
    if [ -d "$p" ]; then
      cd $p
      
      START_TIME=`date +%Y %m-%d (%H:%M)`
      
      echo " "
      echo -e "33[0;36m ${START_TIME}:33[0m Starting build of ${p}..."
      ${BUILD_COMMAND} -w ${REPO_PACKAGES} >/dev/null 2>&1
      
      if [ $? -eq 0 ]; then
        END_TIME=`date +%Y %m-%d (%H:%M)`
        echo -e "33[0;36m ${END_TIME}:33[1;32m ${p} built sucessfully."
        echo "$p built sucessfully on ${END_TIME}" >>${TOP_DIR}/${LOGFILE}
      else
        END_TIME=`date +%Y %m-%d (%H:%M)`
        echo -e "33[0;36m ${END_TIME}:33[1;31m failed."
        echo "$p failed to build." >>${TOP_DIR}/${LOGFILE}
      fi
      #Move all but latest package to $REPO_ARCHIVE
      mv `ls ${REPO_PACKAGES}/${p}*| sed '$d'` ${REPO_ARCHIVES} >/dev/null 2>&1
      
      cd .. #Go back to parent directory
    else
      /bin/true
    fi
  done
  cd ${HOLDING_DIR} #Start with the next batch

else
  /bin/true  
fi
done

cd ${TOP_DIR}

echo " "
echo -e "33[1;31m  -------- Failed Packages: ---------  33[0m"
fgrep "failed" ${LOGFILE}
if [ $? -eq 1 ]; then
  echo -e "33[1;32m No packages failed to build.33[0m"
fi
echo " "
echo "Check ${LOGFILE} for details."

exit 0

·¬»· i am shadowhand, powered by webfaction

Offline

Board footer

Powered by FluxBB