Create a gist now

Instantly share code, notes, and snippets.

@przemoc /abuild.sh
Last active Feb 6, 2018

Embed
What would you like to do?
Simplistic abuild wrapper for building packages out-of-the-tree.
#!/bin/sh
# SPDX-License-Identifier: MIT
## Copyright (C) 2017 Przemyslaw Pawelczyk <przemoc@gmail.com>
##
## This script is licensed under the terms of the MIT license.
## https://opensource.org/licenses/MIT
#
# abuild.sh
# Simplistic abuild wrapper for building packages out-of-the-tree.
#
# Put it in its own directory, and everything will be generated there.
# Why? Because I strongly dislike the idea of polluting local aports clone.
# I keep the script in ~/abuild/. You can also put symlink to it in ~/bin/.
if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "usage: $0 [-f] [-K] [--] [PATH-TO-APKBUILD-FILE-OR-DIR-WITH-IT]..."
exit 0
fi
ORIGPWD=$(pwd)
TOPDIR=$(readlink -f "${0%/*}")
echo TOPDIR="$TOPDIR"
REPODEST="$TOPDIR/repo"
mkdir -p "$REPODEST"
echo REPODEST="$REPODEST"
export REPODEST
SRCDEST="$TOPDIR/sources"
mkdir -p "$SRCDEST"
echo SRCDEST="$SRCDEST"
export SRCDEST
srcdir="$TOPDIR/.src"
mkdir -p "$srcdir"
echo srcdir="$srcdir"
export srcdir
pkgbasedir="$TOPDIR/.pkg"
mkdir -p "$pkgbasedir"
echo pkgbasedir="$pkgbasedir"
export pkgbasedir
FORCE=
if [ "$1" = "-f" ]; then
FORCE=-f
shift
fi
KEEP=
if [ "$1" = "-K" ]; then
KEEP=-K
shift
fi
[ "$1" != "--" ] || shift
export APKBUILD
cd "$TOPDIR"
while [ $# -gt 0 ]; do
APKBUILD="$1"
shift
[ "${APKBUILD#/}" != "$APKBUILD" ] || APKBUILD="$ORIGPWD/${APKBUILD#./}"
[ "${APKBUILD%/APKBUILD}" != "$APKBUILD" ] || APKBUILD="${APKBUILD%/}/APKBUILD"
echo APKBUILD="$APKBUILD"
if ! [ -r "$APKBUILD" ]; then
echo "$0: $APKBUILD is not readable!" >&2
continue
fi
abuild $FORCE $KEEP -r
done
@przemoc

This comment has been minimized.

Show comment
Hide comment
@przemoc

przemoc Feb 6, 2018

commit c579a38229027d2664457654b5e107f4a5ff3fa2
Author: Przemyslaw Pawelczyk <przemoc@gmail.com>
Date:   2018-02-06 15:09:59 +0100

    abuild.sh: Add copyright notice and MIT license notice.

commit 8fc74bff24c2a7b6fd7fb6076ededf570f0e4633
Author: Przemyslaw Pawelczyk <przemoc@gmail.com>
Date:   2018-02-06 15:10:32 +0100

    Add SPDX License Identifier.

    The Software Package Data Exchange (SPDX) is a good initiative, it has
    matured over time and deserves accelerated adoption in open-source.

    https://spdx.org/learn
    https://spdx.org/using-spdx
    https://spdx.org/license-list
Owner

przemoc commented Feb 6, 2018

commit c579a38229027d2664457654b5e107f4a5ff3fa2
Author: Przemyslaw Pawelczyk <przemoc@gmail.com>
Date:   2018-02-06 15:09:59 +0100

    abuild.sh: Add copyright notice and MIT license notice.

commit 8fc74bff24c2a7b6fd7fb6076ededf570f0e4633
Author: Przemyslaw Pawelczyk <przemoc@gmail.com>
Date:   2018-02-06 15:10:32 +0100

    Add SPDX License Identifier.

    The Software Package Data Exchange (SPDX) is a good initiative, it has
    matured over time and deserves accelerated adoption in open-source.

    https://spdx.org/learn
    https://spdx.org/using-spdx
    https://spdx.org/license-list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment