Added hooks
This commit is contained in:
50
bin/makepkg
50
bin/makepkg
@@ -18,13 +18,28 @@ OS="${OSNAME}-${OSVER}"
|
|||||||
|
|
||||||
OPT_INSTALL=0
|
OPT_INSTALL=0
|
||||||
OPT_RECURSE=0
|
OPT_RECURSE=0
|
||||||
|
OPT_FORCE=0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set -- `getopt is $*`
|
#hook_git_clone_pre() {
|
||||||
|
#}
|
||||||
|
#hook_git_clone_post() {
|
||||||
|
#}
|
||||||
|
|
||||||
|
hook() {
|
||||||
|
FN="hook_$1"
|
||||||
|
type $FN 2>/dev/null | grep function > /dev/null && $FN
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
set -- `getopt ifs $*`
|
||||||
for i in $*
|
for i in $*
|
||||||
do
|
do
|
||||||
case $i in
|
case $i in
|
||||||
|
-f) OPT_FORCE=1; shift;;
|
||||||
-i) OPT_INSTALL=1; shift;;
|
-i) OPT_INSTALL=1; shift;;
|
||||||
-s) OPT_RECURSE=1; shift;;
|
-s) OPT_RECURSE=1; shift;;
|
||||||
--) shift; break;;
|
--) shift; break;;
|
||||||
@@ -50,31 +65,35 @@ DESTDIR="${HERE}/staging"
|
|||||||
PKGDIR="${HERE}/pkg"
|
PKGDIR="${HERE}/pkg"
|
||||||
export DESTDIR
|
export DESTDIR
|
||||||
|
|
||||||
mkdir -p "${SRCDIR}"
|
|
||||||
mkdir -p "${DESTDIR}"
|
|
||||||
mkdir -p "${PKGDIR}"
|
|
||||||
|
|
||||||
|
|
||||||
URL_PROTO=`echo "$URL" | cut -f1 -d':'`
|
URL_PROTO=`echo "$URL" | cut -f1 -d':'`
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
rm -rf src pkg staging
|
||||||
|
rm -f .download .extract .patchsrc .configure .build .install .package .installpkg
|
||||||
|
}
|
||||||
|
|
||||||
download() {
|
download() {
|
||||||
cd "${SRCDIR}"
|
|
||||||
|
|
||||||
case $URL_PROTO in
|
case $URL_PROTO in
|
||||||
http|https|ftp)
|
http|https|ftp)
|
||||||
|
cd "${SRCDIR}"
|
||||||
/usr/sfw/bin/wget -c "${URL}"
|
/usr/sfw/bin/wget -c "${URL}"
|
||||||
|
cd "${HERE}"
|
||||||
;;
|
;;
|
||||||
git)
|
git)
|
||||||
P=`echo "${URL}" | cut -f2 -d':'`
|
P=`echo "${URL}" | cut -f2 -d':'`
|
||||||
H=`echo "$P" | cut -f1 -d'@'`
|
H=`echo "$P" | cut -f1 -d'@'`
|
||||||
T=`echo "$P" | cut -f2 -d'@'`
|
T=`echo "$P" | cut -f2 -d'@'`
|
||||||
|
hook git_clone_pre
|
||||||
|
cd "${SRCDIR}"
|
||||||
git clone --depth 1 --branch "$T" https:$H "${PACKAGE}-${VERSION}"
|
git clone --depth 1 --branch "$T" https:$H "${PACKAGE}-${VERSION}"
|
||||||
cd "${PACKAGE}-${VERSION}"
|
hook git_clone_post
|
||||||
git submodule init && git submodule update
|
cd "${HERE}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
cd "${HERE}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extract() {
|
extract() {
|
||||||
@@ -111,6 +130,9 @@ package() {
|
|||||||
# tar -cf "${HERE}/${PACKAGE}_${VERSION}_${ARCH}_${OS}.tar" *
|
# tar -cf "${HERE}/${PACKAGE}_${VERSION}_${ARCH}_${OS}.tar" *
|
||||||
# cd "${HERE}"
|
# cd "${HERE}"
|
||||||
# compress -f ${PACKAGE}_${VERSION}_${ARCH}_${OS}.tar
|
# compress -f ${PACKAGE}_${VERSION}_${ARCH}_${OS}.tar
|
||||||
|
|
||||||
|
rm "${HERE}/Prototype"
|
||||||
|
rm "${HERE}/pkginfo"
|
||||||
}
|
}
|
||||||
|
|
||||||
runonce() {
|
runonce() {
|
||||||
@@ -132,7 +154,7 @@ checkdepend() {
|
|||||||
CATNAME=`echo $DEP | cut -f1 -d'/'`
|
CATNAME=`echo $DEP | cut -f1 -d'/'`
|
||||||
PKGNAME=`echo $DEP | cut -f2 -d'/'`
|
PKGNAME=`echo $DEP | cut -f2 -d'/'`
|
||||||
if pkginfo -q -c $CATNAME $PKGNAME; then
|
if pkginfo -q -c $CATNAME $PKGNAME; then
|
||||||
echo "$PKGNAME found"
|
printf ""
|
||||||
else
|
else
|
||||||
echo "Missing requirement: $DEP"
|
echo "Missing requirement: $DEP"
|
||||||
if [ "${OPT_RECURSE}" = "1" ]; then
|
if [ "${OPT_RECURSE}" = "1" ]; then
|
||||||
@@ -165,13 +187,23 @@ patchsrc() {
|
|||||||
|
|
||||||
checkdepend
|
checkdepend
|
||||||
|
|
||||||
|
if [ "${OPT_FORCE}" = "1" ]; then
|
||||||
|
cleanup
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
mkdir -p "${SRCDIR}"
|
||||||
|
|
||||||
runonce download
|
runonce download
|
||||||
runonce extract
|
runonce extract
|
||||||
runonce patchsrc
|
runonce patchsrc
|
||||||
runonce configure
|
runonce configure
|
||||||
runonce build
|
runonce build
|
||||||
|
|
||||||
|
mkdir -p "${DESTDIR}"
|
||||||
runonce install
|
runonce install
|
||||||
|
|
||||||
|
mkdir -p "${PKGDIR}"
|
||||||
runonce package
|
runonce package
|
||||||
|
|
||||||
if [ "${OPT_INSTALL}" = "1" ]; then
|
if [ "${OPT_INSTALL}" = "1" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user