mirror of
https://github.com/outbackdingo/scratchpkg.git
synced 2026-02-05 00:25:53 +00:00
major changes
This commit is contained in:
73
buildpkg
73
buildpkg
@@ -223,6 +223,11 @@ loadspkgbuild() {
|
||||
|
||||
buildpackage() {
|
||||
|
||||
if [ "$UID" != 0 ]; then
|
||||
msgerr "You must build package as root, or use fakeroot."
|
||||
exitscript1
|
||||
fi
|
||||
|
||||
msg "Start build ${GREEN}$name-$version-$release${CRESET}."
|
||||
|
||||
pushd $SRC
|
||||
@@ -368,21 +373,13 @@ checkdeps() {
|
||||
|
||||
for dep in ${depends[@]}; do
|
||||
if [ ! -d $INDEX_DIR/$dep ]; then
|
||||
if [ "$INSTALL_PKG" -o "$DEP_INSTALL" ]; then
|
||||
scratch -i -p $dep --no-orphan-check ${OPTS2[@]} || exit 1
|
||||
else
|
||||
MSDEP+=($dep)
|
||||
fi
|
||||
MSDEP+=($dep)
|
||||
fi
|
||||
done
|
||||
|
||||
for makedep in ${makedepends[@]}; do
|
||||
if [ ! -d $INDEX_DIR/$makedep ]; then
|
||||
if [ "$INSTALL_PKG" -o "$DEP_INSTALL" ]; then
|
||||
scratch -i -p $makedep --no-orphan-check ${OPTS2[@]} || exit 1
|
||||
else
|
||||
MSMKDEP+=($makedep)
|
||||
fi
|
||||
MSMKDEP+=($makedep)
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -536,8 +533,55 @@ EOF
|
||||
|
||||
}
|
||||
|
||||
get_opts() {
|
||||
|
||||
for (( i=1; i<${#1}; i++ )); do
|
||||
case "${1:$i:1}" in
|
||||
i) INSTALL_PKG=yes ;;
|
||||
u) UPGRADE_PKG=yes; OPTS+=(-${1:$i:1}) ;;
|
||||
r) REINSTALL_PKG=yes; OPTS+=(-${1:$i:1}) ;;
|
||||
d) IGNORE_DEP=yes; OPTS+=(-${1:$i:1}) ;;
|
||||
c) OPTS+=(-${1:$i:1}) ;;
|
||||
v) OPTS+=(-${1:$i:1}) ;;
|
||||
f) FORCE_REBUILD=yes ;;
|
||||
m) IGNORE_MDSUM=yes ;;
|
||||
g) UPDATE_MDSUM=yes ;;
|
||||
o) DOWNLOAD_ONLY=yes ;;
|
||||
e) EXTRACT_ONLY=yes ;;
|
||||
w) KEEP_WORK=yes ;;
|
||||
h) SHOWHELP=yes ;;
|
||||
*) msg "Invalid option (-${1:$i:1})"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
parse_options() {
|
||||
|
||||
while [ "$1" ]; do
|
||||
case "$1" in
|
||||
--srcdir=*) SOURCE_DIR="${1#*=}" ;;
|
||||
--pkgdir=*) PACKAGE_DIR="${1#*=}" ;;
|
||||
--no-preinstall) NO_PREINSTALL=yes; OPTS+=($1) ;;
|
||||
--no-postinstall) OPTS+=($1) ;;
|
||||
--no-preupgrade) OPTS+=($1) ;;
|
||||
--no-postupgrade) OPTS+=($1) ;;
|
||||
--no-color) NOCOLOR=yes; OPTS+=($1) ;;
|
||||
--no-backup) OPTS+=($1) ;;
|
||||
--redownload) REDOWNLOAD_SOURCE=yes ;;
|
||||
--check-source) SOURCE_CHECK=yes ;;
|
||||
--help) SHOWHELP=yes ;;
|
||||
--*) msg "Invalid option: ($1)"; exit 1 ;;
|
||||
-*) get_opts "$1" ;;
|
||||
*) msg "Invalid option: ($1)"; exit 1 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
parse_options2() {
|
||||
|
||||
while [ "$1" ]; do
|
||||
case $1 in
|
||||
-i | --install) INSTALL_PKG=yes ;;
|
||||
@@ -587,6 +631,14 @@ main() {
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$SOURCE_DIR" ]; then
|
||||
msgerr "Option '--srcdir=' need argument (path)"
|
||||
exit 1
|
||||
elif [ -z "$PACKAGE_DIR" ]; then
|
||||
msgerr "Option '--pkgdir=' need argument (path)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# source spkgbuild
|
||||
loadspkgbuild
|
||||
|
||||
@@ -666,7 +718,6 @@ main() {
|
||||
fi
|
||||
[ -f $name.install ] && . $name.install
|
||||
buildpkg
|
||||
IGNORE_DEP=yes
|
||||
if [ ! "$NO_ORPHAN_CHECK" ]; then
|
||||
checkneworphan
|
||||
fi
|
||||
|
||||
@@ -240,3 +240,15 @@ checkdirread() {
|
||||
[ "$DIR_ERROR" ] && exit 1
|
||||
|
||||
}
|
||||
|
||||
msginst() {
|
||||
echo -e "[${GREEN}*${CRESET}] $@"
|
||||
}
|
||||
|
||||
msgnoinst() {
|
||||
echo -e "[ ] $@"
|
||||
}
|
||||
|
||||
msgmiss() {
|
||||
echo -e "[${RED}m${CRESET}] $@"
|
||||
}
|
||||
|
||||
109
installpkg
109
installpkg
@@ -16,10 +16,10 @@ spkglock() {
|
||||
installpkg() {
|
||||
|
||||
#ignore dependency check
|
||||
if [ ! "$IGNORE_DEP" ]; then
|
||||
#if [ ! "$IGNORE_DEP" ]; then
|
||||
#msg2 "Checking package dependencies..."
|
||||
checkdeps
|
||||
fi
|
||||
# checkdeps
|
||||
#fi
|
||||
|
||||
msg "Installing ${GREEN}$name-$version-$release${CRESET}..."
|
||||
|
||||
@@ -30,13 +30,13 @@ installpkg() {
|
||||
|
||||
#ignore conflict
|
||||
if [ ! "$IGNORE_CONFLICT" ]; then
|
||||
msg2 "Checking package/file conflict..."
|
||||
msg2 "Checking file conflict..."
|
||||
if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
|
||||
upcheckconflict
|
||||
else
|
||||
checkconflict
|
||||
fi
|
||||
checkpkgconflict
|
||||
#checkpkgconflict
|
||||
fi
|
||||
|
||||
# create lock file prevent simultaneous install package
|
||||
@@ -178,11 +178,7 @@ checkdeps() {
|
||||
|
||||
for dep in ${depends[@]}; do
|
||||
if [ ! -d $INDEX_DIR/$dep ]; then
|
||||
if [ "$DEP_INSTALL" ]; then
|
||||
scratch -i -p $dep --no-orphan-check || exit 1
|
||||
else
|
||||
MSGDEP+=($dep)
|
||||
fi
|
||||
MSGDEP+=($dep)
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -389,33 +385,69 @@ help() {
|
||||
|
||||
cat << EOF
|
||||
Usage:
|
||||
installpkg package.spkg.txz [ <options> <arguments> ]
|
||||
installpkg package.spkg.txz <options>
|
||||
|
||||
Options:
|
||||
-u, --upgrade update package
|
||||
-r, --reinstall reinstall package
|
||||
-id, --ignore-dependency skip dependency check
|
||||
-ic, --ignore-conflict ignore conflict when installing package
|
||||
-v, --verbose verbose install process
|
||||
--no-preinstall skip preinstall script before build/install package
|
||||
--no-postinstall skip postinstall script after install package
|
||||
--no-preupgrade skip preupgrade script before upgrade package
|
||||
--no-postupgrade skip postupgrade script after upgrade package
|
||||
--no-backup skip backup when upgrading package
|
||||
--no-orphan-check skip orphaned package check after install package
|
||||
--no-color disable colour for output
|
||||
--dep install missing dependencies
|
||||
-h, --help show this help message
|
||||
-u update package
|
||||
-r reinstall package
|
||||
-d skip dependency check
|
||||
-c ignore conflict when installing package
|
||||
-v print files installed
|
||||
--no-preinstall skip preinstall script before build/install package
|
||||
--no-postinstall skip postinstall script after install package
|
||||
--no-preupgrade skip preupgrade script before upgrade package
|
||||
--no-postupgrade skip postupgrade script after upgrade package
|
||||
--no-backup skip backup when upgrading package
|
||||
--no-orphan-check skip orphaned package check after install package
|
||||
--no-color disable colour for output
|
||||
-h, --help show this help message
|
||||
|
||||
Example:
|
||||
installpkg foobar-1.0-1.spkg.txz -u --no-backup upgrade package foobar-1.0-1 without backup
|
||||
its old configuration files
|
||||
installpkg foobar-1.0-1.spkg.txz -uc --no-backup upgrade package foobar-1.0-1 without backup its
|
||||
old configuration files and skip conflict check
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
get_opts() {
|
||||
|
||||
for (( i=1; i<${#1}; i++ )); do
|
||||
case "${1:$i:1}" in
|
||||
u) UPGRADE_PKG=yes ;;
|
||||
r) REINSTALL_PKG=yes ;;
|
||||
d) IGNORE_DEP=yes ;;
|
||||
c) IGNORE_CONFLICT=yes ;;
|
||||
v) VERBOSE_INSTALL=yes ;;
|
||||
h) SHOWHELP=yes ;;
|
||||
*) msg "Invalid option (-${1:$i:1})"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
parse_options() {
|
||||
|
||||
while [ "$1" ]; do
|
||||
case $1 in
|
||||
--no-preinstall) NO_PREINSTALL=yes ;;
|
||||
--no-postinstall) NO_POSTINSTALL=yes ;;
|
||||
--no-preupgrade) NO_PREUPGRADE=yes ;;
|
||||
--no-postupgrade) NO_POSTUPGRADE=yes ;;
|
||||
--no-backup) NO_BACKUP=yes ;;
|
||||
--no-color) NOCOLOR=yes ;;
|
||||
*.spkg.txz) PKGNAME="$1" ;;
|
||||
--help) SHOWHELP=yes ;;
|
||||
--*) msg "Invalid option: ($1)"; exit 1 ;;
|
||||
-*) get_opts "$1" ;;
|
||||
*) msg "Invalid option: ($1)"; exit 1 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
parse_options2() {
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
SHOWHELP=yes
|
||||
else
|
||||
@@ -454,39 +486,39 @@ main() {
|
||||
fi
|
||||
|
||||
# show help page
|
||||
if [ "$SHOWHELP" ]; then
|
||||
if [ "$SHOWHELP" ] || [ -z "$PKGNAME" ]; then
|
||||
help
|
||||
exit 0
|
||||
fi
|
||||
|
||||
### CHECK EXISTANT OF PACKAGE FILE ###
|
||||
# check existence of package file
|
||||
if [ ! -f $PKGNAME ]; then
|
||||
msgerr "Package ${RED}$1${CRESET} not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### INTEGRITY OF PACKAGE ###
|
||||
# check integrity of package
|
||||
if ! tar -tf $PKGNAME &>/dev/null; then
|
||||
msgerr "Package ${RED}$1${CRESET} is corrupted!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### CHECK FOR ROOT ACCESS ###
|
||||
# check for root access
|
||||
needroot "Installing package"
|
||||
|
||||
### CHECK DIRECTORY ###
|
||||
# check directory
|
||||
checkdirexist "$INDEX_DIR"
|
||||
checkdirwrite "$INDEX_DIR"
|
||||
checkdirread "$INDEX_DIR"
|
||||
checkdirread "$INDEX_DIR"
|
||||
|
||||
### CHECK FOR LOCK FILE ###
|
||||
# check for lock file
|
||||
if [ -f /tmp/spkg.lock ]; then
|
||||
msgerr "Cant install/remove package simultaneously."
|
||||
msgerr "remove ${YELLOW}/tmp/spkg.lock${CRESET} if no install/remove package process running."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### EXTRACT .pkginfo file into /tmp ###
|
||||
# extract .pkginfo file into /tmp ###
|
||||
BASEPKGNAME=$(basename $PKGNAME)
|
||||
tar -xf $PKGNAME .pkginfo -O > /tmp/spkg.$BASEPKGNAME.pkginfo
|
||||
|
||||
@@ -537,12 +569,7 @@ main() {
|
||||
### INSTALL PACKAGE INTO SYSTEM ###
|
||||
installpkg
|
||||
|
||||
# check orphan package (usually makedepends package)
|
||||
if [ ! "$NO_ORPHAN_CHECK" ]; then
|
||||
checkneworphan
|
||||
fi
|
||||
|
||||
# msg2 "Running ldconfig..."
|
||||
# running ldconfig
|
||||
if [ -x /sbin/ldconfig ]; then
|
||||
/sbin/ldconfig
|
||||
fi
|
||||
|
||||
69
removepkg
69
removepkg
@@ -223,33 +223,56 @@ help() {
|
||||
|
||||
cat << EOF
|
||||
Usage:
|
||||
removepkg package name [ <options> <arguments> ]
|
||||
removepkg [ <options> <package name> ]
|
||||
|
||||
Options:
|
||||
-id, --ignore-dependency skip dependency check
|
||||
-v, --verbose verbose install process
|
||||
--no-preremove don't run pre-remove script
|
||||
--no-postremove don't run post-remove script
|
||||
--no-orphan-check skip orphaned package check after install package
|
||||
--no-color disable colour for output
|
||||
-h, --help show this help message
|
||||
-d skip dependency check
|
||||
-v print deleted files
|
||||
--no-preremove don't run pre-remove script
|
||||
--no-postremove don't run post-remove script
|
||||
--no-orphan-check skip orphaned package check removing package
|
||||
--no-color disable colour for output
|
||||
-h, --help show this help message
|
||||
|
||||
Example:
|
||||
removepkg firefox -id -v remove package firefox, skipping dependency check
|
||||
and verbose deleted file
|
||||
removepkg firefox -dv --no-preremove remove package firefox, skipping dependency check,
|
||||
print deleted files and skipp pre-remove script
|
||||
EOF
|
||||
}
|
||||
|
||||
arg() {
|
||||
if echo "" $1 | grep -vq "^ -"; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
get_opts() {
|
||||
|
||||
for (( i=1; i<${#1}; i++ )); do
|
||||
case "${1:$i:1}" in
|
||||
d) IGNORE_DEP=yes ;;
|
||||
v) VERBOSE_REMOVE=yes ;;
|
||||
h) SHOWHELP=yes ;;
|
||||
*) msg "Invalid option (-${1:$i:1})"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
parse_options() {
|
||||
|
||||
while [ "$1" ]; do
|
||||
case $1 in
|
||||
--help) SHOWHELP=yes ;;
|
||||
--no-preremove) NO_PREREMOVE=yes ;;
|
||||
--no-postremove) NO_POSTREMOVE=yes ;;
|
||||
--no-color) NOCOLOR=yes ;;
|
||||
--no-orphan-check) NO_ORPHAN_CHECK=yes ;;
|
||||
--*) msg "Invalid option: ($1)"; exit 1 ;;
|
||||
-*) get_opts "$1" ;;
|
||||
*) RMNAME+=($1) ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
parse_options2() {
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
SHOWHELP=yes
|
||||
else
|
||||
@@ -280,20 +303,20 @@ main() {
|
||||
fi
|
||||
|
||||
# show help page
|
||||
if [ "$SHOWHELP" ]; then
|
||||
if [ "$SHOWHELP" ] || [ -z "$RMNAME" ]; then
|
||||
help
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
### CHECK FOR ROOT ACCESS ###
|
||||
# check for root access
|
||||
needroot "Removing package"
|
||||
|
||||
### CHECK DIRECTORY ###
|
||||
# check directory
|
||||
checkdirexist "$INDEX_DIR"
|
||||
checkdirwrite "$INDEX_DIR"
|
||||
checkdirread "$INDEX_DIR"
|
||||
|
||||
### CHECK FOR LOCK FILE ###
|
||||
# check for lock file
|
||||
if [ -f /tmp/spkg.lock ]; then
|
||||
msgerr "Cant install/remove package simultaneously."
|
||||
msgerr "remove ${YELLOW}/tmp/spkg.lock${CRESET} if no install/remove package process running."
|
||||
@@ -309,12 +332,12 @@ main() {
|
||||
fi
|
||||
done
|
||||
|
||||
### CHECK NEW ORPHANED PACKAGE ###
|
||||
# check for orphan package
|
||||
if [ ! "$NO_ORPHAN_CHECK" ]; then
|
||||
checkneworphan
|
||||
fi
|
||||
|
||||
# msg2 "Running ldconfig..."
|
||||
# running ldconfig
|
||||
if [ -x /sbin/ldconfig ]; then
|
||||
/sbin/ldconfig
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user