ubuilder: proper packaging and installation support.
parent
b22f18ff3f
commit
5b3cf2e5c5
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
srcdir=src
|
srcdir=src
|
||||||
pkgdir=pkg/$pkgname
|
pkgdir=pkg/$pkgname
|
||||||
|
arch="$(uname -m)"
|
||||||
|
|
||||||
DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
|
DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
|
||||||
'http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'
|
'http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'
|
||||||
|
@ -81,7 +82,7 @@ _fetch()
|
||||||
|
|
||||||
## TODO: add support for DLAGENT
|
## TODO: add support for DLAGENT
|
||||||
msg2 "Downloading $FILE..."
|
msg2 "Downloading $FILE..."
|
||||||
wget "$OPT_FORCE" "$URI" -O "$FILE"
|
wget $OPT_FORCE_WGET "$URI" -O "$FILE"
|
||||||
|
|
||||||
## Strangely enough, wget will not return 0 on success. On error, it
|
## Strangely enough, wget will not return 0 on success. On error, it
|
||||||
## will still create a 0-byte file.
|
## will still create a 0-byte file.
|
||||||
|
@ -93,8 +94,10 @@ _fetch()
|
||||||
git+*)
|
git+*)
|
||||||
GITURI="${URI#git+}"
|
GITURI="${URI#git+}"
|
||||||
if [ -d "${_gitname:-$FILE}/.git" ]; then
|
if [ -d "${_gitname:-$FILE}/.git" ]; then
|
||||||
cd "${_gitname:-$FILE}"
|
if ! $OPT_NOCLOBBER; then
|
||||||
git pull
|
cd "${_gitname:-$FILE}"
|
||||||
|
git pull
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
git clone "$GITURI"
|
git clone "$GITURI"
|
||||||
fi
|
fi
|
||||||
|
@ -178,15 +181,9 @@ _extract ()
|
||||||
for URI in "${source[@]}"; do
|
for URI in "${source[@]}"; do
|
||||||
FILE="${URI##*/}"
|
FILE="${URI##*/}"
|
||||||
case "$FILE" in
|
case "$FILE" in
|
||||||
*.tar.bz2|*.tbz2)
|
*.tar.bz2|*.tbz2|*.tar.gz|*.tgz|*.tar.xz|*.txz)
|
||||||
msg2 "Extracting $FILE with tar"
|
msg2 "Extracting $FILE with tar"
|
||||||
tar xjf "$FILE" -C "$srcdir";;
|
tar xf "$FILE" -C "$srcdir" $OPT_FORCE_TAR;;
|
||||||
*.tar.gz|*.tgz)
|
|
||||||
msg2 "Extracting $FILE with tar"
|
|
||||||
tar xzf "$FILE" -C "$srcdir";;
|
|
||||||
*.tar.xz|*.txz)
|
|
||||||
msg2 "Extracting $FILE with tar"
|
|
||||||
tar xJf "$FILE" -C "$srcdir";;
|
|
||||||
*)
|
*)
|
||||||
case "$URI" in
|
case "$URI" in
|
||||||
git+*)
|
git+*)
|
||||||
|
@ -246,14 +243,21 @@ _compress()
|
||||||
chmod +x "$UNINS"
|
chmod +x "$UNINS"
|
||||||
|
|
||||||
msg2 "Compressing package..."
|
msg2 "Compressing package..."
|
||||||
ls "$pkgdir" | tar --owner=root --group=root -C "$pkgdir" -cJf "pkgname-$pkgver-$pkgrel-$(uname -m).tar.xz" -T -
|
if [ "$(uname)" = "Linux" ]; then
|
||||||
|
ls "$pkgdir" | tar --numeric-owner --owner=root --group=root \
|
||||||
|
-C "$pkgdir" -cJf "$pkgname-$pkgver-$pkgrel-$arch.tar.xz" -T -
|
||||||
|
else
|
||||||
|
## BSD and others. WARNING: this may not be portable.
|
||||||
|
ls "$pkgdir" | tar --numeric-owner --uid 0 --gid 0 \
|
||||||
|
-C "$pkgdir" -cJf "$pkgname-$pkgver-$pkgrel-$arch.tar.xz" -T -
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_packagehook()
|
_packagehook()
|
||||||
{
|
{
|
||||||
if $OPT_NOCLOBBER && [ $(ls -a1 "$pkgdir" | wc -l) -ne 2 ]; then
|
if $OPT_NOCLOBBER && [ $(ls -a1 "$pkgdir" | wc -l) -ne 2 ]; then
|
||||||
error "A package has already been built. (use -f to overwrite)"
|
warning "A package has already been built. Skipping. (Use -f to overwrite.)"
|
||||||
exit 1
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf "$pkgdir"
|
rm -rf "$pkgdir"
|
||||||
|
@ -276,8 +280,12 @@ _clean ()
|
||||||
_install()
|
_install()
|
||||||
{
|
{
|
||||||
msg "Installing package $pkgname..."
|
msg "Installing package $pkgname..."
|
||||||
## TODO: make sure permissions are fixed.
|
## Only use sudo if user has write permission to DESTROOT.
|
||||||
# sudo tar xf "$pkgname-$pkgver-$pkgrel.tar.xz" -C "/"
|
if [ -w "$OPT_DESTROOT" ]; then
|
||||||
|
tar -xkf "$pkgname-$pkgver-$pkgrel-$arch.tar.xz" -C "$OPT_DESTROOT"
|
||||||
|
else
|
||||||
|
sudo tar -xkf "$pkgname-$pkgver-$pkgrel-$arch.tar.xz" -C "$OPT_DESTROOT"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_printhelp ()
|
_printhelp ()
|
||||||
|
@ -301,19 +309,22 @@ package was never built, the building will be processed automatically.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
-b: Build.
|
-b: Build.
|
||||||
-c: Clean source folders from temp file (keep upstream source and built package).
|
-c: Clean source folders from temp file (keep upstream source and built package).
|
||||||
-d: List dependencies and exit.
|
-d: List dependencies and exit.
|
||||||
-f: Force operation (overwrite, rebuild, reinstall).
|
-f: Force operation (overwrite, rebuild, reinstall).
|
||||||
-h: Display this help.
|
-h: Display this help.
|
||||||
-i: Install package.
|
-i: Install package.
|
||||||
-R: Create package.
|
-r ROOT: Specifiy ROOT folder where to install the package.
|
||||||
-s: Skip integrity checks.
|
-R: Create package.
|
||||||
|
-s: Skip integrity checks.
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
OPT_FORCE="-nc"
|
OPT_DESTROOT="$HOME/.local"
|
||||||
|
OPT_FORCE_WGET="-nc"
|
||||||
|
OPT_FORCE_TAR="-k"
|
||||||
OPT_NOCLOBBER=true
|
OPT_NOCLOBBER=true
|
||||||
|
|
||||||
OPT_BUILD=false
|
OPT_BUILD=false
|
||||||
|
@ -337,7 +348,7 @@ TIDY_zipman=true
|
||||||
TIDY_purge=true
|
TIDY_purge=true
|
||||||
TIDY_upx=false
|
TIDY_upx=false
|
||||||
|
|
||||||
while getopts ":bcdfhiRs" opt; do
|
while getopts ":bcdfhirRs" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
b)
|
b)
|
||||||
OPT_BUILD=true ;;
|
OPT_BUILD=true ;;
|
||||||
|
@ -347,7 +358,8 @@ while getopts ":bcdfhiRs" opt; do
|
||||||
_listdeps
|
_listdeps
|
||||||
exit;;
|
exit;;
|
||||||
f)
|
f)
|
||||||
OPT_FORCE=""
|
OPT_FORCE_TAR=""
|
||||||
|
OPT_FORCE_WGET=""
|
||||||
OPT_NOCLOBBER=false ;;
|
OPT_NOCLOBBER=false ;;
|
||||||
h)
|
h)
|
||||||
_printhelp "$0"
|
_printhelp "$0"
|
||||||
|
@ -356,6 +368,8 @@ while getopts ":bcdfhiRs" opt; do
|
||||||
OPT_BUILD=true
|
OPT_BUILD=true
|
||||||
OPT_PACKAGE=true
|
OPT_PACKAGE=true
|
||||||
OPT_INSTALL=true ;;
|
OPT_INSTALL=true ;;
|
||||||
|
r)
|
||||||
|
OPT_DESTROOT="$OPTARG";;
|
||||||
R)
|
R)
|
||||||
OPT_BUILD=true
|
OPT_BUILD=true
|
||||||
OPT_PACKAGE=true ;;
|
OPT_PACKAGE=true ;;
|
||||||
|
|
Loading…
Reference in New Issue