diff --git a/INSTALL.sh b/INSTALL.sh
index cff67d5..1647b61 100755
--- a/INSTALL.sh
+++ b/INSTALL.sh
@@ -8,7 +8,7 @@ REVDEPD=/etc/revdep.d
REVDEPCONF=/etc/revdep.conf
mkdir -pv ${DESTDIR}{${BINDIR},${CONFDIR},${PORT_DIR},${REVDEPD}}
-install -m755 revdep pkgadd pkgdel pkgbuild pkgdeplist scratch updateconf ${DESTDIR}${BINDIR}
+install -m755 revdep pkgadd pkgdel pkgbuild scratch updateconf ${DESTDIR}${BINDIR}
install -m644 scratchpkg.conf scratchpkg.repo ${DESTDIR}${CONFDIR}
install -dm777 ${DESTDIR}${CACHE_DIR}/{packages,sources,log,work}
install -m644 revdep.conf ${DESTDIR}${REVDEPCONF}
diff --git a/pkgbuild b/pkgbuild
index cee3c04..f918c69 100755
--- a/pkgbuild
+++ b/pkgbuild
@@ -35,10 +35,16 @@ msgwarn() {
}
updatemdsum() {
+ msg "Generating .checksums..."
+ generatemdsum > .checksums
+}
+
+generatemdsum() {
+ local um file missingsource
if [ -z $source ]; then
- msgwarn "source=() is empty, no need md5sum."
- abort 0
+ echo SKIP > .checksums
+ return 0
fi
for um in $(seq 0 $((${#source[@]} - 1))); do
@@ -68,46 +74,30 @@ updatemdsum() {
abort 1
fi
- echo -e "md5sum=($(md5sum $needupdatechecksum | awk '{ print $1 }'))"
+ md5sum $needupdatechecksum | sed -e 's| .*/| |' | sort -k 2
}
checkmdsum() {
+ local mismatch m
- if [ -n "$source" ] && [ -z "$md5sum" ]; then
- msgerr "md5sum=() is empty, please provide it."
- abort 1
+ if [ ! -f .checksums ]; then
+ msg "Generating .checksums..."
+ generatemdsum > .checksums
+ else
+ generatemdsum > .checksums.tmp
+ mismatch=$(diff -w -t -U 0 .checksums .checksums.tmp | sed '/^---/d;/^+++/d;/^@@/d' | awk '{print $2}' | uniq)
fi
- if [ "${#source[@]}" != "${#md5sum[@]}" ]; then
- msgerr "Total source and md5sums different."
- abort 1
- fi
+ rm -f .checksums.tmp
- for s in $(seq 0 $((${#source[@]} - 1))); do
- if [ $(echo ${source[$s]} | grep -E "(ftp|http|https)://") ]; then
- if [ $(echo ${source[$s]} | grep -E "::(ftp|http|https)://") ]; then
- sourcename=$SOURCE_DIR/$(echo ${source[$s]} | awk -F '::' '{print $1}')
- else
- sourcename=$SOURCE_DIR/$(echo ${source[$s]} | rev | cut -d / -f 1 | rev)
- fi
- else
- sourcename="${source[$s]}"
- fi
- sum=$(md5sum "$sourcename" | awk '{ print $1 }')
- if [ "$sum" != "${md5sum[$s]}" ] && [ "SKIP" != "${md5sum[$s]}" ]; then
- errormdsum+=($sourcename)
- fi
- done
-
- if [ "${#errormdsum[@]}" -gt 0 ]; then
+ if [ "$mismatch" ]; then
msgerr "md5sum mismatch:"
- for mismatch in ${errormdsum[@]}; do
- msg2 "$mismatch"
+ for m in $mismatch; do
+ msg2 $m
done
abort 1
- fi
-
+ fi
}
download_src() {
@@ -157,8 +147,8 @@ download_src() {
prepare_src() {
local FILE FILENAME SRC_DIR
-
- [ "$IGNORE_MDSUM" ] || checkmdsum
+ echo $CHECK_MDSUM
+ [ "$IGNORE_MDSUM" -o "$CHECK_MDSUM" = 0 ] || checkmdsum
SRC=$WORK_DIR/$name/src
PKG=$WORK_DIR/$name/pkg
@@ -440,6 +430,8 @@ set_options() {
!buildflags) BUILD_FLAGS=0 ;;
makeflags) MAKE_FLAGS=1 ;;
!makeflags) MAKE_FLAGS=0 ;;
+ mdsum) CHECK_MDSUM=1 ;;
+ !mdsum) CHECK_MDSUM=0 ;;
esac
done
}
@@ -653,7 +645,7 @@ main() {
abort 0
fi
- # calculate & print md5sum
+ # update md5sum
if [ "$UPDATE_MDSUM" ]; then
updatemdsum
abort 0
@@ -695,7 +687,7 @@ WORK_DIR="/var/cache/scratchpkg/work"
DOWNLOAD_PROG="wget"
COMPRESSION_MODE="xz"
-OPTIONS=(!libtool emptydirs strip zipman buildflags makeflags)
+OPTIONS=(!libtool emptydirs strip zipman buildflags makeflags checksum)
INCLUDEINPKG=(install readme mkdirs)
diff --git a/pkgdeplist b/pkgdeplist
deleted file mode 100755
index 1de3b2c..0000000
--- a/pkgdeplist
+++ /dev/null
@@ -1,185 +0,0 @@
-#!/bin/bash
-#
-# scratchpkg
-#
-# Copyright (c) 2018 by Emmett1 (emmett1.2miligrams@gmail.com)
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-#
-
-INDEX_DIR="/var/lib/scratchpkg/index"
-REPO_FILE="/etc/scratchpkg.repo"
-
-msgerr() {
- echo -e "==> ERROR: $1"
-}
-
-msginst() {
- echo -e "[i] $1"
-}
-
-msgmiss() {
- echo -e "[m] $1"
-}
-
-msgforeign() {
- echo -e "[f] $1"
-}
-
-msgnoinst() {
- echo -e "[-] $1"
-}
-
-checkdep() {
- local depends
- PORT_PATH=$(getportpath "$1")
- if [ "$PORT_PATH" ]; then
- depends=$(grep "^# depends[[:blank:]]*:" $PORT_PATH/spkgbuild | sed 's/^# depends[[:blank:]]*:[[:blank:]]*//' | tr ' ' '\n' | awk '!a[$0]++')
- for dep in ${depends[@]}; do
- echo $dep
- done
- else
- return 0
- fi
-}
-
-getportpath() {
- for repo in ${PORT_REPO[@]}; do
- if [[ -f $repo/$1/spkgbuild ]]; then
- dirname $repo/$1/spkgbuild
- return 0
- fi
- done
- return 1
-}
-
-deplist() {
- # check currently process package for loop
- if [ ${#CHECK[@]} -gt 0 ]; then
- if [[ "$(echo ${CHECK[@]} | tr " " "\n" | grep -x $1)" == "$1" ]]; then
- if [ "$IGNORE_LOOP" = 1 ]; then
- return 0
- else
- msgerr "loop dependency found: $1"
- exit 1
- fi
- fi
- fi
-
- # add package to currently process
- CHECK+=($1)
-
- # check dependencies
- for i in $(checkdep $1); do
- [ -e $INDEX_DIR/$i/.pkginfo ] && [ "$QUICK" ] && continue
- if [[ $(echo ${DEP[@]} | tr " " "\n" | grep -x $i) = "" ]]; then
- deplist $i
- fi
- done
-
- # add dependency to list checked dep
- if [[ $(echo ${DEP[@]} | tr " " "\n" | grep -x $1) = "" ]]; then
- DEP+=($1)
- fi
-
- # delete process package array
- for i in "${!CHECK[@]}"; do
- if [[ ${CHECK[i]} = "$1" ]]; then
- unset 'CHECK[i]'
- fi
- done
-}
-
-usage() {
- cat << EOF
-Usage:
- $(basename $0) [ ]
-
-Options:
- -q, --quick calculate only not-installed package/dependency
- -i, --installed print only installed package/dependency
- -n, --not-installed print only not-installed package/dependency
- -m, --missing print only missing package/dependency
- -f, --foreign print foreign package/dependency
- -l, --loop ignore loop dependencies
- -h, --help print this help message
-
-EOF
-}
-
-while [ "$1" ]; do
- case $1 in
- -q|--quick) QUICK=1 ;;
- -i|--installed) INSTALLED=1 ;;
- -n|--not-installed) NOT_INSTALLED=1 ;;
- -m|--missing) MISSING=1 ;;
- -f|--foreign) FOREIGN=1 ;;
- -l|--loop) IGNORE_LOOP=1 ;;
- -h|--help) USAGE=1 ;;
- -*) msgerr "Invalid option. ($1)"; exit 1 ;;
- *) PKG+=($1) ;;
- esac
- shift
-done
-
-if [ "$USAGE" = 1 ]; then
- usage
- exit 0
-fi
-
-if [ ! -f "$REPO_FILE" ]; then
- msgerr "repo file not exist. ($REPO_FILE)"
- exit 1
-fi
-
-if [ "${#PKG[@]}" = 0 ]; then
- msgerr "Please specify package name to list its dependencies order."
- exit 1
-fi
-
-while read -r repodir repourl junk; do
- case $repodir in
- ""|"#"*) continue ;;
- esac
- PORT_REPO+=($repodir)
-done < "$REPO_FILE"
-
-# set all to 1 (all) if not use any of it
-if [ ! "$INSTALLED" ] && [ ! "$NOT_INSTALLED" ] && [ ! "$MISSING" ] && [ ! "$FOREIGN" ]; then
- INSTALLED=1
- NOT_INSTALLED=1
- MISSING=1
- FOREIGN=1
-fi
-
-# calculate dependencies
-for pkg in ${PKG[@]}; do
- deplist $pkg
-done
-
-for deps in ${DEP[@]}; do
- if [ -e $INDEX_DIR/$deps/.pkginfo ]; then
- if [ ! $(getportpath "$deps") ]; then
- [ "$FOREIGN" ] && msgforeign "$deps" # print foreign pkg
- else
- [ "$INSTALLED" ] && msginst "$deps" # print installed
- fi
- elif [ ! $(getportpath "$deps") ]; then
- [ "$MISSING" ] && msgmiss "$deps" # print missing port
- else
- [ "$NOT_INSTALLED" ] && msgnoinst "$deps" # print not installed
- fi
-done
-
-exit 0
diff --git a/scratchpkg.conf b/scratchpkg.conf
index ee94490..a50e0fd 100644
--- a/scratchpkg.conf
+++ b/scratchpkg.conf
@@ -24,8 +24,9 @@ MAKEFLAGS="-j$(nproc)"
# -- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
# -- buildflags: Enable buildflags (CFLAGS and CXXFLAGS)
# -- makeflags: Enable makeflags (MAKEFLAGS)
+# -- checksum: Enable checking checksum
#
# -- These are default values for the options=() settings
# -- add '!' in front of this option to disable it
#
-# OPTIONS=(!libtool emptydirs strip zipman buildflags makeflags)
+# OPTIONS=(!libtool emptydirs strip zipman buildflags makeflags checksum)