All pastes #997075 Raw Edit

aurcreate v1.1.1

public text v1 · immutable
#997075 ·published 2008-04-25 13:33 UTC
rendered paste body
#!/bin/bash

# aurcreate - create clean packages prepared for upload to AUR
# Version: 1.1.1
# Author:  Michal Krenek (Mikos) <mikos@sg1.cz>
# License: GNU General Public License v.2
#          http://www.gnu.org/licenses/gpl.txt
# Modifications: 
#     * Version 1.1.1
#         By: Daenyth <Daenyth+arch _AT_ gmail _DOT_ com> April 2008
#         Changes: Bugfix. Removed "local" declaration, since it's not a function
#                  Direct push/popd output to /dev/null
#     * Version 1.1.0
#         By: Daenyth <Daenyth+arch _AT_ gmail _DOT_ com> April 2008
#         Changes: Preserve the build dir now and work elsewhere. 
#                  Honor /etc/makepkg.conf's BUILDSCRIPT variable.
#                  Also copy all $sources instead of just $BUILDSCRIPT.

# This will set $BUILDSCRIPT, which is usually PKGBUILD
eval `grep -m 1 BUILDSCRIPT /etc/makepkg.conf`

if [ -z "$*" ]; then
  echo "aurcreate - create clean packages prepared for upload to AUR"
  echo "Error: You must specify package name(s)"
  exit 1
fi

for name in "$@"; do
  if [ ! -d "$name" ]; then
    echo "You don't have directory '$name' here. Skipping this package..."
    echo
    continue
  fi

  if [ ! -f "$name/$BUILDSCRIPT" ]; then
    echo "$BUILDSCRIPT doesn't exist in '$name' directory. Skipping this package..."
    echo
    continue
  fi

  # We want to work inside the package dir directly.
  # We are probably around ~/builds/$pkgname right now.
  pushd "$name" > /dev/null

  # Create a directory that will be only for the aur package
  # And ensure that it will be clean
  aurdir="aur/$name"
  rm -rf "$aurdir" 2> /dev/null
  mkdir -p "$aurdir"

  sources=($(. $BUILDSCRIPT; echo ${source[@]}))
  for source in ${sources[@]}; do
    if echo $source | grep -v '://' > /dev/null; then
      cp "$source" "$aurdir"
    fi
  done

  cp "$BUILDSCRIPT" "$aurdir"
  
  # Following our assumed directory structure from before, 
  # we should be at ~/builds/$pkgname/aur
  # with the $pkgname directory below us and full of
  # goodies for all the little children
  pushd "$aurdir"> /dev/null
  cd ..

  echo "Creating new package '$name'..."
  tar -cvzf "$name.tar.gz" "$name"
  echo
  
  popd > /dev/null # Return to ~/builds/$pkgname
  cp -f "$aurdir/../$name.tar.gz" "$PWD"
  popd > /dev/null # Return to the directory we ran the script in, to prepare for the next loop
done
# vim: set ts=2 sw=2 et: