4 Commits

Author SHA1 Message Date
emmett1
f3018114dd add mask function 2020-07-29 22:09:27 +08:00
emmett1
eee0a24f61 remove obsolete part in scratch info 2020-04-28 23:57:15 +08:00
emmett1
ab23dbde67 add CROSS_COMPILE env for strip 2020-04-28 23:56:04 +08:00
emmett1
f74b026a13 add logging option to scratch build 2020-04-27 18:02:18 +08:00
5 changed files with 49 additions and 29 deletions

View File

@@ -275,20 +275,20 @@ strip_files() {
find . -type f -printf "%P\n" 2>/dev/null | $FILTER | while read -r binary ; do
case "$(file -bi "$binary")" in
*application/x-sharedlib*) # Libraries (.so)
strip --strip-unneeded "$binary" 2>/dev/null ;;
${CROSS_COMPILE}strip --strip-unneeded "$binary" 2>/dev/null ;;
*application/x-pie-executable*) # Libraries (.so)
strip --strip-unneeded "$binary" 2>/dev/null ;;
${CROSS_COMPILE}strip --strip-unneeded "$binary" 2>/dev/null ;;
*application/x-archive*) # Libraries (.a)
strip --strip-debug "$binary" 2>/dev/null ;;
${CROSS_COMPILE}strip --strip-debug "$binary" 2>/dev/null ;;
*application/x-object*)
case "$binary" in
*.ko) # Kernel module
strip --strip-unneeded "$binary" 2>/dev/null ;;
${CROSS_COMPILE}strip --strip-unneeded "$binary" 2>/dev/null ;;
*)
continue;;
esac;;
*application/x-executable*) # Binaries
strip --strip-all "$binary" 2>/dev/null ;;
${CROSS_COMPILE}strip --strip-all "$binary" 2>/dev/null ;;
*)
continue ;;
esac

54
scratch
View File

@@ -91,12 +91,12 @@ vercomp() {
installed_pkg_info() {
if isinstalled $2; then
grep ^$1 $PKGDB_DIR/$2/.pkginfo | cut -d " " -f3-
grep ^$1 $PKGDB_DIR/$2/.pkginfo 2>/dev/null | cut -d " " -f3-
fi
}
allinstalled() {
grep ^name "$PKGDB_DIR"/*/.pkginfo | awk '{print $3}'
grep ^name "$PKGDB_DIR"/*/.pkginfo 2>/dev/null | awk '{print $3}'
}
deps_alias() {
@@ -492,6 +492,7 @@ scratch_build() {
while [ "$1" ]; do
case $1 in
-i|-u|-r|-g|-p) ;;
--log) LOG=1;;
-*) OPTS="$OPTS $1";;
*) PKGNAME="$PKGNAME $1";;
esac
@@ -508,10 +509,17 @@ scratch_build() {
}
cd $ppath
settermtitle "Building $pkg..."
pkgbuild $OPTS || {
settermtitle "Building $pkg failed."
return 1
}
if [ "$LOG" ]; then
pkgbuild $OPTS | tee /var/log/pkgbuild.log || {
settermtitle "Building $pkg failed."
return 1
}
else
pkgbuild $OPTS || {
settermtitle "Building $pkg failed."
return 1
}
fi
settermtitle "Building $pkg done."
cd - >/dev/null
done
@@ -689,18 +697,21 @@ scratch_remove() {
outdatepkg() {
for pkg in $(allinstalled); do
if [ ! -e "$PKGDB_DIR/$pkg/.lock" ] && getportpath $pkg >/dev/null; then
. $(getportpath $pkg)/$BUILD_SCRIPT
if [ -z "$name" ] || [ -z "$version" ]; then
continue
fi
iversion=$(installed_pkg_info version $pkg)
irelease=$(installed_pkg_info release $pkg)
if [ "$release" != "$irelease" ] || [ "$version" != "$iversion" ]; then
echo $name
fi
unset iversion irelease version release
if [ -f "$MASK_FILE" ] && [ $(grep -Ev '^(#|$| )' $MASK_FILE | grep $pkg) ]; then
continue
fi
[ -e "$PKGDB_DIR/$pkg/.lock" ] && continue
getportpath $pkg >/dev/null || continue
. $(getportpath $pkg)/$BUILD_SCRIPT
if [ -z "$name" ] || [ -z "$version" ]; then
continue
fi
iversion=$(installed_pkg_info version $pkg)
irelease=$(installed_pkg_info release $pkg)
if [ "$release" != "$irelease" ] || [ "$version" != "$iversion" ]; then
echo $name
fi
unset iversion irelease version release
done
}
@@ -895,7 +906,10 @@ scratch_outdate() {
fi
iversion=$(installed_pkg_info version $pkg)
irelease=$(installed_pkg_info release $pkg)
[ -f "$PKGDB_DIR/$pkg/.lock" ] && ITSLOCK="[locked]"
[ -f "$PKGDB_DIR/$pkg/.lock" ] && ITSLOCK="[masked]"
if [ -f "$MASK_FILE" ] && [ $(grep -Ev '^(#|$| )' $MASK_FILE | grep $pkg) ]; then
ITSLOCK="[masked]"
fi
outdatemsg="$name $iversion-$irelease => $version-$release $ITSLOCK"
newerinstmsg="$name $iversion-$irelease => $version-$release [newer installed] $ITSLOCK"
if [ "$version" != "$iversion" ]; then
@@ -1222,7 +1236,6 @@ scratch_info() {
. $ppath/$BUILD_SCRIPT
desc=$(grep "^# description[[:blank:]]*:" $ppath/$BUILD_SCRIPT | sed 's/^# description[[:blank:]]*:[[:blank:]]*//')
url=$(grep "^# homepage[[:blank:]]*:" $ppath/$BUILD_SCRIPT | sed 's/^# homepage[[:blank:]]*:[[:blank:]]*//')
maint=$(grep "^# maintainer[[:blank:]]*:" $ppath/$BUILD_SCRIPT | sed 's/^# maintainer[[:blank:]]*:[[:blank:]]*//')
deps=$(get_depends $1 | tr '\n' ' ')
@@ -1231,7 +1244,6 @@ scratch_info() {
echo "Version: $version"
echo "Release: $release"
echo "Description: $desc"
echo "Homepage: $url"
echo "Maintainer: $maint"
echo "Dependencies: $deps"
}
@@ -1356,6 +1368,7 @@ Options:
--exclude=* exclude dependencies, comma separated
build <ports> <arg> build ports (use pkgbuild arg, except '-i', '-u', '-r', '-g', & '-p')
--log log build process (/var/log/pkgbuild.log)
lock <ports> locking ports prevent upgrade
unlock <ports> unlock locked ports
@@ -1431,6 +1444,7 @@ BUILD_SCRIPT="spkgbuild"
PKGDB_DIR="$(pkgadd --print-dbdir)"
REPO_FILE="${REPO_FILE:-/etc/scratchpkg.repo}"
ALIAS_FILE="${ALIAS_FILE:-/etc/scratchpkg.alias}"
MASK_FILE="${MASK_FILE:-/etc/scratchpkg.mask}"
# default value from pkgbuild
SOURCE_DIR="/var/cache/scratchpkg/sources"

View File

@@ -6,4 +6,4 @@
#
# example:
# openssl libressl
#
#

View File

@@ -2,9 +2,9 @@
# Configuration file for scratchpkg
#
CFLAGS="-O2 -march=x86-64 -pipe"
CXXFLAGS="${CFLAGS}"
MAKEFLAGS="-j$(nproc)"
# CFLAGS="-O2 -march=x86-64 -pipe"
# CXXFLAGS="${CFLAGS}"
# MAKEFLAGS="-j$(nproc)"
# SOURCE_DIR="/var/cache/scratchpkg/sources"
# PACKAGE_DIR="/var/cache/scratchpkg/packages"

6
scratchpkg.mask Normal file
View File

@@ -0,0 +1,6 @@
# exclude packages from sysup
glibc
gcc
linux-api-headers
binutils