This commit is contained in:
emmett1
2017-08-20 17:33:34 +08:00
parent 58d80e6293
commit d542b2727d
2 changed files with 127 additions and 54 deletions

View File

@@ -14,11 +14,18 @@ updatemdsum() {
for file in ${needupdatechecksum[@]}; do
if [ ! -f $file ]; then
msg "Error updating checksum, source not found."
exitscript1
missingsource+=($file)
fi
done
if [ "${#missingsource[@]}" -gt 0 ]; then
msg "Missing source:"
for ms in ${missingsource[@]}; do
msg2 "$ms"
done
exitscript1
fi
md5sum $needupdatechecksum | awk '{ print $1 }' > .md5sum
[ -f .md5sum ] && msg "md5sum updated."
else
@@ -28,20 +35,34 @@ updatemdsum() {
checkmdsum() {
for sources in ${source[@]}; do
if [[ $sources =~ ^(http|https|ftp)://.*/(.+) ]]; then
sourcename=$SOURCE_DIR/$(echo $sources | rev | cut -d / -f 1 | rev)
for i in $(cat .md5sum); do
mdsums+=($i)
done
if [ "${#source[@]}" != "${#mdsums[@]}" ]; then
msg "${color_red}Error${color_reset}, total source and md5sums different."
exitscript1
fi
for s in $(seq 0 $((${#source[@]} - 1))); do
if [[ ${source[$s]} =~ ^(http|https|ftp)://.*/(.+) ]]; then
sourcename=$SOURCE_DIR/$(echo ${source[$s]} | rev | cut -d / -f 1 | rev)
else
sourcename="$sources"
sourcename="${source[$s]}"
fi
sourcemd5sum=$(md5sum $sourcename | awk '{ print $1 }')
if [ ! $(grep $sourcemd5sum .md5sum) ]; then
msg "${color_red}Checksum error:${color_reset} $sourcename"
CHECKSUM_ERROR=yes
sum=$(md5sum "$sourcename" | awk '{ print $1 }')
if [ "$sum" != "${mdsums[$s]}" ] && [ "SKIP" != "${mdsums[$s]}" ]; then
errormdsum+=($sourcename)
fi
done
[ "$CHECKSUM_ERROR" ] && exitscript1
if [ "${#errormdsum[@]}" -gt 0 ]; then
msg "${color_red}Error${color_reset}, md5sum mismatch:"
for mismatch in ${errormdsum[@]}; do
msg2 "$mismatch"
done
exitscript1
fi
}
@@ -98,7 +119,7 @@ preparesource() {
for i in ${noextract[@]}; do
if [ "$i" = "$tarballname" ]; then
NO_EXTRACT=yes
msg "Preparing ${color_green}$tarballname${color_reset}..." && cp $SOURCE_DIR/$tarballname $SRC || ERROR_PREPARE_SOURCE=yes
msg "Preparing ${color_green}$tarballname${color_reset}..." && cp $SOURCE_DIR/$tarballname $SRC || ERROR_PREPARE_SOURCE+=($tarballname)
break
fi
done
@@ -122,13 +143,16 @@ preparesource() {
fi
fi
else
msg2 "Preparing ${color_green}$sources${color_reset}..." && cp $sources $SRC || ERROR_PREPARE_SOURCE=yes
msg2 "Preparing ${color_green}$sources${color_reset}..." && cp $sources $SRC || ERROR_PREPARE_SOURCE+=($sources)
fi
done
fi
if [ "$ERROR_PREPARE_SOURCE" ]; then
msg "Error preparing ${color_red}$sources${color_reset}."
if [ "${#ERROR_PREPARE_SOURCE[@]}" -gt 0 ]; then
msg "${color_red}Error${color_reset}, failed prepared source:"
for err in ${ERROR_PREPARE_SOURCE[@]}; do
msg2 $err
done
clearworkdir
exitscript1
fi
@@ -147,7 +171,7 @@ loadspkgbuild() {
. $BUILD_SCRIPT
getpkginfo
else
msg "${color_red}Error no $BUILD_SCRIPT found.${color_reset}"
msg "${color_red}Error${color_reset}, no $BUILD_SCRIPT found."
exitscript1
fi
@@ -260,7 +284,7 @@ compressinfomanpages() {
if [ -d usr/share/man ]; then
msg2 "Compressing man pages..."
( cd usr/share/man
find . -type f ! -name "*.gz" -exec gzip -9 {} \;
find . -type f ! -name "*.gz" -exec gzip -9 -f {} \;
for i in $(find . -type l) ; do ln -s $(readlink $i).gz $i.gz ; rm $i ; done
)
fi
@@ -525,7 +549,6 @@ parse_options() {
--no-orphan-check)
NO_ORPHAN_CHECK=yes
;;
# this option not pass to installpkg
-fr|--force-rebuild)
FORCE_REBUILD=yes
;;
@@ -535,9 +558,6 @@ parse_options() {
-um|--update-mdsum)
UPDATE_MDSUM=yes
;;
-cm|--check-mdsum)
CHECK_MDSUM=yes
;;
-do|--download-only)
DOWNLOAD_ONLY=yes
;;
@@ -553,6 +573,9 @@ parse_options() {
-rd|--redownload)
REDOWNLOAD_SOURCE=yes
;;
--no-backup)
NO_BACKUP=yes
;;
-h|--help)
SHOW_HELP=yes
;;
@@ -615,6 +638,8 @@ main() {
loadspkgbuild
[ "$INSTALL_PKG" ] || [ "$REINSTALL_PKG" ] || [ "$UPGRADE_PKG" ] && NO_ORPHAN_CHECK=yes
if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
NO_ORPHAN_CHECK=yes
fi
@@ -634,12 +659,6 @@ main() {
exit 0
fi
### CHECK CHECKSUM ###
if [ "$CHECK_MDSUM" ]; then
checkmdsum
exit 0
fi
### CHECK FOR LOCK FILE ###
if [ -f /tmp/spkg.$name.lock ]; then
msg "Cant build same package simultaneously."
@@ -677,6 +696,7 @@ main() {
updatepkgdepends
fi
buildpkg
IGNORE_DEP=yes
if [ ! "$NO_ORPHAN_CHECK" ]; then
checkneworphan
fi
@@ -692,6 +712,7 @@ main() {
NO_PREINSTALL="$NO_PREINSTALL" \
NO_POSTINSTALL="$NO_POSTINSTALL" \
NO_COLOR="$NO_COLOR" \
NO_BACKUP="$NO_BACKUP" \
installpkg $PACKAGE_DIR/$PKGNAME
exitscript0
fi

106
scratch
View File

@@ -1,27 +1,5 @@
#!/bin/bash
pushtoport() {
for port in ${PORT_REPO[@]}; do
if [ -d $port/$PORTNAME ]; then
PORT_EXIST=yes
pushd $port/$PORTNAME
IGNORE_CONFLICT="$IGNORE_CONFLICT" \
IGNORE_DEP="$IGNORE_DEP" \
REINSTALL_PKG="$REINSTALL_PKG" \
UPGRADE_PKG="$UPGRADE_PKG" \
VERBOSE_INSTALL="$VERBOSE_INSTALL" \
INSTALL_PKG="$INSTALL_PKG" \
FORCE_REBUILD="$FORCE_REBUILD" \
buildpkg
popd
break
fi
done
[ ! "$PORT_EXIST" ] && msg "Port ${color_red}$PORTNAME${color_reset} not found."
}
listinstalled() {
for installed in $(ls $INDEX_DIR); do
getinstalledname $installed
@@ -345,6 +323,37 @@ interrupted() {
exit 1
}
pushtoport() {
for port in ${PORT_REPO[@]}; do
if [ -d $port/$PORTNAME ]; then
PORT_EXIST=yes
pushd $port/$PORTNAME
INSTALL_PKG="$INSTALL_PKG" \
UPGRADE_PKG="$UPGRADE_PKG" \
REINSTALL_PKG="$REINSTALL_PKG" \
IGNORE_DEP="$IGNORE_DEP" \
IGNORE_CONFLICT="$IGNORE_CONFLICT" \
VERBOSE_INSTALL="$VERBOSE_INSTALL" \
FORCE_REBUILD="$FORCE_REBUILD" \
IGNORE_MDSUM="$IGNORE_MDSUM" \
UPDATE_MDSUM="$UPDATE_MDSUM" \
DOWNLOAD_ONLY="$DOWNLOAD_ONLY" \
EXTRACT_ONLY="$EXTRACT_ONLY" \
KEEP_WORK="$KEEP_WORK" \
REDOWNLOAD_SOURCE="$REDOWNLOAD_SOURCE" \
SOURCE_PKG="$SOURCE_PKG" \
OUTPUT_PKG="$OUTPUT_PKG" \
NO_COLOR="$NO_COLOR" \
buildpkg
popd
break
fi
done
[ ! "$PORT_EXIST" ] && msg "Port ${color_red}$PORTNAME${color_reset} not found."
}
parse_options() {
while [ "$1" ]; do
@@ -352,24 +361,51 @@ parse_options() {
-i|--install)
INSTALL_PKG=yes
;;
-u|--upgrade)
UPGRADE_PKG=yes
;;
-r|--reinstall)
REINSTALL_PKG=yes
;;
-id|--ignore-dependency)
IGNORE_DEP=yes
;;
-ic|--ignore-conflict)
IGNORE_CONFLICT=yes
;;
-r|--reinstall)
REINSTALL_PKG=yes
--no-preinstall)
NO_PREINSTALL=yes
;;
--no-preinstall)
NO_POSTINSTALL=yes
;;
-fr|--force-rebuild)
FORCE_REBUILD=yes
;;
-u|--upgrade)
UPGRADE_PKG=yes
;;
-v|--verbose)
VERBOSE_INSTALL=yes
;;
-im|--ignore-mdsum)
IGNORE_MDSUM=yes
;;
-um|--update-mdsum)
UPDATE_MDSUM=yes
;;
-do|--download-only)
DOWNLOAD_ONLY=yes
;;
-eo|--extract-only)
EXTRACT_ONLY=yes
;;
-kw|--keep-work)
KEEP_WORK=yes
;;
-rd|--redownload)
REDOWNLOAD_SOURCE=yes
;;
--no-backup)
NO_BACKUP=yes
;;
-l|--list-installed)
LIST_INSTALLED=yes
;;
@@ -473,6 +509,22 @@ parse_options() {
PORT_PATH="$2"
shift
;;
-sd|--source-dir)
if [ ! "$2" ]; then
msg "Option '$1' require an argument (source path for package)."
exit 1
fi
SOURCE_PKG="$2"
shift
;;
-o|--output)
if [ ! "$2" ]; then
msg "Option '$1' require an argument (output path for compiled package)."
exit 1
fi
OUTPUT_PKG="$2"
shift
;;
*)
msg "Option invalid!"
exit 1