ABS wrapper scripts: big refactoring
Merged all scripts into one single script.master
parent
b881eff591
commit
9b1dd7c517
|
@ -1,14 +0,0 @@
|
|||
#!/bin/sh
|
||||
[ -z "$(command -v makepkg)" ] && echo "You need makepkg to run this script." && exit 1
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Please give build folders as argument with .pkg.tar.xz in them."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for i; do
|
||||
(cd "$i" && \
|
||||
mkdir -p "srcpkg" && \
|
||||
SRCDEST="srcpkg" makepkg -rscf --nocheck --noconfirm && \
|
||||
rm -rvf "srcpkg" )
|
||||
done
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Please give build folders as argument with .pkg.tar.xz in them."
|
||||
echo "Please give as argument build folders with .pkg.tar.xz in them."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,28 +1,42 @@
|
|||
#!/bin/sh
|
||||
|
||||
HAS_ABS=0
|
||||
HAS_YAOURT=0
|
||||
[ -n "$(command -v abs)" ] && HAS_ABS=1
|
||||
[ -n "$(command -v yaourt)" ] && HAS_YAOURT=1
|
||||
|
||||
if [ $HAS_ABS -eq 0 ] && [ $HAS_YAOURT -eq 0 ]; then
|
||||
echo "Please install either an ABS-tree or yaourt."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
_printhelp ()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: ${1##*/} [OPTIONS] PACKAGES
|
||||
|
||||
Fetch PKGBUILDs from source tree (using ABS tree by default).
|
||||
Fetch PKGBUILDs from source tree (using ABS tree or yaourt if available) and extract source.
|
||||
|
||||
-a: Use 'abs' to fetch data.
|
||||
-f: Overwrite folder if it exists.
|
||||
-h: Display this help.
|
||||
-y: Use 'yaourt' to fetch data.
|
||||
|
||||
Noteworthy parameters:
|
||||
\$(pacman-official)
|
||||
\$(pacman -Qmq)
|
||||
\$(pacman -Qq)
|
||||
\$(pacman -Qsq <search-string>)
|
||||
EOF
|
||||
}
|
||||
|
||||
DL_AGENT=0
|
||||
DL_AGENT=-1 # Dynamic choice
|
||||
CP_AGENT="/bin/cp -rnv"
|
||||
|
||||
while getopts ":hfy" opt; do
|
||||
case $opt in
|
||||
a)
|
||||
DL_AGENT=0
|
||||
;;
|
||||
h)
|
||||
_printhelp "$0"
|
||||
exit 1
|
||||
|
@ -53,8 +67,23 @@ if [ $# -eq 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [ $DL_AGENT -eq -1 ]; then
|
||||
for i; do
|
||||
pacman -Si $i >/dev/null 2>&1
|
||||
if [ $? -eq 0] && [ $HAS_ABS -eq 1 ]; then
|
||||
[ ! -d "/var/abs" ] && sudo abs
|
||||
eval "$CP_AGENT" /var/abs/*/$i .
|
||||
(cd "$i" && makepkg -o)
|
||||
else
|
||||
yaourt -G "$i"
|
||||
(cd "$i" && makepkg -o)
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $DL_AGENT -eq 0 ]; then
|
||||
if [ ! -f /usr/bin/abs ]; then
|
||||
if [ $HAS_ABS -eq 0 ]; then
|
||||
echo "ABS needs to be installed."
|
||||
exit
|
||||
fi
|
||||
|
@ -67,10 +96,12 @@ if [ $DL_AGENT -eq 0 ]; then
|
|||
fi
|
||||
|
||||
if [ $DL_AGENT -eq 1 ]; then
|
||||
if [ ! -f /usr/bin/yaourt ]; then
|
||||
if [ $HAS_YAOURT -eq 0 ]; then
|
||||
echo "Yaourt needs to be installed."
|
||||
exit
|
||||
fi
|
||||
|
||||
for i; do
|
||||
yaourt -G "$@"
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -10,13 +10,13 @@ echo "[$0]"
|
|||
|
||||
if [ "$CHOICE" = "y" ]; then
|
||||
for i in *; do
|
||||
(cd "$i" && pacman --noconfirm -U *.pkg.tar.xz)
|
||||
echo "$i"
|
||||
done
|
||||
fi
|
||||
else
|
||||
(cd "$0" && pacman --noconfirm -U *.pkg.tar.xz)
|
||||
echo "$0"
|
||||
for i; do
|
||||
(cd "$i" && pacman --noconfirm -U *.pkg.tar.xz)
|
||||
echo "$i"
|
||||
done
|
||||
fi
|
||||
' "$@"
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
#!/bin/sh
|
||||
|
||||
UPSTREAM_SOURCE="srcdir"
|
||||
|
||||
_printhelp ()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: ${1##*/} [OPTIONS] PACKAGES
|
||||
|
||||
Default operation is to fetch source code for provided packages. Other
|
||||
operations include:
|
||||
* Cleaning specified folder from build data.
|
||||
* Installing packages.
|
||||
The script first look for exising folder containing a PKGBUILD file. If they are
|
||||
not to be found, it will fetch the PKGBUILD from ABS-tree or yaourt, depending
|
||||
on what is available.
|
||||
|
||||
-c: Clean source folders from temp file (keep upstream source and built package).
|
||||
-f: Force operation (overwrite, rebuild).
|
||||
-h: Display this help.
|
||||
-i: Install package (build if needed).
|
||||
|
||||
Example:
|
||||
${1##*/} -afic \$(pacman -Qmq)
|
||||
Rebuild, install
|
||||
\$(pacman -Qsq <search-string>)
|
||||
EOF
|
||||
}
|
||||
|
||||
CP_OPT=""
|
||||
MAKEPKT_OPT=""
|
||||
|
||||
OPT_CLEAN=0
|
||||
OPT_FORCE=0
|
||||
OPT_INSTALL=0
|
||||
|
||||
while getopts ":hfy" opt; do
|
||||
case $opt in
|
||||
c)
|
||||
MAKEPKG_OPT="$MAKEPKG_OPT -c";;
|
||||
OPT_CLEAN=1 ;;
|
||||
f)
|
||||
CP_OPT="$CP_OPT -f"
|
||||
MAKEPKG_OPT="$MAKEPKG_OPT -f"
|
||||
OPT_FORCE=1;;
|
||||
h)
|
||||
_printhelp "$0"
|
||||
exit 1 ;;
|
||||
i)
|
||||
OPT_INSTALL=1 ;;
|
||||
?)
|
||||
_printhelp "$0"
|
||||
exit 1 ;;
|
||||
:)
|
||||
echo "Missing argument."
|
||||
_printhelp "$0"
|
||||
exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Missing argument."
|
||||
_printhelp "$0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$(command -v makepkg)" ]; then
|
||||
echo "You need makepkg to run this script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HAS_ABS=0
|
||||
HAS_YAOURT=0
|
||||
[ -n "$(command -v abs)" ] && HAS_ABS=1
|
||||
[ -n "$(command -v yaourt)" ] && HAS_YAOURT=1
|
||||
|
||||
if [ $HAS_ABS -eq 0 ] && [ $HAS_YAOURT -eq 0 ]; then
|
||||
echo "Please install either an ABS-tree or yaourt."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
|
||||
## TODO: check if force works with yaourt.
|
||||
abs-fetch ()
|
||||
{
|
||||
pacman -Si $i >/dev/null 2>&1
|
||||
if [ $? -eq 0] && [ $HAS_ABS -eq 1 ]; then
|
||||
[ ! -d "/var/abs" ] && sudo abs
|
||||
cp -rvn $CP_OPT /var/abs/*/$i .
|
||||
(cd "$i" && SRCDEST="$UPSTREAM_SOURCE" makepkg -o)
|
||||
else
|
||||
yaourt -G "$i"
|
||||
(cd "$i" && SRCDEST="$UPSTREAM_SOURCE" makepkg -o)
|
||||
fi
|
||||
}
|
||||
|
||||
## TODO: add option to not download. Useful when cleaning only.
|
||||
for i ; do
|
||||
if [ ! -f "$i/PKGBUILD" ] || [ $OPT_FORCE -eq 1 ]; then
|
||||
abs-fetch "$i"
|
||||
fi
|
||||
if [ $OPT_INSTALL -eq 1 ]; then
|
||||
(cd "$i" && \
|
||||
mkdir -p "srcpkg" && \
|
||||
SRCDEST="$UPSTREAM_SOURCE" makepkg -rs $MAKEPKG_OPT --nocheck --noconfirm)
|
||||
fi
|
||||
|
||||
if [ $OPT_CLEAN ]; then
|
||||
(cd "$i" && rm -rvf "src" "pkg")
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $OPT_INSTALL -eq 1 ]; then
|
||||
sudo sh -c '
|
||||
for i in; do
|
||||
(cd "$i" && pacman --noconfirm -U *.pkg.tar.xz)
|
||||
done
|
||||
' "$@"
|
||||
fi
|
Loading…
Reference in New Issue