25 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
emmett1
552e0c7bfe updated 2020-04-27 13:52:05 +08:00
emmett1
34b9568afb fix printf colourize 2020-04-27 13:09:02 +08:00
emmett1
0aa9868d15 fixesss 2020-04-22 14:27:39 +08:00
emmett1
f0ff3d070e add function to use custom repo and alias file 2020-04-10 22:41:09 +08:00
emmett1
985f59fc97 update alias function 2020-04-10 13:18:13 +08:00
emmett1
2651ad3188 remove pkglocate 2020-04-07 00:39:36 +08:00
emmett1
3602e0a8e8 add locate function 2020-04-07 00:39:12 +08:00
emmett1
c816e3b409 update pkgbase 2020-04-02 16:22:27 +08:00
emmett1
8d4b7902eb add usr/lib/locale to removelocales function 2020-04-02 16:20:02 +08:00
emmett1
32b7462f2d updated 2020-03-30 17:17:39 +08:00
emmett1
a1ef1c5b33 move pkgquery function back to scratch 2020-03-16 17:52:49 +08:00
emmett1
b72816f8df revert logging 2020-03-14 00:12:29 +08:00
emmett1
9b186bfd31 add logging, --log 2020-03-13 17:20:31 +08:00
emmett1
8e8c62d338 xchroot: add '-l' to umount 2020-03-05 17:32:54 +08:00
emmett1
c8b2eca5ba updated 2020-02-25 23:59:33 +08:00
emmett1
a23a22c659 fix scratch_upgrade 2020-02-25 18:07:35 +08:00
emmett1
9a06fbd474 fix pkgadd 2020-02-19 17:03:24 +08:00
emmett1
7a91fbdcd4 replace type with command 2020-02-19 15:23:42 +08:00
emmett1
00e55a2473 replace type with command 2020-02-19 00:39:34 +08:00
emmett1
0ee256b921 fix 2020-02-17 23:58:18 +08:00
emmett1
424c56f075 fix typo 2020-02-12 23:48:17 +08:00
18 changed files with 951 additions and 589 deletions

View File

@@ -16,7 +16,8 @@ install -dm777 ${DESTDIR}${CACHE_DIR}/packages
install -dm777 ${DESTDIR}${CACHE_DIR}/sources install -dm777 ${DESTDIR}${CACHE_DIR}/sources
install -dm777 ${DESTDIR}${CACHE_DIR}/work install -dm777 ${DESTDIR}${CACHE_DIR}/work
install -m755 xchroot revdep pkgadd pkgdel pkgbuild pkgquery scratch updateconf ${DESTDIR}${BINDIR} install -m755 xchroot revdep pkgadd pkgdel pkgbuild pkgquery scratch updateconf \
pkgbase pkgdepends pkgrebuild pkgfix portcreate ${DESTDIR}${BINDIR}
install -m644 scratchpkg.conf scratchpkg.repo scratchpkg.alias ${DESTDIR}${CONFDIR} install -m644 scratchpkg.conf scratchpkg.repo scratchpkg.alias ${DESTDIR}${CONFDIR}
install -m644 revdep.conf ${DESTDIR}${REVDEPCONF} install -m644 revdep.conf ${DESTDIR}${REVDEPCONF}

View File

@@ -129,7 +129,7 @@ Available options:
### pkgadd ### pkgadd
`pkgadd` is a tool to install and upgrade package created by `pkgbuild`. Install package is simply extract `pkgadd` is a tool to install and upgrade package created by `pkgbuild`. Install package is simply extract
`<name>-<version>-<release>.spkg.txz` by using tar into real system then save list extracted file into package `INDEX_DIR`. `<name>-<version>-<release>.spkg.txz` by using tar into real system then save list extracted file into package `PKGDB_DIR`.
Upgrading package is also using same extract as install, it will replace old files then compare list file from old and new Upgrading package is also using same extract as install, it will replace old files then compare list file from old and new
package and remove old file which not exist in new package (like Slackware pkgtool does). package and remove old file which not exist in new package (like Slackware pkgtool does).
@@ -154,7 +154,7 @@ package and remove old file which not exist in new package (like Slackware pkgto
old configuration files and skip conflict check old configuration files and skip conflict check
### pkgdel ### pkgdel
`pkgdel` is a tool to remove package from system. It will read file listed in package `INDEX_DIR` and remove it. `pkgdel` is a tool to remove package from system. It will read file listed in package `PKGDB_DIR` and remove it.
Usage: Usage:
pkgdel [ <options> <package name> ] pkgdel [ <options> <package name> ]

54
pkgadd
View File

@@ -36,11 +36,11 @@ msg2() {
} }
msgerr() { msgerr() {
echo "==> ERROR: $1" echo "==> ERROR: $1" >&2
} }
msgwarn() { msgwarn() {
echo "==> WARNING: $1" echo "==> WARNING: $1" >&2
} }
help() { help() {
@@ -59,6 +59,7 @@ Options:
--no-preupgrade skip preupgrade script before upgrade package --no-preupgrade skip preupgrade script before upgrade package
--no-postupgrade skip postupgrade script after upgrade package --no-postupgrade skip postupgrade script after upgrade package
--no-backup skip backup when upgrading package --no-backup skip backup when upgrading package
--print-dbdir print package database path
--root=<path> install to custom root directory --root=<path> install to custom root directory
EOF EOF
@@ -96,6 +97,7 @@ parse_opts() {
--no-preupgrade) NO_PREUPGRADE=yes ;; --no-preupgrade) NO_PREUPGRADE=yes ;;
--no-postupgrade) NO_POSTUPGRADE=yes ;; --no-postupgrade) NO_POSTUPGRADE=yes ;;
--no-backup) NO_BACKUP=yes ;; --no-backup) NO_BACKUP=yes ;;
--print-dbdir) PRINTDBDIR=yes ;;
--root=*) ROOT_DIR="${1#*=}" ;; --root=*) ROOT_DIR="${1#*=}" ;;
*.spkg.tar.*) PKGNAME="$(realpath $1)" ;; *.spkg.tar.*) PKGNAME="$(realpath $1)" ;;
*) msg "Invalid option! ($1)"; exit 1 ;; *) msg "Invalid option! ($1)"; exit 1 ;;
@@ -112,7 +114,7 @@ ret() {
} }
isinstalled() { isinstalled() {
if [ -s "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo" ] && grep -q "$1" "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo"; then if [ -s "$ROOT_DIR/$PKGDB_DIR/$1/.pkginfo" ] && grep -q "$1" "$ROOT_DIR/$PKGDB_DIR/$1/.pkginfo"; then
return 0 return 0
else else
return 1 return 1
@@ -130,17 +132,24 @@ run_scripts() {
parse_opts $(extract_opts "$@") parse_opts $(extract_opts "$@")
SCRATCHPKG_DIR="var/lib/scratchpkg" SCRATCHPKG_DIR="var/lib/scratchpkg"
INDEX_DIR="$SCRATCHPKG_DIR/index" PKGDB_DIR="$SCRATCHPKG_DIR/index"
LOCK_FILE="$SCRATCHPKG_DIR/spkg.lock" LOCK_FILE="$SCRATCHPKG_DIR/spkg.lock"
ROOT_DIR="${ROOT_DIR%/}" # remove trailing slash
[ "$PRINTDBDIR" ] && {
echo "$ROOT_DIR/$PKGDB_DIR"
ret 0
}
# show help page # show help page
[ "$SHOWHELP" ] || [ -z "$PKGNAME" ] && { [ "$SHOWHELP" ] || [ -z "$PKGNAME" ] && {
help help
ret 0 ret 0
} }
[ -d "$ROOT_DIR/$INDEX_DIR" ] || { [ -d "$ROOT_DIR/$PKGDB_DIR" ] || {
msgerr "Package's database directory not exist! ($ROOT_DIR$/INDEX_DIR)" msgerr "Package's database directory not exist: $ROOT_DIR/$PKGDB_DIR"
ret 1 ret 1
} }
@@ -154,6 +163,7 @@ LOCK_FILE="$SCRATCHPKG_DIR/spkg.lock"
[ -f "$ROOT_DIR/$LOCK_FILE" ] && { [ -f "$ROOT_DIR/$LOCK_FILE" ] && {
msgerr "Cant install/remove package simultaneously." msgerr "Cant install/remove package simultaneously."
msgerr "remove '$ROOT_DIR/$LOCK_FILE' if no install/remove package process running." msgerr "remove '$ROOT_DIR/$LOCK_FILE' if no install/remove package process running."
exit 1
} }
touch "$ROOT_DIR/$LOCK_FILE" 2>/dev/null || { touch "$ROOT_DIR/$LOCK_FILE" 2>/dev/null || {
@@ -177,8 +187,8 @@ name=${noextname%-*}
# get package information if installed # get package information if installed
if isinstalled $name; then if isinstalled $name; then
iversion=$(grep ^version $ROOT_DIR/$INDEX_DIR/$name/.pkginfo | cut -d " " -f3-) iversion=$(grep ^version $ROOT_DIR/$PKGDB_DIR/$name/.pkginfo | cut -d " " -f3-)
irelease=$(grep ^release $ROOT_DIR/$INDEX_DIR/$name/.pkginfo | cut -d " " -f3-) irelease=$(grep ^release $ROOT_DIR/$PKGDB_DIR/$name/.pkginfo | cut -d " " -f3-)
ALREADYINSTALLED=yes ALREADYINSTALLED=yes
fi fi
@@ -226,7 +236,7 @@ if [ ! "$IGNORE_CONFLICT" ]; then
fi fi
if [ -e "$ROOT_DIR/$line" ] || [ -L "$ROOT_DIR/$line" ]; then if [ -e "$ROOT_DIR/$line" ] || [ -L "$ROOT_DIR/$line" ]; then
if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
if ! grep -Fqx "$line" "$ROOT_DIR/$INDEX_DIR/$name/.files"; then if ! grep -Fqx "$line" "$ROOT_DIR/$PKGDB_DIR/$name/.files"; then
echo "$line" echo "$line"
touch "$TMP_CONFLICT" touch "$TMP_CONFLICT"
fi fi
@@ -289,12 +299,12 @@ if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
rmlist_dir="$ROOT_DIR/$SCRATCHPKG_DIR/.rmlist_dir" rmlist_dir="$ROOT_DIR/$SCRATCHPKG_DIR/.rmlist_dir"
reserve_dir="$ROOT_DIR/$SCRATCHPKG_DIR/.reserve_dir" reserve_dir="$ROOT_DIR/$SCRATCHPKG_DIR/.reserve_dir"
rmlist_all="$ROOT_DIR/$SCRATCHPKG_DIR/.rmlist_all" rmlist_all="$ROOT_DIR/$SCRATCHPKG_DIR/.rmlist_all"
grep '/$' $ROOT_DIR/$INDEX_DIR/*/.files \ grep '/$' $ROOT_DIR/$PKGDB_DIR/*/.files \
| grep -v $ROOT_DIR/$INDEX_DIR/$name/.files \ | grep -v $ROOT_DIR/$PKGDB_DIR/$name/.files \
| awk -F : '{print $2}' \ | awk -F : '{print $2}' \
| sort \ | sort \
| uniq > $reserve_dir # get list reserved dirs | uniq > $reserve_dir # get list reserved dirs
grep -Fxv -f "$TMP_PKGINSTALL" $ROOT_DIR/$INDEX_DIR/$name/.files > $rmlist_all # get list files and dirs to remove grep -Fxv -f "$TMP_PKGINSTALL" $ROOT_DIR/$PKGDB_DIR/$name/.files > $rmlist_all # get list files and dirs to remove
grep -v '/$' "$rmlist_all" | tac > "$rmlist_file" # get files only to remove grep -v '/$' "$rmlist_all" | tac > "$rmlist_file" # get files only to remove
grep -Fxv -f "$reserve_dir" "$rmlist_all" | grep '/$' | tac > "$rmlist_dir" # get dirs only (safe) to remove grep -Fxv -f "$reserve_dir" "$rmlist_all" | grep '/$' | tac > "$rmlist_dir" # get dirs only (safe) to remove
(cd "$ROOT_DIR"/ (cd "$ROOT_DIR"/
@@ -305,30 +315,30 @@ if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
fi fi
# register package into database # register package into database
rm -fr "$ROOT_DIR/$INDEX_DIR/$name" rm -fr "$ROOT_DIR/$PKGDB_DIR/$name"
mkdir "$ROOT_DIR/$INDEX_DIR/$name" mkdir "$ROOT_DIR/$PKGDB_DIR/$name"
echo "name = $name" > "$ROOT_DIR/$INDEX_DIR/$name/.pkginfo" echo "name = $name" > "$ROOT_DIR/$PKGDB_DIR/$name/.pkginfo"
echo "version = $version" >> "$ROOT_DIR/$INDEX_DIR/$name/.pkginfo" echo "version = $version" >> "$ROOT_DIR/$PKGDB_DIR/$name/.pkginfo"
echo "release = $release" >> "$ROOT_DIR/$INDEX_DIR/$name/.pkginfo" echo "release = $release" >> "$ROOT_DIR/$PKGDB_DIR/$name/.pkginfo"
install -m644 "$TMP_PKGINSTALL" "$ROOT_DIR/$INDEX_DIR/$name/.files" install -m644 "$TMP_PKGINSTALL" "$ROOT_DIR/$PKGDB_DIR/$name/.files"
for ii in $(grep ^.pkg* $TMP_PKGADD); do for ii in $(grep ^.pkg* $TMP_PKGADD); do
pkgfiles="$pkgfiles $ii" pkgfiles="$pkgfiles $ii"
done done
if [ "$pkgfiles" ]; then if [ "$pkgfiles" ]; then
tar -x -f "$PKGNAME" -C "$ROOT_DIR/$INDEX_DIR/$name" $pkgfiles >/dev/null 2>&1 tar -x -f "$PKGNAME" -C "$ROOT_DIR/$PKGDB_DIR/$name" $pkgfiles >/dev/null 2>&1
fi fi
if [ -f "$ROOT_DIR/$INDEX_DIR/$name/.pkginstall" ]; then if [ -f "$ROOT_DIR/$PKGDB_DIR/$name/.pkginstall" ]; then
if [ ! "$NO_POSTINSTALL" ] && [ ! "$UPGRADE_PKG" ]; then if [ ! "$NO_POSTINSTALL" ] && [ ! "$UPGRADE_PKG" ]; then
(cd "$ROOT_DIR"/ (cd "$ROOT_DIR"/
run_scripts "$INDEX_DIR/$name/.pkginstall" post-install "$version" run_scripts "$PKGDB_DIR/$name/.pkginstall" post-install "$version"
) )
fi fi
if [ "$UPGRADE_PKG" ] && [ ! "$NO_POSTUPGRADE" ]; then if [ "$UPGRADE_PKG" ] && [ ! "$NO_POSTUPGRADE" ]; then
(cd "$ROOT_DIR"/ (cd "$ROOT_DIR"/
run_scripts "$INDEX_DIR/$name/.pkginstall" post-upgrade "$version" "$iversion" run_scripts "$PKGDB_DIR/$name/.pkginstall" post-upgrade "$version" "$iversion"
) )
fi fi
fi fi

76
pkgbase Executable file
View File

@@ -0,0 +1,76 @@
#!/bin/sh
#
# 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 <https://www.gnu.org/licenses/>.
#
#
# script to remove all packages other than base and any user input
#
parseopt() {
while [ "$1" ]; do
case $1 in
-n) dryrun=1;;
-y) yes=$1;;
-h) printhelp; exit 0;;
*) pkg="$pkg $1"
esac
shift
done
}
printhelp() {
cat << EOF
Usage:
$(basename $0) [options] [packages]
Options:
-n dry-run
-y dont ask user confirmation
-h print this help msg
EOF
}
error=0
parseopt "$@"
echo "Calculate packages to keep..."
keep=$(scratch deplist base $pkg | awk '{print $2}')
echo "Calculate selected packages to remove..."
for pkg in $(scratch installed | awk '{print $1}'); do
echo $keep | tr ' ' '\n' | grep -qx $pkg || {
remove="$remove $pkg"
}
done
[ "$remove" ] && {
[ "$dryrun" = 1 ] && {
for i in $remove; do
echo "remove: $i..."
done
echo "This is dry-run, no real action is run!"
} || {
scratch remove $yes $remove || error=1
}
} || {
echo "Already on base, nothing to remove."
}
exit $error

144
pkgbuild
View File

@@ -27,46 +27,59 @@ msg2() {
} }
msgerr() { msgerr() {
echo "==> ERROR: $1" echo "==> ERROR: $1" >&2
} }
msgwarn() { msgwarn() {
echo "==> WARNING: $1" echo "==> WARNING: $1" >&2
} }
updatemdsum() { updatemdsum() {
msg "Generating .checksums..." for s in $(getsourcelist); do
generatemdsum > .checksums if [ ! -f $s ]; then
} msgerr "Source file '$s' not found."
err=1
generatemdsum() {
if [ -z "$source" ]; then
echo SKIP
return 0
fi
for src in $source; do
if echo $src | grep -qE "::(ftp|http|https)://"; then
FILENAME=$SOURCE_DIR/$(echo $src | awk -F '::' '{print $1}')
elif echo $src | grep -qE "(ftp|http|https)://"; then
FILENAME=$SOURCE_DIR/$(basename $src)
else
FILENAME=$src
fi fi
needupdatechecksum="$needupdatechecksum $FILENAME"
done done
[ "$err" = 1 ] && abort 1
md5sum $needupdatechecksum | sed -e 's| .*/| |' | sort -k 2 generatemdsum > .checksums
msg "Checksums updated."
} }
checkmdsum() { getsourcelist() {
for s in $source; do
if echo $s | grep -qE "::(ftp|http|https)://"; then
FILENAME=$SOURCE_DIR/$(echo $s | awk -F '::' '{print $1}')
elif echo $s | grep -qE "(ftp|http|https)://"; then
FILENAME=$SOURCE_DIR/$(basename $s)
else
FILENAME=$PWD/$s
fi
echo $FILENAME
done
}
generatemdsum() {
for s in $(getsourcelist); do
if [ -f $s ]; then
needupdatechecksum="$needupdatechecksum $s"
fi
done
if [ "$needupdatechecksum" ]; then
md5sum $needupdatechecksum | sed -e 's| .*/| |' | sort -k 2
else
echo SKIP
fi
}
checkmdsum() {
[ "$CHECK_MDSUM" = 0 ] || [ "$IGNORE_MDSUM" = yes ] && return 0
TMPCHECKSUM=$WORK_DIR/checksumstmp.$$ TMPCHECKSUM=$WORK_DIR/checksumstmp.$$
ORICHECKSUM=$WORK_DIR/checksumsori.$$ ORICHECKSUM=$WORK_DIR/checksumsori.$$
DIFCHECKSUM=$WORK_DIR/checksumsdiff.$$ DIFCHECKSUM=$WORK_DIR/checksumsdiff.$$
if [ ! -f .checksums ]; then if [ ! -f .checksums ]; then
msg "Generating .checksums..." updatemdsum
generatemdsum > .checksums
else else
msg "Checking checksums..." msg "Checking checksums..."
generatemdsum > "$TMPCHECKSUM" generatemdsum > "$TMPCHECKSUM"
@@ -98,9 +111,14 @@ download_src() {
FILENAME=$(basename $FILE) FILENAME=$(basename $FILE)
SRCURL=$FILE SRCURL=$FILE
fi fi
[ "$DOWNLOAD_PROG" = "auto" ] && {
command -v curl >/dev/null && DOWNLOAD_PROG=curl
command -v wget >/dev/null && DOWNLOAD_PROG=wget
}
case $DOWNLOAD_PROG in case $DOWNLOAD_PROG in
curl) DLCMD="curl -C - -L --fail --ftp-pasv --retry 3 --retry-delay 3 -o $SOURCE_DIR/$FILENAME.partial $CURL_OPTS" ;; curl) DLCMD="curl -C - -L --fail --ftp-pasv --retry 3 --retry-delay 3 -o $SOURCE_DIR/$FILENAME.partial $CURL_OPTS" ;;
wget) DLCMD="wget -c --passive-ftp --no-directories --tries=3 --waitretry=3 --output-document=$SOURCE_DIR/$FILENAME.partial $WGET_OPTS" ;; wget) DLCMD="wget -c --passive-ftp --no-directories --tries=3 --waitretry=3 --output-document=$SOURCE_DIR/$FILENAME.partial $WGET_OPTS" ;;
*) msgerr "No download agent found"; abort 1;;
esac esac
if [ "$FILENAME" != "$FILE" ]; then if [ "$FILENAME" != "$FILE" ]; then
if [ ! -f "$SOURCE_DIR/$FILENAME" ] || [ "$REDOWNLOAD_SOURCE" ]; then if [ ! -f "$SOURCE_DIR/$FILENAME" ] || [ "$REDOWNLOAD_SOURCE" ]; then
@@ -129,8 +147,6 @@ download_src() {
} }
prepare_src() { prepare_src() {
[ "$IGNORE_MDSUM" -o "$CHECK_MDSUM" = 0 ] || checkmdsum
SRC=$WORK_DIR/$name/src SRC=$WORK_DIR/$name/src
PKG=$WORK_DIR/$name/pkg PKG=$WORK_DIR/$name/pkg
@@ -155,10 +171,15 @@ prepare_src() {
break break
fi fi
done done
if [ ! -f $FILENAME ]; then
msgerr "File source '$FILENAME' not found."
err=1
continue
fi
if [ "$FILENAME" != "$FILE" ] && [ "$nxt" != 1 ]; then if [ "$FILENAME" != "$FILE" ] && [ "$nxt" != 1 ]; then
case $FILENAME in case $FILENAME in
*.tar|*.tar.gz|*.tar.Z|*.tgz|*.tar.bz2|*.tbz2|*.tar.xz|*.txz|*.tar.lzma|*.zip|*.rpm) *.tar|*.tar.gz|*.tar.Z|*.tgz|*.tar.bz2|*.tbz2|*.tar.xz|*.txz|*.tar.lzma|*.zip|*.rpm)
if [ $(type -p bsdtar) ]; then if [ $(command -v bsdtar) ]; then
COMMAND="bsdtar -p -o -C $SRC -xf $FILENAME" COMMAND="bsdtar -p -o -C $SRC -xf $FILENAME"
else else
COMMAND="tar -p -o -C $SRC -xf $FILENAME" COMMAND="tar -p -o -C $SRC -xf $FILENAME"
@@ -166,7 +187,7 @@ prepare_src() {
MODE="Unpacking" ;; MODE="Unpacking" ;;
*) *)
COMMAND="cp $FILENAME $SRC" COMMAND="cp $FILENAME $SRC"
MODE="Preparing" ;; MODE="Preparing" ;;
esac esac
msg "$MODE '$(basename $FILENAME)'..." msg "$MODE '$(basename $FILENAME)'..."
$COMMAND || { $COMMAND || {
@@ -211,8 +232,30 @@ run_build() {
cd - >/dev/null cd - >/dev/null
} }
pkglint() {
linterror=0
# cant package empty PKG
if [ ! "$(find $PKG/* -maxdepth 1 -type d 2>/dev/null)" ]; then
msgerr "PKG is empty."
abort 1
fi
# check for backup file
for f in $backup; do
if [ ! -f $PKG/$f ]; then
msgerr "Backup file '$f' not exist in PKG!"
linterror=1
fi
done
if [ "$linterror" = 1 ]; then
abort 1
fi
}
removeemptydirs() { removeemptydirs() {
find . -type d -empty -delete find . -type d -empty -delete
} }
removelibtool() { removelibtool() {
@@ -232,20 +275,20 @@ strip_files() {
find . -type f -printf "%P\n" 2>/dev/null | $FILTER | while read -r binary ; do find . -type f -printf "%P\n" 2>/dev/null | $FILTER | while read -r binary ; do
case "$(file -bi "$binary")" in case "$(file -bi "$binary")" in
*application/x-sharedlib*) # Libraries (.so) *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) *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) *application/x-archive*) # Libraries (.a)
strip --strip-debug "$binary" 2>/dev/null ;; ${CROSS_COMPILE}strip --strip-debug "$binary" 2>/dev/null ;;
*application/x-object*) *application/x-object*)
case "$binary" in case "$binary" in
*.ko) # Kernel module *.ko) # Kernel module
strip --strip-unneeded "$binary" 2>/dev/null ;; ${CROSS_COMPILE}strip --strip-unneeded "$binary" 2>/dev/null ;;
*) *)
continue;; continue;;
esac;; esac;;
*application/x-executable*) # Binaries *application/x-executable*) # Binaries
strip --strip-all "$binary" 2>/dev/null ;; ${CROSS_COMPILE}strip --strip-all "$binary" 2>/dev/null ;;
*) *)
continue ;; continue ;;
esac esac
@@ -282,12 +325,7 @@ compressinfomanpages() {
backupconf() { backupconf() {
for FILE in $backup; do for FILE in $backup; do
if [ ! -f $FILE ]; then mv $FILE $FILE.spkgnew
msgerr "File '$FILE' not exist!"
abort 1
else
mv $FILE $FILE.spkgnew
fi
done done
} }
@@ -306,10 +344,14 @@ removelocales() {
usr/share/locale \ usr/share/locale \
usr/locale \ usr/locale \
usr/local/locale \ usr/local/locale \
usr/local/share/locale usr/local/share/locale \
usr/lib/locale
} }
packaging() { packaging() {
# lint $PKG before packaging
pkglint
for FILE in $INCLUDEINPKG; do for FILE in $INCLUDEINPKG; do
if [ -f $FILE ]; then if [ -f $FILE ]; then
install -m644 $FILE $PKG/.pkg$FILE install -m644 $FILE $PKG/.pkg$FILE
@@ -327,9 +369,6 @@ packaging() {
find usr/share/fonts \( -name fonts.dir -o -name fonts.scale \) -delete find usr/share/fonts \( -name fonts.dir -o -name fonts.scale \) -delete
} }
# remove pseudo directories
#rm -fr dev sys proc run tmp
[ "$KEEP_EMPTYDIR" = 0 ] && removeemptydirs [ "$KEEP_EMPTYDIR" = 0 ] && removeemptydirs
[ "$KEEP_LIBTOOL" = 0 ] && removelibtool [ "$KEEP_LIBTOOL" = 0 ] && removelibtool
[ "$STRIP_BINARY" = 1 ] && strip_files [ "$STRIP_BINARY" = 1 ] && strip_files
@@ -374,11 +413,11 @@ generate_pkgfiles() {
excludefile="$excludefile --exclude=.pkg$i" excludefile="$excludefile --exclude=.pkg$i"
done done
msg "Generating .pkgfiles..."
tar -tvf "$PACKAGE_DIR/$PKGNAME" $excludefile \ tar -tvf "$PACKAGE_DIR/$PKGNAME" $excludefile \
| awk '{$3=$4=$5=""; print $0}' \ | awk '{$3=$4=$5=""; print $0}' \
| sed "s,lib/modules/$(uname -r),lib/modules/<kernelversion>,g" \ | sed "s,lib/modules/$(uname -r),lib/modules/<kernelversion>,g" \
| sort -k 3 > .pkgfiles | sort -k 3 > .pkgfiles
msg "Pkgfiles updated."
} }
cleanup() { cleanup() {
@@ -415,7 +454,7 @@ check_buildscript() {
elif [ -z "$release" ]; then elif [ -z "$release" ]; then
msgerr "'release' is empty!" msgerr "'release' is empty!"
exit 1 exit 1
elif [ "$(type -t build)" != "function" ]; then elif [ ! "$(command -v build)" ]; then
msgerr "'build' function not exist!" msgerr "'build' function not exist!"
exit 1 exit 1
elif echo "$version" | grep -q '-'; then elif echo "$version" | grep -q '-'; then
@@ -573,13 +612,13 @@ extract_opts() {
echo $opts echo $opts
} }
main() { main() {
parse_opts $(extract_opts "$@") parse_opts $(extract_opts "$@")
if [ -f "$PKGBUILD_CONF" ]; then if [ -f "$PKGBUILD_CONF" ]; then
. "$PKGBUILD_CONF" . "$PKGBUILD_CONF"
else else
msgerr "Config file not found ('$PKGBUILD_CONF')" msgerr "Config file not found: $PKGBUILD_CONF"
exit 1 exit 1
fi fi
@@ -597,7 +636,7 @@ main() {
if [ -f "$PKGBUILD_BSCRIPT" ]; then if [ -f "$PKGBUILD_BSCRIPT" ]; then
description=$(grep "^# description[[:blank:]]*:" $PKGBUILD_BSCRIPT | sed 's/^# description[[:blank:]]*:[[:blank:]]*//') description=$(grep "^# description[[:blank:]]*:" $PKGBUILD_BSCRIPT | sed 's/^# description[[:blank:]]*:[[:blank:]]*//')
. ./$PKGBUILD_BSCRIPT . ./$PKGBUILD_BSCRIPT
else else
msgerr "'$PKGBUILD_BSCRIPT' file not found." msgerr "'$PKGBUILD_BSCRIPT' file not found."
exit 1 exit 1
@@ -625,14 +664,12 @@ main() {
# extract source only # extract source only
[ "$EXTRACT_ONLY" ] && { [ "$EXTRACT_ONLY" ] && {
download_src
prepare_src prepare_src
exit 0 exit 0
} }
# update md5sum # update md5sum
[ "$UPDATE_MDSUM" ] && { [ "$UPDATE_MDSUM" ] && {
download_src
updatemdsum updatemdsum
exit 0 exit 0
} }
@@ -667,6 +704,7 @@ main() {
else else
msg "Building '$name-$version-$release'..." msg "Building '$name-$version-$release'..."
download_src download_src
checkmdsum
prepare_src prepare_src
run_build run_build
packaging packaging
@@ -691,7 +729,7 @@ PKGBUILD_BSCRIPT="spkgbuild"
SOURCE_DIR="/var/cache/scratchpkg/sources" SOURCE_DIR="/var/cache/scratchpkg/sources"
PACKAGE_DIR="/var/cache/scratchpkg/packages" PACKAGE_DIR="/var/cache/scratchpkg/packages"
WORK_DIR="/var/cache/scratchpkg/work" WORK_DIR="/var/cache/scratchpkg/work"
DOWNLOAD_PROG="wget" DOWNLOAD_PROG="auto"
COMPRESSION_MODE="xz" COMPRESSION_MODE="xz"
OPTIONS="!libtool emptydirs strip zipman buildflags makeflags checksum !docs !locales" OPTIONS="!libtool emptydirs strip zipman buildflags makeflags checksum !docs !locales"

38
pkgdel
View File

@@ -36,11 +36,11 @@ msg2() {
} }
msgerr() { msgerr() {
echo "==> ERROR: $1" echo "==> ERROR: $1" >&2
} }
msgwarn() { msgwarn() {
echo "==> WARNING: $1" echo "==> WARNING: $1" >&2
} }
help() { help() {
@@ -100,7 +100,7 @@ ret() {
} }
isinstalled() { isinstalled() {
if [ -s "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo" ] && grep -q "$1" "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo"; then if [ -s "$ROOT_DIR/$PKGDB_DIR/$1/.pkginfo" ] && grep -q "$1" "$ROOT_DIR/$PKGDB_DIR/$1/.pkginfo"; then
return 0 return 0
else else
return 1 return 1
@@ -115,9 +115,15 @@ run_scripts() {
fi fi
} }
command -v pkgadd >/dev/null 2>&1 || {
msgerr "'pkgadd' not found in \$PATH!"
exit 1
}
parse_opts $(extract_opts "$@") parse_opts $(extract_opts "$@")
INDEX_DIR="var/lib/scratchpkg/index" PKGDB_DIR="$(pkgadd --print-dbdir)"
PKGDB_DIR="${PKGDB_DIR##/}" # remove leading /
LOCK_FILE="var/lib/scratchpkg/spkg.lock" LOCK_FILE="var/lib/scratchpkg/spkg.lock"
# show help page # show help page
@@ -149,9 +155,9 @@ if ! isinstalled "$RMNAME"; then
ret 1 ret 1
fi fi
name=$(grep ^name $ROOT_DIR/$INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-) name=$(grep ^name $ROOT_DIR/$PKGDB_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
version=$(grep ^version $ROOT_DIR/$INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-) version=$(grep ^version $ROOT_DIR/$PKGDB_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
release=$(grep ^release $ROOT_DIR/$INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-) release=$(grep ^release $ROOT_DIR/$PKGDB_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
if [ -z "$name" ] && [ -z "$version" ] && [ -z "$release" ]; then if [ -z "$name" ] && [ -z "$version" ] && [ -z "$release" ]; then
msgerr "Package '$RMNAME' not installed but exist in database." msgerr "Package '$RMNAME' not installed but exist in database."
@@ -164,21 +170,21 @@ remove="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_remove"
dirs="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_dirs" dirs="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_dirs"
files="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_files" files="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_files"
grep '/$' $ROOT_DIR/$INDEX_DIR/*/.files \ grep '/$' $ROOT_DIR/$PKGDB_DIR/*/.files \
| grep -v "$ROOT_DIR/$INDEX_DIR/$name" \ | grep -v "$ROOT_DIR/$PKGDB_DIR/$name" \
| awk -F : '{print $2}' \ | awk -F : '{print $2}' \
| sort \ | sort \
| uniq > "$reserve" | uniq > "$reserve"
grep '/$' "$ROOT_DIR/$INDEX_DIR/$name/.files" > "$remove" grep '/$' "$ROOT_DIR/$PKGDB_DIR/$name/.files" > "$remove"
grep -Fxv -f "$reserve" "$remove" | tac > "$dirs" grep -Fxv -f "$reserve" "$remove" | tac > "$dirs"
grep -v '/$' "$ROOT_DIR/$INDEX_DIR/$name/.files" | tac >> "$files" grep -v '/$' "$ROOT_DIR/$PKGDB_DIR/$name/.files" | tac >> "$files"
echo "remove: $name-$version-$release..." echo "remove: $name-$version-$release..."
# pre-remove script # pre-remove script
if [ ! "$NO_PREREMOVE" ] && [ -f "$ROOT_DIR/$INDEX_DIR/$name/.pkginstall" ]; then if [ ! "$NO_PREREMOVE" ] && [ -f "$ROOT_DIR/$PKGDB_DIR/$name/.pkginstall" ]; then
(cd "$ROOT_DIR"/ (cd "$ROOT_DIR"/
run_scripts "$INDEX_DIR/$name/.pkginstall" pre-remove "$version" run_scripts "$PKGDB_DIR/$name/.pkginstall" pre-remove "$version"
) )
fi fi
@@ -191,14 +197,14 @@ fi
rm -f "$reserve" "$dirs" "$remove" "$files" rm -f "$reserve" "$dirs" "$remove" "$files"
# post-remove script # post-remove script
if [ ! "$NO_POSTREMOVE" ] && [ -f "$ROOT_DIR/$INDEX_DIR/$name/.pkginstall" ]; then if [ ! "$NO_POSTREMOVE" ] && [ -f "$ROOT_DIR/$PKGDB_DIR/$name/.pkginstall" ]; then
(cd "$ROOT_DIR"/ (cd "$ROOT_DIR"/
run_scripts "$INDEX_DIR/$name/.pkginstall" post-remove "$version" run_scripts "$PKGDB_DIR/$name/.pkginstall" post-remove "$version"
) )
fi fi
# remove from database # remove from database
rm -rf "$ROOT_DIR/$INDEX_DIR/$name" rm -rf "$ROOT_DIR/$PKGDB_DIR/$name"
# running ldconfig # running ldconfig
if [ -x "$ROOT_DIR"/sbin/ldconfig ]; then if [ -x "$ROOT_DIR"/sbin/ldconfig ]; then

72
pkgdepends Executable file
View File

@@ -0,0 +1,72 @@
#!/bin/sh
#
# 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 <https://www.gnu.org/licenses/>.
#
#
# script to check shared libraries dependencies
#
get_libpath() {
ldd $1 2>/dev/null | grep $2 | awk '{print $3}'
}
scratch files $1 | while read -r line; do
case $line in
usr/share/gir-1.0/*.gir) extra_dep="$extra_dep gobject-introspection";;
usr/share/vala/vapi/*.vapi) extra_dep="$extra_dep vala";;
esac
case $line in
*/) continue;;
esac
case "$(file -bi /$line)" in
*application/x-sharedlib* | *application/x-executable* | *application/x-pie-executable*)
for NEEDED in $(objdump -x /$line | grep NEEDED | awk '{print $2}'); do
case $NEEDED in
libc.so|libc.so.6) continue;;
esac
[ "$NEEDED" ] || continue
[ -f /"$line" ] || continue
libs=$(get_libpath /$line $NEEDED)
[ "$libs" ] || continue
if ! echo $all_libs | grep -qw $libs; then
pkg=$(scratch provide $libs$ | awk '{print $1}' | head -n1)
case $pkg in
$1|gcc|glibc|musl) continue;;
esac
[ "$pkg" ] || continue
if ! echo $all_pkgs | grep -qw $pkg; then
echo $pkg
all_pkgs="$all_pkgs $pkg"
unset pkg
fi
all_libs="$all_libs $libs"
unset libs
fi
done ;;
esac
[ "$extra_dep" ] && {
for e in $extra_dep; do
if ! echo $all_pkgs | grep -qw $e; then
echo $e
all_pkgs="$all_pkgs $e"
fi
done
}
done
exit 0

141
pkgfix Executable file
View File

@@ -0,0 +1,141 @@
#!/bin/sh
#
# Copyright (c) 2019 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 <https://www.gnu.org/licenses/>.
#
#
# script to detect broken kernel modules after kernel update
# need to use with 'scratchpkg'
#
export LANG=C
get_perlmodules() {
command -v perl >/dev/null || return
perlpath=$(dirname $(perl -V:sitearch | grep -o "'.*'" | sed "s/'//g"))
for i in $(dirname $perlpath)/*; do
[ "$perlpath" = "$i" ] && continue
brokenpkg="$brokenpkg $(scratch provide $i/$ | awk '{print $1}')"
done
}
get_modules() {
[ -f /lib/modules/KERNELVERSION ] || return
KERVER=$(cat /lib/modules/KERNELVERSION)
for i in /lib/modules/*; do
case $i in
/lib/modules/KERNELVERSION|/lib/modules/$KERVER) continue ;;
esac
brokenpkg="$brokenpkg $(scratch provide $i/$ | awk '{print $1}')"
done
}
get_rubygem() {
command -v gem >/dev/null || return
gempath=$(gem env gemdir)
for i in $(dirname $gempath)/*; do
[ "$gempath" = "$i" ] && continue
brokenpkg="$brokenpkg $(scratch provide $i/$ | awk '{print $1}')"
done
}
sort_modules() {
for all in $(scratch deplist $brokenpkg | cut -d ' ' -f2); do
for r in $brokenpkg; do
if [ $r = $all ]; then
if [ -z "$order" ]; then
order="$all"
else
order="$order $all"
fi
break
fi
done
done
}
confirm() {
printf "$1 (Y/n) "
read -r response
case "$response" in
[Nn][Oo]|[Nn]) echo "$2"; return 2 ;;
*) : ;;
esac
return 0
}
usage() {
cat << EOF
Usage:
$(basename $0) [options]
Options:
-r rebuild & reinstall broken package
-y dont ask user confirmation to rebuild package (use with -r)
-h print this help message
EOF
}
parse_opt() {
while [ "$1" ]; do
case $1 in
-r) REBUILD=1 ;;
-y) YES=1 ;;
-h) usage; exit 0 ;;
*) echo "Invalid option ($1)"; exit 1 ;;
esac
shift
done
}
parse_opt $@
if [ "$REBUILD" ] && [ "$(id -u)" != 0 ]; then
echo "Rebuild broken packages required root!"
exit 1
fi
get_modules
get_perlmodules
get_rubygem
if [ "$brokenpkg" ]; then
sort_modules
else
echo "No broken packages found."
exit 0
fi
if [ "$REBUILD" = 1 ]; then
[ "$YES" ] || {
echo
echo "Package will be rebuild & reinstall by this order:"
echo " $order"
echo
confirm "Continue rebuild & reinstall broken packages?" "Operation cancelled."
}
for p in $order; do
scratch build -f $p || exit 1
scratch install -r $p || exit 1
done
else
echo "Broken packages:"
for p in $order; do
echo " $p"
done
fi
exit 0

340
pkgquery
View File

@@ -18,342 +18,6 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# #
msg() { echo "*** ${0##*/} is deprecated, please use 'scratch' instead ***"
echo "==> $1"
}
msgerr() { exit 0
msg "ERROR: $*"
}
msgwarn() {
msg "WARNING: $*"
}
msginst() {
echo "[i] $1"
}
msgmiss() {
echo "[m] $1"
}
msgnoinst() {
echo "[-] $1"
}
needarg() {
[ "$*" ] || {
msgerr "This operation required an arguments!"
exit 1
}
}
isinstalled() {
if [ -s "$INDEX_DIR/$1/.pkginfo" ] && [ "$(grep $1 $INDEX_DIR/$1/.pkginfo)" ]; then
return 0
else
return 1
fi
}
allinstalled() {
grep ^name "$INDEX_DIR"/*/.pkginfo | awk '{print $3}'
}
installed_pkg_info() {
if isinstalled $1; then
grep ^$2 "$INDEX_DIR/$1/.pkginfo" | cut -d " " -f3-
fi
}
deps_alias() {
[ -f $ALIAS_FILE ] || {
echo $@
return
}
while [ "$1" ]; do
getalias=$(grep -w ^$1 $ALIAS_FILE | awk '{print $2}')
echo ${getalias:-$1}
shift
done
unset getalias
}
getdepends() {
ppath=$(getportpath $1) || return 0
deps=$(grep "^# depends[[:blank:]]*:" $ppath/$BUILD_SCRIPT \
| sed 's/^# depends[[:blank:]]*:[[:blank:]]*//' \
| tr ' ' '\n' \
| awk '!a[$0]++' \
| sed 's/,//')
deps_alias $deps
}
getportpath() {
for repo in $REPO; do
if [ -f $repo/$1/$BUILD_SCRIPT ]; then
dirname $repo/$1/$BUILD_SCRIPT
return 0
fi
done
return 1
}
pkg_dependent() {
needarg $@
if [ "$(getportpath $1)" ]; then
grep -R "# depends[[:blank:]]*:" $REPO \
| sed "s,:# depends[[:blank:]]*:[[:blank:]]*,#|,;s, ,|,g;s,$,|,g" \
| grep "|$1|" \
| awk -F "#" '{print $1}' \
| rev \
| awk -F / '{print $2}' \
| rev
else
msgerr "Port '$1' not exist."
return 1
fi
}
pkg_orphan() {
tmpallpkg="/tmp/.pkgquery_allpkg.$$"
tmpalldep="/tmp/.pkgquery_alldep.$$"
for pkg in $(allinstalled); do
echo $pkg >> $tmpallpkg
dep="$dep $(getdepends $pkg)"
done
echo $dep | tr ' ' '\n' | sort | uniq > "$tmpalldep"
grep -xvF -f "$tmpalldep" "$tmpallpkg"
rm "$tmpalldep" "$tmpallpkg"
}
pkg_dup() {
dup=$(find $REPO -type d -print | grep -Exv "($(echo $REPO | tr ' ' '|'))" | \
rev | cut -d '/' -f1 | rev | sort | uniq -d)
if [ "$dup" ]; then
for dp in $dup; do
for repo in $REPO; do
[ -d $repo/$dp ] && echo "$repo/$dp"
done
done
else
msg "No duplicate ports found."
fi
}
pkg_foreign() {
for pkg in $(allinstalled); do
if ! getportpath $pkg >/dev/null; then
iname=$(installed_pkg_info $pkg name)
iversion=$(installed_pkg_info $pkg version)
irelease=$(installed_pkg_info $pkg release)
echo "$iname $iversion-$irelease"
fi
unset iname iversion irelease
done
}
pkg_search() {
needarg $@
arg=$*
for repo in $REPO; do
out=$(grep -R "# description" $repo | grep $BUILD_SCRIPT | grep "$arg" | awk -F : '{print $1}' | sort)
[ "$out" ] || continue
for line in $out; do
repo=$(echo $line | rev | awk -F / '{print $3}' | rev)
desc=$(grep "^# description[[:blank:]]*:" $line | sed 's/^# description[[:blank:]]*:[[:blank:]]*//')
. $line
echo "($repo) $name $version-$release: $desc"
unset repo desc name version release build
done
unset out
done
}
pkg_locked() {
for pkg in $(allinstalled); do
[ -f "$INDEX_DIR/$pkg/.lock" ] && echo "$pkg"
done
}
pkg_installed() {
for all in $(allinstalled); do
printf "%s" "$all "
grep -e ^version -e ^release $INDEX_DIR/$all/.pkginfo | awk '{print $3}' | tr '\n' '-' | sed 's:\-$::'
echo
done
}
pkg_missingdep() {
for pkg in $(allinstalled); do
if getportpath "$pkg" >/dev/null; then
depends=$(getdepends $pkg)
fi
if [ "$depends" ]; then
for d in $depends; do
if ! isinstalled $d; then
if [ -z "$msd" ]; then
msd="$d"
else
msd="$msd $d"
fi
fi
done
fi
[ "$msd" ] && echo "$pkg: $msd"
unset depends msd
done
}
pkg_info() {
needarg $@
ppath=$(getportpath $1) || return 1
. $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=$(getdepends $1 | tr '\n' ' ')
echo "Name: $1"
echo "Path: $ppath"
echo "Version: $version"
echo "Release: $release"
echo "Description: $desc"
echo "Homepage: $url"
echo "Maintainer: $maint"
echo "Dependencies: $deps"
}
pkg_depends() {
needarg $@
if getportpath "$1" >/dev/null; then
depends=$(getdepends $1)
else
msgerr "Port '$1' not exist."
return 1
fi
for dep in $depends; do
if isinstalled $dep; then
msginst "$dep"
elif getportpath $dep >/dev/null; then
msgnoinst "$dep"
else
msgmiss "$dep"
fi
done
}
pkg_path() {
needarg $@
if PPATH=$(getportpath "$1"); then
echo "$PPATH"
else
msgerr "Port '$1' not exist."
return 1
fi
}
pkg_provide() {
needarg $@
arg=$(echo $1 | sed "s/^\///")
grep -R "$arg" $INDEX_DIR/*/.files \
| sed "s:$INDEX_DIR/::" \
| sed "s:/.files::" \
| tr : " " \
| column -t
}
pkg_readme() {
needarg $@
if PPATH=$(getportpath "$1"); then
if [ -f "$PPATH/readme" ]; then
cat "$PPATH/readme"
else
msgerr "Port '$1' does not have readme."
fi
else
msgerr "Port '$1' not exist."
exit 1
fi
}
pkg_files() {
needarg $@
if isinstalled $1; then
cat "$INDEX_DIR/$1/.files"
else
msg "Package '$1' not installed."
fi
}
pkg_cat() {
needarg $@
if PPATH=$(getportpath "$1"); then
cat "$PPATH/$BUILD_SCRIPT"
else
msgerr "Port '$1' not exist."
return 1
fi
}
pkg_help() {
cat << EOF
Usage:
$(basename $0) <options> [<arg>]
Options:
search <pattern> find ports in repo
cat <port> print spkgbuild
depends <port> print dependencies
dependent <port> print dependent
path <port> print path in repo
provide <files> print port's provided files
readme <port> print readme file, if exist
files <port> print files installed
info <port> print information
dup print duplicate ports in repo
installed print all installed ports
locked print loacked ports
missingdep print missing dependencies
orphan print orphan installed ports
foreign print foreign ports
help print this help msg
EOF
}
print_runhelp_msg() {
echo "Run '$(basename $0) help' to see available options."
exit 2
}
BUILD_SCRIPT="spkgbuild"
INDEX_DIR="/var/lib/scratchpkg/index"
REPO_FILE="/etc/scratchpkg.repo"
ALIAS_FILE="/etc/scratchpkg.alias"
if [ -f "$REPO_FILE" ]; then
for repodir in $(grep -Ev '^(#|$)' "$REPO_FILE" | awk '{print $1}'); do
REPO="$REPO $repodir"
done
fi
opts=$1
if [ -z "$opts" ]; then
print_runhelp_msg
fi
shift
if [ $(type -t pkg_$opts) ]; then
pkg_$opts "$@"
else
print_runhelp_msg
fi
exit $?

51
pkgrebuild Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/sh
#
# 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 <https://www.gnu.org/licenses/>.
#
#
# script to rebuild base packages in right toolchain order
#
LIST="/tmp/$(basename $0)-list"
touch $LIST
TOOLCHAIN="linux-api-headers glibc-pass1 binutils-pass1 gcc binutils glibc"
#scratch sync || exit 1
for tc in $TOOLCHAIN; do
if [ ! $(grep -x $tc $LIST) ]; then
pkgname="$(echo $tc | sed 's/-pass1//')"
scratch build -f $pkgname || exit 1
echo $tc >> $LIST
scratch install -r $pkgname --no-backup || exit 1
fi
done
for pkg in $(scratch deplist base | awk '{print $2}'); do
case $pkg in
linux-api-headers|musl|gcc|binutils|glibc) continue;;
esac
if [ ! $(grep -x $pkg $LIST) ]; then
scratch build -f $pkg || exit 1
echo $pkg >> $LIST
scratch install -r $pkg --no-backup || exit 1
fi
done
exit 0

46
portcreate Executable file
View File

@@ -0,0 +1,46 @@
#!/bin/sh
#
# 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 <https://www.gnu.org/licenses/>.
#
if [ -d "$1" ]; then
echo "ERROR: Directory '$1' already exist!"
exit 1
else
mkdir "$1"
echo "# description :
# depends :
name=$1
version=
release=1
options=\"\"
noextract=\"\"
backup=\"\"
source=\"\"
build() {
cd \$name-\$version
./configure --prefix=/usr
make
make DESTDIR=\$PKG install
}" > "$1"/spkgbuild
echo "Template port have created for '$1'."
fi
exit 0

16
revdep
View File

@@ -114,7 +114,8 @@ rebuild() {
confirm "Continue rebuild & reinstall broken packages?" "Operation cancelled." confirm "Continue rebuild & reinstall broken packages?" "Operation cancelled."
fi fi
for p in $order; do for p in $order; do
scratch build -f $p && scratch install -r $p || { cleanup; exit 1; } scratch build -f $p || { cleanup; exit 1; }
scratch install -r $p || { cleanup; exit 1; }
done done
fi fi
} }
@@ -163,8 +164,13 @@ rev_exclude() {
trap "interrupted" 1 2 3 15 trap "interrupted" 1 2 3 15
command -v pkgadd >/dev/null 2>&1 || {
echo "'pkgadd' not found in \$PATH!"
exit 1
}
# package database directory # package database directory
INDEX_DIR="/var/lib/scratchpkg/index" PKGDB_DIR="$(pkgadd --print-dbdir)"
SEARCH_DIRS="/bin /usr/bin /sbin /usr/sbin /lib /usr/lib /lib64 /usr/lib64 /usr/libexec" SEARCH_DIRS="/bin /usr/bin /sbin /usr/sbin /lib /usr/lib /lib64 /usr/lib64 /usr/libexec"
parse_opt $(extract_opts "$@") parse_opt $(extract_opts "$@")
@@ -174,7 +180,7 @@ if [ "$(id -u)" != 0 ] && [ "$REBUILD" = 1 ]; then
exit 1 exit 1
fi fi
if [ "$PKG" ] && [ ! -f "$INDEX_DIR/$PKG/.files" ]; then if [ "$PKG" ] && [ ! -f "$PKGDB_DIR/$PKG/.files" ]; then
echo "ERROR: Package '$PKG' not installed" echo "ERROR: Package '$PKG' not installed"
cleanup cleanup
exit 1 exit 1
@@ -249,7 +255,7 @@ if [ "$PKG" ]; then
filterdir=cat filterdir=cat
fi fi
printf "Find '$PKG' files... " printf "Find '$PKG' files... "
sed 's/^/\//' $INDEX_DIR/$PKG/.files | grep $gx | $filterfile | $filterdir > $FILE_LIST sed 's/^/\//' $PKGDB_DIR/$PKG/.files | grep $gx | $filterfile | $filterdir > $FILE_LIST
else else
printf "Find all files... " printf "Find all files... "
find $SEARCH_DIRS $EXCLUDED_DIRS $EXCLUDED_FILES -type f \( -perm /+u+x -o -name '*.so' -o -name '*.so.*' \) -print 2> /dev/null | sort -u > $FILE_LIST find $SEARCH_DIRS $EXCLUDED_DIRS $EXCLUDED_FILES -type f \( -perm /+u+x -o -name '*.so' -o -name '*.so.*' \) -print 2> /dev/null | sort -u > $FILE_LIST
@@ -278,7 +284,7 @@ while read -r line; do
LIB_NAME=$NEW_LIB_NAME LIB_NAME=$NEW_LIB_NAME
[ "$LIB_NAME" ] || continue [ "$LIB_NAME" ] || continue
PKG_NAME=$(echo $line | sed 's#^/##') PKG_NAME=$(echo $line | sed 's#^/##')
PKG_NAME=$(grep -Rx $PKG_NAME "$INDEX_DIR"/*/.files | cut -d : -f1) PKG_NAME=$(grep -Rx $PKG_NAME "$PKGDB_DIR"/*/.files | cut -d : -f1)
[ "$PKG_NAME" ] || continue [ "$PKG_NAME" ] || continue
PKG_NAME=$(dirname $PKG_NAME) PKG_NAME=$(dirname $PKG_NAME)
PKG_NAME=$(basename $PKG_NAME) PKG_NAME=$(basename $PKG_NAME)

515
scratch
View File

@@ -35,27 +35,27 @@ nocolor() {
} }
msg() { msg() {
printf "${GREEN}==>${CRESET} $1\n" printf "${GREEN}==>${CRESET} %s\n" "$1"
}
msgerr() {
printf "${RED}==> ERROR:${CRESET} $1\n"
} }
msginst() { msginst() {
printf "[${GREEN}i${CRESET}] $1\n" printf "[${GREEN}i${CRESET}] %s\n" "$1"
} }
msgmiss() { msgmiss() {
printf "[${YELLOW}m${CRESET}] $1\n" printf "[${YELLOW}m${CRESET}] %s\n" "$1"
} }
msgnoinst() { msgnoinst() {
printf "[-] $1\n" printf "[-] %s\n" "$1"
}
msgerr() {
printf "${RED}==> ERROR:${CRESET} %s\n" "$1" >&2
} }
msgwarn() { msgwarn() {
printf "${YELLOW}==> WARNING:${CRESET} $1\n" printf "${YELLOW}==> WARNING:${CRESET} %s\n" "$1" >&2
} }
needroot() { needroot() {
@@ -91,25 +91,29 @@ vercomp() {
installed_pkg_info() { installed_pkg_info() {
if isinstalled $2; then if isinstalled $2; then
grep ^$1 $INDEX_DIR/$2/.pkginfo | cut -d " " -f3- grep ^$1 $PKGDB_DIR/$2/.pkginfo 2>/dev/null | cut -d " " -f3-
fi fi
} }
allinstalled() { allinstalled() {
grep ^name "$INDEX_DIR"/*/.pkginfo | awk '{print $3}' grep ^name "$PKGDB_DIR"/*/.pkginfo 2>/dev/null | awk '{print $3}'
} }
deps_alias() { deps_alias() {
[ -f $ALIAS_FILE ] || { [ -f "$ALIAS_FILE" ] || {
echo $@ echo $@
return return
} }
while [ "$1" ]; do while [ "$1" ]; do
getalias=$(grep -w ^$1 $ALIAS_FILE | awk '{print $2}') if [ "$(grep -w ^$1 $ALIAS_FILE)" ]; then
echo ${getalias:-$1} getalias=$(grep -w ^$1 $ALIAS_FILE | awk '{print $2}')
[ "$getalias" ] && echo "$getalias"
else
echo "$1"
fi
shift shift
unset getalias
done done
unset getalias
} }
get_depends() { get_depends() {
@@ -133,7 +137,7 @@ confirm() {
} }
checktool() { checktool() {
if ! type -p $1 >/dev/null; then if ! command -v $1 >/dev/null; then
msgerr "'$1' not exist in your system!" msgerr "'$1' not exist in your system!"
exit 1 exit 1
fi fi
@@ -147,7 +151,7 @@ needarg() {
} }
isinstalled() { isinstalled() {
if [ -s "$INDEX_DIR/$1/.pkginfo" ] && [ "$(grep $1 $INDEX_DIR/$1/.pkginfo)" ]; then if [ -s "$PKGDB_DIR/$1/.pkginfo" ] && [ "$(grep $1 $PKGDB_DIR/$1/.pkginfo)" ]; then
return 0 return 0
else else
return 1 return 1
@@ -161,8 +165,8 @@ settermtitle() {
scratch_integrity() { scratch_integrity() {
if [ "$1" ]; then if [ "$1" ]; then
cd / cd /
if [ -f $INDEX_DIR/$1/.files ]; then if [ -f $PKGDB_DIR/$1/.files ]; then
cat $INDEX_DIR/$1/.files | while read -r line; do cat $PKGDB_DIR/$1/.files | while read -r line; do
if [ ! -e "$line" ]; then if [ ! -e "$line" ]; then
if [ -L "$line" ]; then if [ -L "$line" ]; then
printf "${YELLOW}broken symlink${CRESET} $1: /$line" printf "${YELLOW}broken symlink${CRESET} $1: /$line"
@@ -179,7 +183,7 @@ scratch_integrity() {
else else
cd / cd /
for pkg in $(allinstalled); do for pkg in $(allinstalled); do
cat $INDEX_DIR/$pkg/.files | while read -r line; do cat $PKGDB_DIR/$pkg/.files | while read -r line; do
if [ ! -e "$line" ]; then if [ ! -e "$line" ]; then
if [ -L "$line" ]; then if [ -L "$line" ]; then
echo "broken symlink $pkg: /$line" echo "broken symlink $pkg: /$line"
@@ -198,23 +202,30 @@ scratch_lock() {
for pkg in "$@"; do for pkg in "$@"; do
if ! isinstalled $pkg; then if ! isinstalled $pkg; then
msgerr "Package '$pkg' is not installed." msgerr "Package '$pkg' is not installed."
elif [ -f $INDEX_DIR/$pkg/.lock ]; then elif [ -f $PKGDB_DIR/$pkg/.lock ]; then
msgerr "Package '$pkg' already locked." msgerr "Package '$pkg' already locked."
else else
touch $INDEX_DIR/$pkg/.lock && msg "Successfully locked package '$pkg'." touch $PKGDB_DIR/$pkg/.lock && msg "Successfully locked package '$pkg'."
fi fi
done done
} }
scratch_locate() {
needarg $@
for repo in $PORT_REPO; do
grep -R $@ $repo/*/.pkgfiles 2>/dev/null | sed 's/:/ /;s/\/\.pkgfiles//' | awk '{print $1,$4}' | column -t
done
}
scratch_unlock() { scratch_unlock() {
needroot "Unlocking package" needroot "Unlocking package"
for pkg in "$@"; do for pkg in "$@"; do
if ! isinstalled $pkg; then if ! isinstalled $pkg; then
msgerr "Package '$pkg' is not installed." msgerr "Package '$pkg' is not installed."
elif [ ! -f $INDEX_DIR/$pkg/.lock ]; then elif [ ! -f $PKGDB_DIR/$pkg/.lock ]; then
msgerr "Package '$pkg' is not locked." msgerr "Package '$pkg' is not locked."
else else
rm -f $INDEX_DIR/$pkg/.lock && msg "Successfully unlocked package '$pkg'." rm -f $PKGDB_DIR/$pkg/.lock && msg "Successfully unlocked package '$pkg'."
fi fi
done done
} }
@@ -268,7 +279,7 @@ scratch_trigger() {
post_triggers() { post_triggers() {
if [ "$trig_12" = 1 ]; then if [ "$trig_12" = 1 ]; then
echo "trigger: Running mkdirs..." echo "trigger: Running mkdirs..."
for mkd in $INDEX_DIR/*/.pkgmkdirs; do for mkd in $PKGDB_DIR/*/.pkgmkdirs; do
[ -s $mkd ] || continue [ -s $mkd ] || continue
grep -Ev '^(#|$)' $mkd | while read -r dir mode uid gid junk; do grep -Ev '^(#|$)' $mkd | while read -r dir mode uid gid junk; do
if [ -e "$dir" ]; then if [ -e "$dir" ]; then
@@ -286,37 +297,37 @@ post_triggers() {
done done
fi fi
if [ "$trig_11" = 1 ] && [ $(type -p fc-cache) ]; then if [ "$trig_11" = 1 ] && [ $(command -v fc-cache) ]; then
echo "trigger: Updating fontconfig cache..." echo "trigger: Updating fontconfig cache..."
fc-cache -s fc-cache -s
fi fi
if [ "$trig_10" = 1 ] && [ $(type -p gdk-pixbuf-query-loaders) ]; then if [ "$trig_10" = 1 ] && [ $(command -v gdk-pixbuf-query-loaders) ]; then
echo "trigger: Probing GDK-Pixbuf loader modules..." echo "trigger: Probing GDK-Pixbuf loader modules..."
gdk-pixbuf-query-loaders --update-cache gdk-pixbuf-query-loaders --update-cache
fi fi
if [ "$trig_9" = 1 ] && [ $(type -p gio-querymodules) ]; then if [ "$trig_9" = 1 ] && [ $(command -v gio-querymodules) ]; then
echo "trigger: Updating GIO module cache..." echo "trigger: Updating GIO module cache..."
gio-querymodules /usr/lib/gio/modules gio-querymodules /usr/lib/gio/modules
fi fi
if [ "$trig_8" = 1 ] && [ $(type -p glib-compile-schemas) ]; then if [ "$trig_8" = 1 ] && [ $(command -v glib-compile-schemas) ]; then
echo "trigger: Compiling GSettings XML schema files..." echo "trigger: Compiling GSettings XML schema files..."
glib-compile-schemas /usr/share/glib-2.0/schemas glib-compile-schemas /usr/share/glib-2.0/schemas
fi fi
if [ "$trig_7" = 1 ] && [ $(type -p gtk-query-immodules-2.0) ]; then if [ "$trig_7" = 1 ] && [ $(command -v gtk-query-immodules-2.0) ]; then
echo "trigger: Probing GTK2 input method modules..." echo "trigger: Probing GTK2 input method modules..."
gtk-query-immodules-2.0 --update-cache gtk-query-immodules-2.0 --update-cache
fi fi
if [ "$trig_6" = 1 ] && [ $(type -p gtk-query-immodules-3.0) ]; then if [ "$trig_6" = 1 ] && [ $(command -v gtk-query-immodules-3.0) ]; then
echo "trigger: Probing GTK3 input method modules..." echo "trigger: Probing GTK3 input method modules..."
gtk-query-immodules-3.0 --update-cache gtk-query-immodules-3.0 --update-cache
fi fi
if [ "$trig_5" = 1 ] && [ $(type -p gtk-update-icon-cache) ]; then if [ "$trig_5" = 1 ] && [ $(command -v gtk-update-icon-cache) ]; then
echo "trigger: Updating icon theme caches..." echo "trigger: Updating icon theme caches..."
for dir in /usr/share/icons/* ; do for dir in /usr/share/icons/* ; do
if [ -e $dir/index.theme ]; then if [ -e $dir/index.theme ]; then
@@ -328,12 +339,12 @@ post_triggers() {
done done
fi fi
if [ "$trig_4" = 1 ] && [ $(type -p udevadm) ]; then if [ "$trig_4" = 1 ] && [ $(command -v udevadm) ]; then
echo "trigger: Updating hardware database..." echo "trigger: Updating hardware database..."
udevadm hwdb --update udevadm hwdb --update
fi fi
if [ "$trig_3" = 1 ] && [ $(type -p mkfontdir) ] && [ $(type -p mkfontscale) ]; then if [ "$trig_3" = 1 ] && [ $(command -v mkfontdir) ] && [ $(command -v mkfontscale) ]; then
echo "trigger: Updating X fontdir indices..." echo "trigger: Updating X fontdir indices..."
for dir in $(find /usr/share/fonts -maxdepth 1 -type d \( ! -path /usr/share/fonts -a ! -name X11 \)) /usr/share/fonts/X11/*; do for dir in $(find /usr/share/fonts -maxdepth 1 -type d \( ! -path /usr/share/fonts -a ! -name X11 \)) /usr/share/fonts/X11/*; do
rm -f $dir/fonts.scale $dir/fonts.dir $dir/.uuid rm -f $dir/fonts.scale $dir/fonts.dir $dir/.uuid
@@ -344,12 +355,12 @@ post_triggers() {
done done
fi fi
if [ "$trig_2" = 1 ] && [ $(type -p update-desktop-database) ]; then if [ "$trig_2" = 1 ] && [ $(command -v update-desktop-database) ]; then
echo "trigger: Updating desktop file MIME type cache..." echo "trigger: Updating desktop file MIME type cache..."
update-desktop-database --quiet update-desktop-database --quiet
fi fi
if [ "$trig_1" = 1 ] && [ $(type -p update-mime-database) ]; then if [ "$trig_1" = 1 ] && [ $(command -v update-mime-database) ]; then
echo "trigger: Updating the MIME type database..." echo "trigger: Updating the MIME type database..."
update-mime-database /usr/share/mime update-mime-database /usr/share/mime
fi fi
@@ -359,7 +370,7 @@ pre_triggers() {
# mime db # mime db
if [ "$trig_1" != "1" ]; then if [ "$trig_1" != "1" ]; then
for pkg in $@; do for pkg in $@; do
if [ -s "$INDEX_DIR/$pkg/.files" ] && [ "$(grep ^usr/share/mime/$ $INDEX_DIR/$pkg/.files)" ]; then if [ -s "$PKGDB_DIR/$pkg/.files" ] && [ "$(grep ^usr/share/mime/$ $PKGDB_DIR/$pkg/.files)" ]; then
trig_1=1 trig_1=1
break break
fi fi
@@ -369,7 +380,7 @@ pre_triggers() {
# desktop db # desktop db
if [ "$trig_2" != "1" ]; then if [ "$trig_2" != "1" ]; then
for pkg in $@; do for pkg in $@; do
if [ -s "$INDEX_DIR/$pkg/.files" ] && [ "$(grep ^usr/share/applications/$ $INDEX_DIR/$pkg/.files)" ]; then if [ -s "$PKGDB_DIR/$pkg/.files" ] && [ "$(grep ^usr/share/applications/$ $PKGDB_DIR/$pkg/.files)" ]; then
trig_2=1 trig_2=1
break break
fi fi
@@ -379,7 +390,7 @@ pre_triggers() {
# mkfontdir # mkfontdir
if [ "$trig_3" != "1" ]; then if [ "$trig_3" != "1" ]; then
for pkg in $@; do for pkg in $@; do
if [ -s "$INDEX_DIR/$pkg/.files" ] && [ "$(grep ^usr/share/fonts/$ $INDEX_DIR/$pkg/.files)" ]; then if [ -s "$PKGDB_DIR/$pkg/.files" ] && [ "$(grep ^usr/share/fonts/$ $PKGDB_DIR/$pkg/.files)" ]; then
trig_3=1 trig_3=1
break break
fi fi
@@ -389,7 +400,7 @@ pre_triggers() {
# hwdb # hwdb
if [ "$trig_4" != "1" ]; then if [ "$trig_4" != "1" ]; then
for pkg in $@; do for pkg in $@; do
if [ -s "$INDEX_DIR/$pkg/.files" ] && [ "$(grep ^etc/udev/hwdb.d/$ $INDEX_DIR/$pkg/.files)" ]; then if [ -s "$PKGDB_DIR/$pkg/.files" ] && [ "$(grep ^etc/udev/hwdb.d/$ $PKGDB_DIR/$pkg/.files)" ]; then
trig_4=1 trig_4=1
break break
fi fi
@@ -399,7 +410,7 @@ pre_triggers() {
# icon caches # icon caches
if [ "$trig_5" != "1" ]; then if [ "$trig_5" != "1" ]; then
for pkg in $@; do for pkg in $@; do
if [ -s "$INDEX_DIR/$pkg/.files" ] && [ "$(grep ^usr/share/icons/$ $INDEX_DIR/$pkg/.files)" ]; then if [ -s "$PKGDB_DIR/$pkg/.files" ] && [ "$(grep ^usr/share/icons/$ $PKGDB_DIR/$pkg/.files)" ]; then
trig_5=1 trig_5=1
break break
fi fi
@@ -409,7 +420,7 @@ pre_triggers() {
# gtk3 immodules # gtk3 immodules
if [ "$trig_6" != "1" ]; then if [ "$trig_6" != "1" ]; then
for pkg in $@; do for pkg in $@; do
if [ -s "$INDEX_DIR/$pkg/.files" ] && [ "$(grep ^usr/lib/gtk-3.0/3.0.0/immodules/.*.so $INDEX_DIR/$pkg/.files)" ]; then if [ -s "$PKGDB_DIR/$pkg/.files" ] && [ "$(grep ^usr/lib/gtk-3.0/3.0.0/immodules/.*.so $PKGDB_DIR/$pkg/.files)" ]; then
trig_6=1 trig_6=1
break break
fi fi
@@ -419,7 +430,7 @@ pre_triggers() {
# gtk2 immodules # gtk2 immodules
if [ "$trig_7" != "1" ]; then if [ "$trig_7" != "1" ]; then
for pkg in $@; do for pkg in $@; do
if [ -s "$INDEX_DIR/$pkg/.files" ] && [ "$(grep ^usr/lib/gtk-2.0/2.10.0/immodules/.*.so $INDEX_DIR/$pkg/.files)" ]; then if [ -s "$PKGDB_DIR/$pkg/.files" ] && [ "$(grep ^usr/lib/gtk-2.0/2.10.0/immodules/.*.so $PKGDB_DIR/$pkg/.files)" ]; then
trig_7=1 trig_7=1
break break
fi fi
@@ -429,7 +440,7 @@ pre_triggers() {
# gsettings schema # gsettings schema
if [ "$trig_8" != "1" ]; then if [ "$trig_8" != "1" ]; then
for pkg in $@; do for pkg in $@; do
if [ -s "$INDEX_DIR/$pkg/.files" ] && [ "$(grep ^usr/share/glib-2.0/schemas/$ $INDEX_DIR/$pkg/.files)" ]; then if [ -s "$PKGDB_DIR/$pkg/.files" ] && [ "$(grep ^usr/share/glib-2.0/schemas/$ $PKGDB_DIR/$pkg/.files)" ]; then
trig_8=1 trig_8=1
break break
fi fi
@@ -439,7 +450,7 @@ pre_triggers() {
# gio modules # gio modules
if [ "$trig_9" != "1" ]; then if [ "$trig_9" != "1" ]; then
for pkg in $@; do for pkg in $@; do
if [ -s "$INDEX_DIR/$pkg/.files" ] && [ "$(grep ^usr/lib/gio/modules/.*.so $INDEX_DIR/$pkg/.files)" ]; then if [ -s "$PKGDB_DIR/$pkg/.files" ] && [ "$(grep ^usr/lib/gio/modules/.*.so $PKGDB_DIR/$pkg/.files)" ]; then
trig_9=1 trig_9=1
break break
fi fi
@@ -449,7 +460,7 @@ pre_triggers() {
# gdk-pixbuf # gdk-pixbuf
if [ "$trig_10" != "1" ]; then if [ "$trig_10" != "1" ]; then
for pkg in $@; do for pkg in $@; do
if [ -s "$INDEX_DIR/$pkg/.files" ] && [ "$(grep ^usr/lib/gdk-pixbuf-2.0/2.10.0/loaders/.*.so $INDEX_DIR/$pkg/.files)" ]; then if [ -s "$PKGDB_DIR/$pkg/.files" ] && [ "$(grep ^usr/lib/gdk-pixbuf-2.0/2.10.0/loaders/.*.so $PKGDB_DIR/$pkg/.files)" ]; then
trig_10=1 trig_10=1
break break
fi fi
@@ -459,7 +470,7 @@ pre_triggers() {
# font caches # font caches
if [ "$trig_11" != "1" ]; then if [ "$trig_11" != "1" ]; then
for pkg in $@; do for pkg in $@; do
if [ -s "$INDEX_DIR/$pkg/.files" ] && [ "$(grep ^usr/share/fonts/$ $INDEX_DIR/$pkg/.files)" ]; then if [ -s "$PKGDB_DIR/$pkg/.files" ] && [ "$(grep ^usr/share/fonts/$ $PKGDB_DIR/$pkg/.files)" ]; then
trig_11=1 trig_11=1
break break
fi fi
@@ -469,7 +480,7 @@ pre_triggers() {
# makedirs # makedirs
if [ "$trig_12" != "1" ]; then if [ "$trig_12" != "1" ]; then
for pkg in $@; do for pkg in $@; do
if [ -s "$INDEX_DIR/$pkg/.pkgmkdirs" ]; then if [ -s "$PKGDB_DIR/$pkg/.pkgmkdirs" ]; then
trig_12=1 trig_12=1
break break
fi fi
@@ -481,6 +492,7 @@ scratch_build() {
while [ "$1" ]; do while [ "$1" ]; do
case $1 in case $1 in
-i|-u|-r|-g|-p) ;; -i|-u|-r|-g|-p) ;;
--log) LOG=1;;
-*) OPTS="$OPTS $1";; -*) OPTS="$OPTS $1";;
*) PKGNAME="$PKGNAME $1";; *) PKGNAME="$PKGNAME $1";;
esac esac
@@ -497,10 +509,17 @@ scratch_build() {
} }
cd $ppath cd $ppath
settermtitle "Building $pkg..." settermtitle "Building $pkg..."
pkgbuild $OPTS || { if [ "$LOG" ]; then
settermtitle "Building $pkg failed." pkgbuild $OPTS | tee /var/log/pkgbuild.log || {
return 1 settermtitle "Building $pkg failed."
} return 1
}
else
pkgbuild $OPTS || {
settermtitle "Building $pkg failed."
return 1
}
fi
settermtitle "Building $pkg done." settermtitle "Building $pkg done."
cd - >/dev/null cd - >/dev/null
done done
@@ -678,18 +697,21 @@ scratch_remove() {
outdatepkg() { outdatepkg() {
for pkg in $(allinstalled); do for pkg in $(allinstalled); do
if [ ! -e "$INDEX_DIR/$pkg/.lock" ] && getportpath $pkg >/dev/null; then if [ -f "$MASK_FILE" ] && [ $(grep -Ev '^(#|$| )' $MASK_FILE | grep $pkg) ]; then
. $(getportpath $pkg)/$BUILD_SCRIPT continue
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
fi 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 done
} }
@@ -797,78 +819,79 @@ scratch_upgrade() {
} }
for pkg in $PKGNAME; do for pkg in $PKGNAME; do
if ! isinstalled $pkg; then if ! isinstalled $pkg; then
msgerr "Package '$pkg' not installed." echo "Package '$pkg' not installed."
continue continue
elif [ ! $(getportpath $pkg) ]; then elif [ ! $(getportpath $pkg) ]; then
msgerr "Package '$pkg' not exist." echo "Package '$pkg' not exist."
continue continue
else else
. $(getportpath $pkg)/$BUILD_SCRIPT . $(getportpath $pkg)/$BUILD_SCRIPT
if [ "$(installed_pkg_info version $pkg)-$(installed_pkg_info release $pkg)" = "$version-$release" ]; then if [ "$(installed_pkg_info version $pkg)-$(installed_pkg_info release $pkg)" = "$version-$release" ]; then
msg "Package '$pkg' is up to date." echo "Package '$pkg' is up to date."
continue continue
fi fi
fi fi
upkg="$upkg $pkg" upkg="$upkg $pkg"
done done
[ "$upkg" ] || return 0 [ "$upkg" ] || return 0
[ "$NO_DEP" ] || {
UPGPKG=0
NEWPKG=0
if [ "$NODEP" != 1 ]; then
echo "Resolving dependencies..." echo "Resolving dependencies..."
DEP=$(scratch_deplist $upkg $EXOPT | awk '{print $2}') DEP=$(scratch_deplist $upkg $EXOPT | awk '{print $2}')
for dep in $DEP; do echo
if ! isinstalled $dep; then for d in $DEP; do
[ "$(getportpath $dep)" ] && newpkg="$newpkg $dep" if [ "$(echo $upkg | tr ' ' '\n' | grep -x $d)" = "$d" ]; then
printf "[${GREEN}u${CRESET}] $d "
WILLINSTALL="$WILLINSTALL $d"
UPGPKG=$(( UPGPKG + 1 ))
elif ! isinstalled $d && [ "$(getportpath "$d")" ]; then
printf "[${CYAN}n${CRESET}] $d "
WILLINSTALL="$WILLINSTALL $d"
NEWPKG=$(( NEWPKG + 1 ))
fi fi
done done
} else
echo echo
tnew=0 for dd in $upkg; do
tup=0 printf "[${GREEN}u${CRESET}] $dd "
for i in $newpkg; do WILLINSTALL="$WILLINSTALL $dd"
tnew=$(( tnew + 1 )) UPGPKG=$(( UPGPKG + 1 ))
printf "[${CYAN}n${CRESET}] $i " done
done fi
for i in $upkg; do
tup=$(( tup + 1 ))
printf "[${GREEN}u${CRESET}] $i "
done
echo; echo echo; echo
echo "( $tup upgrade, $tnew new install )" echo "( $UPGPKG upgrade, $NEWPKG new install )"
echo echo
[ "$NOCONFIRM" ] || { [ "$NOCONFIRM" ] || {
confirm "Continue upgrade/install these package(s)?" "Package upgrade cancelled." || exit $? confirm "Continue upgrade/install these package(s)?" "Package upgrade cancelled." || exit $?
echo echo
} }
total=$(( tup + tnew ))
count=0
error=0 error=0
if [ "$newpkg" ]; then count=0
for pkg in $newpkg; do total=$(echo $WILLINSTALL | wc -w)
count=$(( count + 1 )) for inst in $WILLINSTALL; do # install all required dependencies and target packages itself
cd $(getportpath $pkg)
settermtitle "[ $count/$total ] Installing $pkg..."
pkgbuild -i $OPTS || {
error=1
count=$(( count - 1 ))
break
}
done_pkg="$done_pkg $pkg"
cd - >/dev/null
done
fi
for pkg in $upkg; do # upgrade all target packages
count=$(( count + 1 )) count=$(( count + 1 ))
cd $(getportpath $pkg) cd $(getportpath $inst)
settermtitle "[ $count/$total ] Upgrading $pkg..." if ! isinstalled $inst; then
settermtitle "[ $count/$total ] Installing $inst..."
pkgbuild -i $OPTS || {
error=1
count=$(( count - 1 ))
break
}
else
settermtitle "[ $count/$total ] Upgrading $inst..."
pkgbuild -u $OPTS || { pkgbuild -u $OPTS || {
error=1 error=1
count=$(( count - 1 )) count=$(( count - 1 ))
break break
} }
done_pkg="$done_pkg $pkg" fi
cd - >/dev/null cd - >/dev/null
done_pkg="$done_pkg $inst"
done done
settermtitle "triggering upgrade hook..." settermtitle "Triggering install hook."
[ "$done_pkg" ] && scratch_trigger $done_pkg [ "$done_pkg" ] && scratch_trigger $done_pkg
settermtitle "$count/$total package(s) upgraded." settermtitle "$count/$total package(s) upgraded."
return "$error" return "$error"
@@ -883,7 +906,10 @@ scratch_outdate() {
fi fi
iversion=$(installed_pkg_info version $pkg) iversion=$(installed_pkg_info version $pkg)
irelease=$(installed_pkg_info release $pkg) irelease=$(installed_pkg_info release $pkg)
[ -f "$INDEX_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" outdatemsg="$name $iversion-$irelease => $version-$release $ITSLOCK"
newerinstmsg="$name $iversion-$irelease => $version-$release [newer installed] $ITSLOCK" newerinstmsg="$name $iversion-$irelease => $version-$release [newer installed] $ITSLOCK"
if [ "$version" != "$iversion" ]; then if [ "$version" != "$iversion" ]; then
@@ -916,6 +942,7 @@ scratch_search() {
needarg $@ needarg $@
arg=$* arg=$*
for repo in $PORT_REPO; do for repo in $PORT_REPO; do
[ -d $repo ] || continue
out=$(grep -R "# description" $repo | grep $BUILD_SCRIPT | grep "$arg" | awk -F : '{print $1}' | sort) out=$(grep -R "# description" $repo | grep $BUILD_SCRIPT | grep "$arg" | awk -F : '{print $1}' | sort)
[ "$out" ] || continue [ "$out" ] || continue
found=1 found=1
@@ -1130,6 +1157,187 @@ deplist() {
CHECK=$(echo $CHECK | sed "s/$1//") CHECK=$(echo $CHECK | sed "s/$1//")
} }
scratch_cat() {
needarg $@
if PPATH=$(getportpath "$1"); then
cat "$PPATH/$BUILD_SCRIPT"
else
msgerr "Port '$1' not exist."
return 1
fi
}
scratch_dependent() {
needarg $@
if [ "$(getportpath $1)" ]; then
grep -R "# depends[[:blank:]]*:" $PORT_REPO \
| sed "s,:# depends[[:blank:]]*:[[:blank:]]*,#|,;s, ,|,g;s,$,|,g" \
| grep "|$1|" \
| awk -F "#" '{print $1}' \
| rev \
| awk -F / '{print $2}' \
| rev
else
msgerr "Port '$1' not exist."
return 1
fi
}
scratch_depends() {
needarg $@
if getportpath "$1" >/dev/null; then
depends=$(get_depends $1)
else
msgerr "Port '$1' not exist."
return 1
fi
for dep in $depends; do
if isinstalled $dep; then
msginst "$dep"
elif getportpath $dep >/dev/null; then
msgnoinst "$dep"
else
msgmiss "$dep"
fi
done
}
scratch_dup() {
dup=$(find $PORT_REPO -type d -print | grep -Exv "($(echo $PORT_REPO | tr ' ' '|'))" | \
rev | cut -d '/' -f1 | rev | sort | uniq -d)
if [ "$dup" ]; then
for dp in $dup; do
for repo in $PORT_REPO; do
[ -d $repo/$dp ] && echo "$repo/$dp"
done
done
else
msg "No duplicate ports found."
fi
}
scratch_foreign() {
for pkg in $(allinstalled); do
if ! getportpath $pkg >/dev/null; then
iname=$(installed_pkg_info name $pkg)
iversion=$(installed_pkg_info version $pkg)
irelease=$(installed_pkg_info release $pkg)
echo "$iname $iversion-$irelease"
fi
unset iname iversion irelease
done
}
scratch_info() {
needarg $@
ppath=$(getportpath $1) || return 1
. $ppath/$BUILD_SCRIPT
desc=$(grep "^# description[[:blank:]]*:" $ppath/$BUILD_SCRIPT | sed 's/^# description[[:blank:]]*:[[:blank:]]*//')
maint=$(grep "^# maintainer[[:blank:]]*:" $ppath/$BUILD_SCRIPT | sed 's/^# maintainer[[:blank:]]*:[[:blank:]]*//')
deps=$(get_depends $1 | tr '\n' ' ')
echo "Name: $1"
echo "Path: $ppath"
echo "Version: $version"
echo "Release: $release"
echo "Description: $desc"
echo "Maintainer: $maint"
echo "Dependencies: $deps"
}
scratch_installed() {
for all in $(allinstalled); do
printf "%s" "$all "
grep -e ^version -e ^release $PKGDB_DIR/$all/.pkginfo | awk '{print $3}' | tr '\n' '-' | sed 's:\-$::'
echo
done
}
scratch_missingdep() {
for pkg in $(allinstalled); do
if getportpath "$pkg" >/dev/null; then
depends=$(get_depends $pkg)
fi
if [ "$depends" ]; then
for d in $depends; do
if ! isinstalled $d; then
if [ -z "$msd" ]; then
msd="$d"
else
msd="$msd $d"
fi
fi
done
fi
[ "$msd" ] && echo "$pkg: $msd"
unset depends msd
done
}
scratch_locked() {
for pkg in $(allinstalled); do
[ -f "$PKGDB_DIR/$pkg/.lock" ] && echo "$pkg"
done
}
scratch_orphan() {
tmpallpkg="/tmp/.pkgquery_allpkg.$$"
tmpalldep="/tmp/.pkgquery_alldep.$$"
for pkg in $(allinstalled); do
echo $pkg >> $tmpallpkg
dep="$dep $(get_depends $pkg)"
done
echo $dep | tr ' ' '\n' | sort | uniq > "$tmpalldep"
grep -xvF -f "$tmpalldep" "$tmpallpkg"
rm "$tmpalldep" "$tmpallpkg"
}
scratch_path() {
needarg $@
if PPATH=$(getportpath "$1"); then
echo "$PPATH"
else
msgerr "Port '$1' not exist."
return 1
fi
}
scratch_provide() {
needarg $@
arg=$(echo $1 | sed "s/^\///")
grep -R "$arg" $PKGDB_DIR/*/.files \
| sed "s:$PKGDB_DIR/::" \
| sed "s:/.files::" \
| tr : " " \
| column -t
}
scratch_readme() {
needarg $@
if PPATH=$(getportpath "$1"); then
if [ -f "$PPATH/readme" ]; then
cat "$PPATH/readme"
else
msgerr "Port '$1' does not have readme."
fi
else
msgerr "Port '$1' not exist."
exit 1
fi
}
scratch_files() {
needarg $@
if isinstalled $1; then
cat "$PKGDB_DIR/$1/.files"
else
msg "Package '$1' not installed."
fi
}
scratch_help() { scratch_help() {
cat << EOF cat << EOF
Usage: Usage:
@@ -1141,40 +1349,58 @@ Options:
-n|--no-dep skip dependencies -n|--no-dep skip dependencies
-y|--yes skip ask user permission -y|--yes skip ask user permission
--exclude=* exclude dependencies, comma separated --exclude=* exclude dependencies, comma separated
upgrade <ports> <arg> upgrade ports (use pkgbuild arg, except '-i' & '-r') upgrade <ports> <arg> upgrade ports (use pkgbuild arg, except '-i' & '-r')
-n|--no-dep skip dependencies -n|--no-dep skip dependencies
-y|--yes skip ask user permission -y|--yes skip ask user permission
--exclude=* exclude dependencies, comma separated --exclude=* exclude dependencies, comma separated
remove <ports> <arg> remove installed ports (use pkgdel arg) remove <ports> <arg> remove installed ports (use pkgdel arg)
-y|--yes skip ask user permission -y|--yes skip ask user permission
sysup <arg> full system upgrade (use pkgbuild arg, except '-i', '-r' & '-u') sysup <arg> full system upgrade (use pkgbuild arg, except '-i', '-r' & '-u')
-n|--no-dep skip dependencies -n|--no-dep skip dependencies
-y|--yes skip ask user permission -y|--yes skip ask user permission
--exclude=* exclude dependencies, comma separated --exclude=* exclude dependencies, comma separated
deplist <ports> print all dependencies for ports deplist <ports> print all dependencies for ports
-q|--quick skip installed ports -q|--quick skip installed ports
--exclude=* exclude dependencies, comma separated --exclude=* exclude dependencies, comma separated
build <ports> <arg> build ports (use pkgbuild arg, except '-i', '-u', '-r', '-g', & '-p')
lock <ports> locking ports prevent upgrade build <ports> <arg> build ports (use pkgbuild arg, except '-i', '-u', '-r', '-g', & '-p')
unlock <ports> unlock locked ports --log log build process (/var/log/pkgbuild.log)
trigger [ports] run system trigger
lock <ports> locking ports prevent upgrade
unlock <ports> unlock locked ports
trigger [ports] run system trigger
search <pattern> find ports in repo
cat <port> print spkgbuild
depends <port> print dependencies
dependent <port> print dependent
path <port> print path in repo
provide <files> print port's provided files
readme <port> print readme file, if exist
files <port> print files installed
info <port> print information
locate <files> print location of files in ports repo
sync update ports database sync update ports database
search <pattern> find ports in repo
outdate print outdated ports outdate print outdated ports
cache print and clear old pkg and src caches cache print and clear old pkg and src caches
integrity check installed port integrity integrity check installed port integrity
dup print duplicate ports in repo
installed print all installed ports
locked print loacked ports
missingdep print missing dependencies
orphan print orphan installed ports
foreign print foreign ports
help print this help msg help print this help msg
Global options: Global options:
--repo=<repo path> add custom repo path --append-repo=<repo path> append custom repo path
--nocolor disable colour for output --prepend-repo=<repo path> prepend custom repo path
--repo-file=<repo file> use custom repo file (default: $REPO_FILE)
--nocolor disable colour for output
EOF EOF
} }
@@ -1183,46 +1409,55 @@ print_runhelp_msg() {
exit 2 exit 2
} }
BUILD_SCRIPT="spkgbuild" # check for 'pkgadd', required for package database path
INDEX_DIR="/var/lib/scratchpkg/index" command -v pkgadd >/dev/null 2>&1 || {
REPO_FILE="/etc/scratchpkg.repo" echo "'pkgadd' not found in \$PATH!"
ALIAS_FILE="/etc/scratchpkg.alias" exit 1
}
# default value from pkgbuild
SOURCE_DIR="/var/cache/scratchpkg/sources"
PACKAGE_DIR="/var/cache/scratchpkg/packages"
COMPRESSION_MODE="xz"
mode=$1 mode=$1
if [ -z "$mode" ]; then [ "$mode" ] || {
print_runhelp_msg print_runhelp_msg
fi }
shift shift
for opt in $@; do for opt in $@; do
case $opt in case $opt in
--nocolor) nocolor;; --nocolor) nocolor;;
--repo=*) PORT_REPO="$PORT_REPO ${opt#*=}";; --repo=*) PORT_REPO="$PORT_REPO ${opt#*=}";;
--*) MAINOPTS="$MAINOPTS $opt";; --repo-file=*) REPO_FILE="${opt#*=}";;
-*) char=${#opt}; count=1 --alias-file=*) ALIAS_FILE="${opt#*=}";;
while [ "$count" != "$char" ]; do --*) MAINOPTS="$MAINOPTS $opt";;
count=$((count+1)) -*) char=${#opt}; count=1
MAINOPTS="$MAINOPTS -$(echo $opt | cut -c $count)" while [ "$count" != "$char" ]; do
done;; count=$((count+1))
*) MAINOPTS="$MAINOPTS $opt";; MAINOPTS="$MAINOPTS -$(printf '%s' $opt | cut -c $count)"
done;;
*) MAINOPTS="$MAINOPTS $opt";;
esac esac
shift shift
done done
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"
PACKAGE_DIR="/var/cache/scratchpkg/packages"
COMPRESSION_MODE="xz"
if [ -f "$REPO_FILE" ]; then if [ -f "$REPO_FILE" ]; then
for repodir in $(grep -Ev '^(#|$)' "$REPO_FILE" | awk '{print $1}'); do for repodir in $(grep -Ev '^(#|$)' "$REPO_FILE" | awk '{print $1}'); do
PORT_REPO="$PORT_REPO $repodir" PORT_REPO="$PORT_REPO $repodir"
done done
fi fi
if [ "$(type -t scratch_$mode)" = "function" ]; then if [ "$(command -v scratch_$mode)" ]; then
scratch_$mode $MAINOPTS scratch_$mode $MAINOPTS
else else
print_runhelp_msg print_runhelp_msg

View File

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

View File

@@ -2,14 +2,14 @@
# Configuration file for scratchpkg # Configuration file for scratchpkg
# #
CFLAGS="-O2 -march=x86-64 -pipe" # CFLAGS="-O2 -march=x86-64 -pipe"
CXXFLAGS="${CFLAGS}" # CXXFLAGS="${CFLAGS}"
MAKEFLAGS="-j$(nproc)" # MAKEFLAGS="-j$(nproc)"
# SOURCE_DIR="/var/cache/scratchpkg/sources" # SOURCE_DIR="/var/cache/scratchpkg/sources"
# PACKAGE_DIR="/var/cache/scratchpkg/packages" # PACKAGE_DIR="/var/cache/scratchpkg/packages"
# WORK_DIR="/var/cache/scratchpkg/work" # WORK_DIR="/var/cache/scratchpkg/work"
# DOWNLOAD_PROG="wget" # DOWNLOAD_PROG="auto"
# WGET_OPTS="" # WGET_OPTS=""
# CURL_OPTS="" # CURL_OPTS=""
# COMPRESSION_MODE="xz" # COMPRESSION_MODE="xz"

6
scratchpkg.mask Normal file
View File

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

View File

@@ -20,7 +20,7 @@
EDITOR=${EDITOR:-vi} EDITOR=${EDITOR:-vi}
type -p $EDITOR >/dev/null || { command -v $EDITOR >/dev/null || {
echo "Editor '$EDITOR' not exist. Append 'EDITOR=<your editor>' to ${0##*/}." echo "Editor '$EDITOR' not exist. Append 'EDITOR=<your editor>' to ${0##*/}."
exit 2 exit 2
} }

22
xchroot
View File

@@ -1,4 +1,7 @@
#!/bin/sh #!/bin/sh
#
# script to enter chroot
#
printhelp() { printhelp() {
cat << EOF cat << EOF
@@ -14,6 +17,13 @@ EOF
msgerr() { msgerr() {
echo "ERROR: $*" echo "ERROR: $*"
} }
unmount() {
while true; do
mountpoint -q $1 || break
umount $1 2>/dev/null
done
}
[ "$(id -u)" = "0" ] || { [ "$(id -u)" = "0" ] || {
msgerr "$(basename $0) need root access!" msgerr "$(basename $0) need root access!"
@@ -78,13 +88,13 @@ retval=$?
mv $TARGET/etc/resolv.conf.tmp $TARGET/etc/resolv.conf mv $TARGET/etc/resolv.conf.tmp $TARGET/etc/resolv.conf
} }
umount $TARGET/dev/pts unmount $TARGET/dev/pts
umount $TARGET/dev unmount $TARGET/dev
umount $TARGET/run unmount $TARGET/run
umount $TARGET/proc unmount $TARGET/proc
if [ -n "$EFI_SYSTEM" ]; then if [ -n "$EFI_SYSTEM" ]; then
umount $TARGET/sys/firmware/efi/efivars unmount $TARGET/sys/firmware/efi/efivars
fi fi
umount $TARGET/sys unmount $TARGET/sys
exit $retval exit $retval