2013-07-08 14:14:41 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
if [ $# -ne 1 ] || [ "$1" = "-h" ]; then
|
|
|
|
cat<<EOF
|
|
|
|
Usage: ${0##*/} PKGBUILD
|
|
|
|
|
2013-07-10 18:31:13 +02:00
|
|
|
Convert an Arch Linux PKGBUILD to a universal standalone bash script. (The
|
2013-09-10 20:00:31 +02:00
|
|
|
infamous 'bash' is assumed because PKGBUILD are bash scripts, they strongly rely
|
|
|
|
on arrays.) The resulting script tries to resemble makepkg build process where
|
|
|
|
it makes sense. There is no dependency resolution because we cannot guess the
|
|
|
|
package names of the target system.
|
2013-07-10 00:21:41 +02:00
|
|
|
|
|
|
|
Differences with makepkg
|
2013-09-10 20:00:31 +02:00
|
|
|
* Parameters may differ.
|
|
|
|
* The progress output may differ.
|
|
|
|
* Some features are not implemented (e.g. explicit source filename)
|
2013-07-08 14:14:41 +02:00
|
|
|
|
2013-08-26 14:09:56 +02:00
|
|
|
Options:
|
|
|
|
|
|
|
|
-l: install in usr/local/ instead of usr/
|
|
|
|
|
2013-07-08 14:14:41 +02:00
|
|
|
EOF
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$(command -v realpath)" ]; then
|
|
|
|
echo "You need 'realpath'"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$1" ]; then
|
|
|
|
echo "$1 must be a PKGBUILD file."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
OUTPATH="$(realpath "$1")"
|
|
|
|
OUTPATH="${OUTPATH%/*}"
|
|
|
|
UBUILD="${OUTPATH}/UBUILD.sh"
|
|
|
|
|
|
|
|
if [ -f "$UBUILD" ]; then
|
|
|
|
echo "$UBUILD already exists."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo '#!/bin/bash
|
|
|
|
|
|
|
|
if [ -z "$(command -v realpath)" ];then
|
|
|
|
echo "You need 'realpath'."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
if [ -z "$(command -v wget)" ];then
|
|
|
|
echo "You need 'wget'."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
' > "$UBUILD"
|
|
|
|
|
2013-08-26 14:09:56 +02:00
|
|
|
if [ "$1" = "-l" ]; then
|
|
|
|
cat "$2" | sed -e 's|/usr|/usr/local|g' >> "$UBUILD"
|
|
|
|
else
|
|
|
|
cat "$1" >> "$UBUILD"
|
|
|
|
fi
|
2013-07-08 14:14:41 +02:00
|
|
|
|
2013-08-04 11:29:35 +02:00
|
|
|
cat "${0%/*}/.${0##*/}.in" >> "$UBUILD"
|
2013-07-10 00:21:41 +02:00
|
|
|
chmod +x "$UBUILD"
|