mirror of
https://github.com/outbackdingo/scratchpkg.git
synced 2026-03-21 13:44:51 +00:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0ff3d070e | ||
|
|
985f59fc97 | ||
|
|
2651ad3188 | ||
|
|
3602e0a8e8 | ||
|
|
c816e3b409 | ||
|
|
8d4b7902eb | ||
|
|
32b7462f2d | ||
|
|
a1ef1c5b33 | ||
|
|
b72816f8df | ||
|
|
9b186bfd31 | ||
|
|
8e8c62d338 | ||
|
|
c8b2eca5ba | ||
|
|
a23a22c659 | ||
|
|
9a06fbd474 | ||
|
|
7a91fbdcd4 | ||
|
|
00e55a2473 | ||
|
|
0ee256b921 | ||
|
|
424c56f075 | ||
|
|
0440395881 | ||
|
|
6dddc034f9 | ||
|
|
4d8f539f45 | ||
|
|
cfaca4e65f | ||
|
|
0a9cfce26a | ||
|
|
5eeb974b17 | ||
|
|
2e26f7c2f0 |
@@ -14,10 +14,10 @@ install -d ${DESTDIR}${REVDEPD}
|
||||
|
||||
install -dm777 ${DESTDIR}${CACHE_DIR}/packages
|
||||
install -dm777 ${DESTDIR}${CACHE_DIR}/sources
|
||||
install -dm777 ${DESTDIR}${CACHE_DIR}/log
|
||||
install -dm777 ${DESTDIR}${CACHE_DIR}/work
|
||||
|
||||
install -m755 revdep pkgadd pkgdel pkgbuild pkgquery scratch updateconf ${DESTDIR}${BINDIR}
|
||||
install -m644 scratchpkg.conf scratchpkg.repo ${DESTDIR}${CONFDIR}
|
||||
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 revdep.conf ${DESTDIR}${REVDEPCONF}
|
||||
|
||||
129
pkgadd
129
pkgadd
@@ -43,7 +43,7 @@ msgwarn() {
|
||||
echo "==> WARNING: $1"
|
||||
}
|
||||
|
||||
help() {
|
||||
help() {
|
||||
cat << EOF
|
||||
Usage:
|
||||
$(basename $0) [ <options> <package.spkg.txz> ]
|
||||
@@ -70,9 +70,9 @@ extract_opts() {
|
||||
--*) opts="$opts $1";;
|
||||
-*) char=${#1}; count=1
|
||||
while [ "$count" != "$char" ]; do
|
||||
count=$((count+1))
|
||||
opts="$opts -$(echo $1 | cut -c $count)"
|
||||
done;;
|
||||
count=$((count+1))
|
||||
opts="$opts -$(echo $1 | cut -c $count)"
|
||||
done;;
|
||||
*) opts="$opts $1"
|
||||
esac
|
||||
shift
|
||||
@@ -93,12 +93,12 @@ parse_opts() {
|
||||
-h | --help) SHOWHELP=yes ;;
|
||||
--no-preinstall) NO_PREINSTALL=yes ;;
|
||||
--no-postinstall) NO_POSTINSTALL=yes ;;
|
||||
--no-preupgrade) NO_PREUPGRADE=yes ;;
|
||||
--no-postupgrade) NO_POSTUPGRADE=yes ;;
|
||||
--no-backup) NO_BACKUP=yes ;;
|
||||
--root=*) ROOT_DIR="${1#*=}" ;;
|
||||
*.spkg.tar.*) PKGNAME="$(realpath $1)" ;;
|
||||
*) msg "Invalid option! ($1)"; exit 1 ;;
|
||||
--no-preupgrade) NO_PREUPGRADE=yes ;;
|
||||
--no-postupgrade) NO_POSTUPGRADE=yes ;;
|
||||
--no-backup) NO_BACKUP=yes ;;
|
||||
--root=*) ROOT_DIR="${1#*=}" ;;
|
||||
*.spkg.tar.*) PKGNAME="$(realpath $1)" ;;
|
||||
*) msg "Invalid option! ($1)"; exit 1 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
@@ -107,30 +107,31 @@ parse_opts() {
|
||||
|
||||
ret() {
|
||||
# remove lock and all tmp files on exit
|
||||
rm -f "$LOCK_FILE" "$TMP_PKGADD" "$TMP_PKGINSTALL" "$TMP_CONFLICT"
|
||||
rm -f "$ROOT_DIR/$LOCK_FILE" "$TMP_PKGADD" "$TMP_PKGINSTALL" "$TMP_CONFLICT"
|
||||
exit $1
|
||||
}
|
||||
|
||||
isinstalled() {
|
||||
if [ -s "$INDEX_DIR/$1/.pkginfo" ] && grep -q "$1" "$INDEX_DIR/$1/.pkginfo"; then
|
||||
if [ -s "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo" ] && grep -q "$1" "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo"; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
run_scripts() {
|
||||
if [ "$ROOT_DIR" ]; then
|
||||
xchroot "$ROOT_DIR" sh $@
|
||||
else
|
||||
sh $@
|
||||
fi
|
||||
}
|
||||
|
||||
parse_opts $(extract_opts "$@")
|
||||
|
||||
INDEX_DIR="$ROOT_DIR/var/lib/scratchpkg/index"
|
||||
LOCK_FILE="$ROOT_DIR/var/lib/scratchpkg/spkg.lock"
|
||||
|
||||
# disable pre/post install/upgrade script when install to custom root location
|
||||
if [ "$ROOT_DIR" != "" ]; then
|
||||
NO_PREINSTALL=yes
|
||||
NO_POSTINSTALL=yes
|
||||
NO_PREUPGRADE=yes
|
||||
NO_POSTUPGRADE=yes
|
||||
fi
|
||||
SCRATCHPKG_DIR="var/lib/scratchpkg"
|
||||
INDEX_DIR="$SCRATCHPKG_DIR/index"
|
||||
LOCK_FILE="$SCRATCHPKG_DIR/spkg.lock"
|
||||
|
||||
# show help page
|
||||
[ "$SHOWHELP" ] || [ -z "$PKGNAME" ] && {
|
||||
@@ -138,25 +139,26 @@ fi
|
||||
ret 0
|
||||
}
|
||||
|
||||
[ -d "$INDEX_DIR" ] || {
|
||||
msgerr "Package's database directory not exist! ($INDEX_DIR)"
|
||||
[ -d "$ROOT_DIR/$INDEX_DIR" ] || {
|
||||
msgerr "Package's database directory not exist! ($ROOT_DIR/$INDEX_DIR)"
|
||||
ret 1
|
||||
}
|
||||
|
||||
# check for root access, non-root only allowed if use custom --root= location
|
||||
[ "$(id -u)" = "0" ] || [ "$ROOT_DIR" ] || {
|
||||
# check for root access
|
||||
[ "$(id -u)" = "0" ] || {
|
||||
msgerr "Installing package need root access!"
|
||||
ret 1
|
||||
}
|
||||
|
||||
# check for lock file
|
||||
[ -f "$LOCK_FILE" ] && {
|
||||
[ -f "$ROOT_DIR/$LOCK_FILE" ] && {
|
||||
msgerr "Cant install/remove package simultaneously."
|
||||
msgerr "remove '$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 "$LOCK_FILE" 2>/dev/null || {
|
||||
msgerr "Cant create lock file in '$LOCK_FILE'."
|
||||
touch "$ROOT_DIR/$LOCK_FILE" 2>/dev/null || {
|
||||
msgerr "Cant create lock file in '$ROOT_DIR/$LOCK_FILE'."
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -173,11 +175,11 @@ release=${noextname##*-}
|
||||
noextname=${noextname%-*}
|
||||
version=${noextname##*-}
|
||||
name=${noextname%-*}
|
||||
|
||||
|
||||
# get package information if installed
|
||||
if isinstalled $name; then
|
||||
iversion=$(grep ^version $INDEX_DIR/$name/.pkginfo | cut -d " " -f3-)
|
||||
irelease=$(grep ^release $INDEX_DIR/$name/.pkginfo | cut -d " " -f3-)
|
||||
iversion=$(grep ^version $ROOT_DIR/$INDEX_DIR/$name/.pkginfo | cut -d " " -f3-)
|
||||
irelease=$(grep ^release $ROOT_DIR/$INDEX_DIR/$name/.pkginfo | cut -d " " -f3-)
|
||||
ALREADYINSTALLED=yes
|
||||
fi
|
||||
|
||||
@@ -200,9 +202,9 @@ if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
TMP_PKGADD="/tmp/.tmp_pkgadd.$$"
|
||||
TMP_PKGINSTALL="/tmp/.tmp_pkginstall.$$"
|
||||
TMP_CONFLICT="/tmp/.tmp_conflict.$$"
|
||||
TMP_PKGADD="$ROOT_DIR/$SCRATCHPKG_DIR/.tmp_pkgadd"
|
||||
TMP_PKGINSTALL="$ROOT_DIR/$SCRATCHPKG_DIR/.tmp_pkginstall"
|
||||
TMP_CONFLICT="$ROOT_DIR/$SCRATCHPKG_DIR/.tmp_conflict"
|
||||
|
||||
# check integrity of package and save list file/dirs to install in the meantime
|
||||
tar -tf $PKGNAME > $TMP_PKGADD 2>/dev/null || {
|
||||
@@ -225,7 +227,7 @@ if [ ! "$IGNORE_CONFLICT" ]; then
|
||||
fi
|
||||
if [ -e "$ROOT_DIR/$line" ] || [ -L "$ROOT_DIR/$line" ]; then
|
||||
if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
|
||||
if ! grep -Fqx "$line" "$INDEX_DIR/$name/.files"; then
|
||||
if ! grep -Fqx "$line" "$ROOT_DIR/$INDEX_DIR/$name/.files"; then
|
||||
echo "$line"
|
||||
touch "$TMP_CONFLICT"
|
||||
fi
|
||||
@@ -244,19 +246,19 @@ fi
|
||||
|
||||
# pre-install and pre-upgrade script
|
||||
if grep -qx .pkginstall $TMP_PKGADD; then
|
||||
TMP_PKGINSTALL_SCRIPT="/tmp/.tmp_pkgadd_installscript.$$"
|
||||
tar -xf "$PKGNAME" .pkginstall -O > "$TMP_PKGINSTALL_SCRIPT"
|
||||
TMP_PKGINSTALL_SCRIPT="$SCRATCHPKG_DIR/pkgadd_installscript"
|
||||
tar -xf "$PKGNAME" .pkginstall -O > "$ROOT_DIR/$TMP_PKGINSTALL_SCRIPT"
|
||||
if [ ! "$NO_PREINSTALL" ] && [ ! "$UPGRADE_PKG" ]; then
|
||||
(cd "$ROOT_DIR"/
|
||||
sh "$TMP_PKGINSTALL_SCRIPT" pre-install "$version"
|
||||
run_scripts "$TMP_PKGINSTALL_SCRIPT" pre-install "$version"
|
||||
)
|
||||
fi
|
||||
if [ "$UPGRADE_PKG" ] && [ ! "$NO_PREUPGRADE" ]; then
|
||||
(cd "$ROOT_DIR"/
|
||||
sh "$TMP_PKGINSTALL_SCRIPT" pre-upgrade "$version" "$iversion"
|
||||
run_scripts "$TMP_PKGINSTALL_SCRIPT" pre-upgrade "$version" "$iversion"
|
||||
)
|
||||
fi
|
||||
rm -f "$TMP_PKGINSTALL_SCRIPT"
|
||||
rm -f "$ROOT_DIR/$TMP_PKGINSTALL_SCRIPT"
|
||||
fi
|
||||
|
||||
# exclude .pkg* files when extract into system
|
||||
@@ -284,17 +286,18 @@ done
|
||||
|
||||
# remove old files from old package that not exist in new package
|
||||
if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
|
||||
rmlist_file="/tmp/.rmlist_file.$$"
|
||||
rmlist_dir="/tmp/.rmlist_dir.$$"
|
||||
reserve_dir="/tmp/.reserve_dir.$$"
|
||||
rmlist_all="/tmp/.rmlist_all.$$"
|
||||
grep '/$' $INDEX_DIR/*/.files | grep -v $INDEX_DIR/$name/.files | awk -F : '{print $2}' | sort | uniq > $reserve_dir # get list reserved dirs
|
||||
grep -Fxv -f "$TMP_PKGINSTALL" $INDEX_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 -Fxv -f "$reserve_dir" "$rmlist_all" | grep '/$' | tac > "$rmlist_dir" # get dirs only (safe) to remove
|
||||
# remove pseudo fs from remove list
|
||||
#sed '/^dev\//d;/^sys\//d;/^proc\//d;/^run\//d;/^tmp\//d' -i $rmlist_file
|
||||
#sed '/^dev\//d;/^sys\//d;/^proc\//d;/^run\//d;/^tmp\//d' -i $rmlist_dir
|
||||
rmlist_file="$ROOT_DIR/$SCRATCHPKG_DIR/.rmlist_file"
|
||||
rmlist_dir="$ROOT_DIR/$SCRATCHPKG_DIR/.rmlist_dir"
|
||||
reserve_dir="$ROOT_DIR/$SCRATCHPKG_DIR/.reserve_dir"
|
||||
rmlist_all="$ROOT_DIR/$SCRATCHPKG_DIR/.rmlist_all"
|
||||
grep '/$' $ROOT_DIR/$INDEX_DIR/*/.files \
|
||||
| grep -v $ROOT_DIR/$INDEX_DIR/$name/.files \
|
||||
| awk -F : '{print $2}' \
|
||||
| sort \
|
||||
| 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 -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
|
||||
(cd "$ROOT_DIR"/
|
||||
[ -s $rmlist_file ] && xargs -a $rmlist_file -d'\n' rm $VERBOSE_INSTALL
|
||||
[ -s $rmlist_dir ] && xargs -a $rmlist_dir -d'\n' rmdir $VERBOSE_INSTALL
|
||||
@@ -303,30 +306,30 @@ if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
|
||||
fi
|
||||
|
||||
# register package into database
|
||||
rm -fr "$INDEX_DIR/$name"
|
||||
mkdir "$INDEX_DIR/$name"
|
||||
echo "name = $name" > "$INDEX_DIR/$name/.pkginfo"
|
||||
echo "version = $version" >> "$INDEX_DIR/$name/.pkginfo"
|
||||
echo "release = $release" >> "$INDEX_DIR/$name/.pkginfo"
|
||||
install -m644 "$TMP_PKGINSTALL" "$INDEX_DIR/$name/.files"
|
||||
rm -fr "$ROOT_DIR/$INDEX_DIR/$name"
|
||||
mkdir "$ROOT_DIR/$INDEX_DIR/$name"
|
||||
echo "name = $name" > "$ROOT_DIR/$INDEX_DIR/$name/.pkginfo"
|
||||
echo "version = $version" >> "$ROOT_DIR/$INDEX_DIR/$name/.pkginfo"
|
||||
echo "release = $release" >> "$ROOT_DIR/$INDEX_DIR/$name/.pkginfo"
|
||||
install -m644 "$TMP_PKGINSTALL" "$ROOT_DIR/$INDEX_DIR/$name/.files"
|
||||
|
||||
for ii in $(grep ^.pkg* $TMP_PKGADD); do
|
||||
pkgfiles="$pkgfiles $ii"
|
||||
done
|
||||
|
||||
if [ "$pkgfiles" ]; then
|
||||
tar -x -f "$PKGNAME" -C "$INDEX_DIR/$name" $pkgfiles >/dev/null 2>&1
|
||||
tar -x -f "$PKGNAME" -C "$ROOT_DIR/$INDEX_DIR/$name" $pkgfiles >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
if [ -f "$INDEX_DIR/$name/.pkginstall" ]; then
|
||||
if [ -f "$ROOT_DIR/$INDEX_DIR/$name/.pkginstall" ]; then
|
||||
if [ ! "$NO_POSTINSTALL" ] && [ ! "$UPGRADE_PKG" ]; then
|
||||
(cd "$ROOT_DIR"/
|
||||
sh "$INDEX_DIR/$name/.pkginstall" post-install "$version"
|
||||
run_scripts "$INDEX_DIR/$name/.pkginstall" post-install "$version"
|
||||
)
|
||||
fi
|
||||
if [ "$UPGRADE_PKG" ] && [ ! "$NO_POSTUPGRADE" ]; then
|
||||
(cd "$ROOT_DIR"/
|
||||
sh "$INDEX_DIR/$name/.pkginstall" post-upgrade "$version" "$iversion"
|
||||
run_scripts "$INDEX_DIR/$name/.pkginstall" post-upgrade "$version" "$iversion"
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
58
pkgbase
Executable file
58
pkgbase
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# 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
|
||||
39
pkgbuild
39
pkgbuild
@@ -98,9 +98,14 @@ download_src() {
|
||||
FILENAME=$(basename $FILE)
|
||||
SRCURL=$FILE
|
||||
fi
|
||||
[ "$DOWNLOAD_PROG" = "auto" ] && {
|
||||
command -v curl >/dev/null && DOWNLOAD_PROG=curl
|
||||
command -v wget >/dev/null && DOWNLOAD_PROG=wget
|
||||
}
|
||||
case $DOWNLOAD_PROG in
|
||||
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" ;;
|
||||
*) msgerr "No download agent found"; abort 1;;
|
||||
esac
|
||||
if [ "$FILENAME" != "$FILE" ]; then
|
||||
if [ ! -f "$SOURCE_DIR/$FILENAME" ] || [ "$REDOWNLOAD_SOURCE" ]; then
|
||||
@@ -158,7 +163,7 @@ prepare_src() {
|
||||
if [ "$FILENAME" != "$FILE" ] && [ "$nxt" != 1 ]; then
|
||||
case $FILENAME in
|
||||
*.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"
|
||||
else
|
||||
COMMAND="tar -p -o -C $SRC -xf $FILENAME"
|
||||
@@ -291,6 +296,25 @@ backupconf() {
|
||||
done
|
||||
}
|
||||
|
||||
removedocs() {
|
||||
for i in doc gtk-doc info; do
|
||||
rm -fr \
|
||||
usr/share/$i \
|
||||
usr/$i \
|
||||
usr/local/$i \
|
||||
usr/local/share/$i
|
||||
done
|
||||
}
|
||||
|
||||
removelocales() {
|
||||
rm -fr \
|
||||
usr/share/locale \
|
||||
usr/locale \
|
||||
usr/local/locale \
|
||||
usr/local/share/locale \
|
||||
usr/lib/locale
|
||||
}
|
||||
|
||||
packaging() {
|
||||
for FILE in $INCLUDEINPKG; do
|
||||
if [ -f $FILE ]; then
|
||||
@@ -316,6 +340,8 @@ packaging() {
|
||||
[ "$KEEP_LIBTOOL" = 0 ] && removelibtool
|
||||
[ "$STRIP_BINARY" = 1 ] && strip_files
|
||||
[ "$ZIP_MAN" = 1 ] && compressinfomanpages
|
||||
[ "$KEEP_DOCS" = 0 ] && removedocs
|
||||
[ "$KEEP_LOCALES" = 0 ] && removelocales
|
||||
|
||||
if [ "${#backup[@]}" -gt 0 ]; then
|
||||
backupconf
|
||||
@@ -395,7 +421,7 @@ check_buildscript() {
|
||||
elif [ -z "$release" ]; then
|
||||
msgerr "'release' is empty!"
|
||||
exit 1
|
||||
elif [ "$(type -t build)" != "function" ]; then
|
||||
elif [ ! "$(command -v build)" ]; then
|
||||
msgerr "'build' function not exist!"
|
||||
exit 1
|
||||
elif echo "$version" | grep -q '-'; then
|
||||
@@ -427,6 +453,10 @@ set_options() {
|
||||
!makeflags) MAKE_FLAGS=0 ;;
|
||||
checksum) CHECK_MDSUM=1 ;;
|
||||
!checksum) CHECK_MDSUM=0 ;;
|
||||
docs) KEEP_DOCS=1 ;;
|
||||
!docs) KEEP_DOCS=0 ;;
|
||||
locales) KEEP_LOCALES=1 ;;
|
||||
!locales) KEEP_LOCALES=0 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
@@ -641,6 +671,7 @@ main() {
|
||||
abort 0
|
||||
fi
|
||||
else
|
||||
msg "Building '$name-$version-$release'..."
|
||||
download_src
|
||||
prepare_src
|
||||
run_build
|
||||
@@ -666,10 +697,10 @@ PKGBUILD_BSCRIPT="spkgbuild"
|
||||
SOURCE_DIR="/var/cache/scratchpkg/sources"
|
||||
PACKAGE_DIR="/var/cache/scratchpkg/packages"
|
||||
WORK_DIR="/var/cache/scratchpkg/work"
|
||||
DOWNLOAD_PROG="wget"
|
||||
DOWNLOAD_PROG="auto"
|
||||
COMPRESSION_MODE="xz"
|
||||
|
||||
OPTIONS="!libtool emptydirs strip zipman buildflags makeflags checksum"
|
||||
OPTIONS="!libtool emptydirs strip zipman buildflags makeflags checksum !docs !locales"
|
||||
|
||||
INCLUDEINPKG="install readme mkdirs"
|
||||
|
||||
|
||||
84
pkgdel
84
pkgdel
@@ -74,7 +74,7 @@ extract_opts() {
|
||||
echo $opts
|
||||
}
|
||||
|
||||
parse_opts() {
|
||||
parse_opts() {
|
||||
if [ -z "$1" ]; then
|
||||
SHOWHELP=yes
|
||||
else
|
||||
@@ -83,62 +83,64 @@ parse_opts() {
|
||||
-h | --help) SHOWHELP=yes ;;
|
||||
-v | --verbose) VERBOSE_REMOVE="-v" ;;
|
||||
--no-preremove) NO_PREREMOVE=yes ;;
|
||||
--no-postremove) NO_POSTREMOVE=yes ;;
|
||||
--root=*) ROOT_DIR="${1#*=}" ;;
|
||||
-*) msg "Invalid option: ($1)"; exit 1 ;;
|
||||
*) RMNAME=$1 ;;
|
||||
--no-postremove) NO_POSTREMOVE=yes ;;
|
||||
--root=*) ROOT_DIR="${1#*=}" ;;
|
||||
-*) msg "Invalid option: ($1)"; exit 1 ;;
|
||||
*) RMNAME=$1 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
ret() {
|
||||
# remove lock file on exit
|
||||
rm -f "$LOCK_FILE" "$reserve" "$dirs" "$remove" "$files"
|
||||
rm -f "$ROOT_DIR/$LOCK_FILE" "$reserve" "$dirs" "$remove" "$files"
|
||||
exit $1
|
||||
}
|
||||
|
||||
isinstalled() {
|
||||
if [ -s "$INDEX_DIR/$1/.pkginfo" ] && grep -q "$1" "$INDEX_DIR/$1/.pkginfo"; then
|
||||
if [ -s "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo" ] && grep -q "$1" "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo"; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
run_scripts() {
|
||||
if [ "$ROOT_DIR" ]; then
|
||||
xchroot "$ROOT_DIR" sh $@
|
||||
else
|
||||
sh $@
|
||||
fi
|
||||
}
|
||||
|
||||
parse_opts $(extract_opts "$@")
|
||||
|
||||
INDEX_DIR="$ROOT_DIR/var/lib/scratchpkg/index"
|
||||
LOCK_FILE="$ROOT_DIR/var/lib/scratchpkg/spkg.lock"
|
||||
INDEX_DIR="var/lib/scratchpkg/index"
|
||||
LOCK_FILE="var/lib/scratchpkg/spkg.lock"
|
||||
|
||||
# disable pre/post remove script when remove from custom root location
|
||||
if [ "$ROOT_DIR" != "" ]; then
|
||||
NO_PREREMOVE=yes
|
||||
NO_POSTREMOVE=yes
|
||||
fi
|
||||
|
||||
# show help page
|
||||
[ "$SHOWHELP" ] || [ -z "$RMNAME" ] && {
|
||||
help
|
||||
ret 0
|
||||
}
|
||||
|
||||
# check for root access, non-root only allowed if use custom --root= location
|
||||
[ "$(id -u)" = "0" ] || [ "$ROOT_DIR" ] || {
|
||||
# check for root access
|
||||
[ "$(id -u)" = "0" ] || {
|
||||
echo "Removing package need root access!"
|
||||
ret 1
|
||||
}
|
||||
|
||||
# check for lock file
|
||||
[ -f "$LOCK_FILE" ] && {
|
||||
[ -f "$ROOT_DIR/$LOCK_FILE" ] && {
|
||||
msgerr "Cant install/remove package simultaneously."
|
||||
msgerr "remove '$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 "$LOCK_FILE" 2>/dev/null || {
|
||||
msgerr "Cant create lock file in '$LOCK_FILE'"
|
||||
touch "$ROOT_DIR/$LOCK_FILE" 2>/dev/null || {
|
||||
msgerr "Cant create lock file in '$ROOT_DIR/$LOCK_FILE'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -147,32 +149,36 @@ if ! isinstalled "$RMNAME"; then
|
||||
ret 1
|
||||
fi
|
||||
|
||||
name=$(grep ^name $INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
|
||||
version=$(grep ^version $INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
|
||||
release=$(grep ^release $INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
|
||||
name=$(grep ^name $ROOT_DIR/$INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
|
||||
version=$(grep ^version $ROOT_DIR/$INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
|
||||
release=$(grep ^release $ROOT_DIR/$INDEX_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."
|
||||
ret 1
|
||||
fi
|
||||
|
||||
# create list for reserve and remove (dirs and files)
|
||||
reserve="/tmp/.pkgdel_reserve.$$"
|
||||
remove="/tmp/.pkgdel_remove.$$"
|
||||
dirs="/tmp/.pkgdel_dirs.$$"
|
||||
files="/tmp/.pkgdel_files.$$"
|
||||
reserve="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_reserve"
|
||||
remove="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_remove"
|
||||
dirs="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_dirs"
|
||||
files="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_files"
|
||||
|
||||
grep '/$' $INDEX_DIR/*/.files | grep -v "$INDEX_DIR/$name" | awk -F : '{print $2}' | sort | uniq > "$reserve"
|
||||
grep '/$' "$INDEX_DIR/$name/.files" > "$remove"
|
||||
grep '/$' $ROOT_DIR/$INDEX_DIR/*/.files \
|
||||
| grep -v "$ROOT_DIR/$INDEX_DIR/$name" \
|
||||
| awk -F : '{print $2}' \
|
||||
| sort \
|
||||
| uniq > "$reserve"
|
||||
grep '/$' "$ROOT_DIR/$INDEX_DIR/$name/.files" > "$remove"
|
||||
grep -Fxv -f "$reserve" "$remove" | tac > "$dirs"
|
||||
grep -v '/$' "$INDEX_DIR/$name/.files" | tac >> "$files"
|
||||
grep -v '/$' "$ROOT_DIR/$INDEX_DIR/$name/.files" | tac >> "$files"
|
||||
|
||||
echo "remove: $name-$version-$release..."
|
||||
|
||||
# pre-remove script
|
||||
if [ ! "$NO_PREREMOVE" ] && [ -f "$INDEX_DIR/$name/.pkginstall" ]; then
|
||||
if [ ! "$NO_PREREMOVE" ] && [ -f "$ROOT_DIR/$INDEX_DIR/$name/.pkginstall" ]; then
|
||||
(cd "$ROOT_DIR"/
|
||||
sh "$INDEX_DIR/$name/.pkginstall" pre-remove "$version"
|
||||
run_scripts "$INDEX_DIR/$name/.pkginstall" pre-remove "$version"
|
||||
)
|
||||
fi
|
||||
|
||||
@@ -184,15 +190,15 @@ fi
|
||||
|
||||
rm -f "$reserve" "$dirs" "$remove" "$files"
|
||||
|
||||
# post-remove script
|
||||
if [ ! "$NO_POSTREMOVE" ] && [ -f "$INDEX_DIR/$name/.pkginstall" ]; then
|
||||
# post-remove script
|
||||
if [ ! "$NO_POSTREMOVE" ] && [ -f "$ROOT_DIR/$INDEX_DIR/$name/.pkginstall" ]; then
|
||||
(cd "$ROOT_DIR"/
|
||||
sh "$INDEX_DIR/$name/.pkginstall" post-remove "$version"
|
||||
run_scripts "$INDEX_DIR/$name/.pkginstall" post-remove "$version"
|
||||
)
|
||||
fi
|
||||
|
||||
# remove from database
|
||||
rm -rf "$INDEX_DIR/$name"
|
||||
rm -rf "$ROOT_DIR/$INDEX_DIR/$name"
|
||||
|
||||
# running ldconfig
|
||||
if [ -x "$ROOT_DIR"/sbin/ldconfig ]; then
|
||||
|
||||
55
pkgdepends
Executable file
55
pkgdepends
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# script to check 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
|
||||
140
pkgfix
Executable file
140
pkgfix
Executable file
@@ -0,0 +1,140 @@
|
||||
#!/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 && scratch install -r $p || exit 1
|
||||
done
|
||||
else
|
||||
echo "Broken packages:"
|
||||
for p in $order; do
|
||||
echo " $p"
|
||||
done
|
||||
fi
|
||||
|
||||
exit 0
|
||||
325
pkgquery
325
pkgquery
@@ -18,327 +18,6 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
msg() {
|
||||
echo "==> $1"
|
||||
}
|
||||
echo "*** ${0##*/} is deprecated, please use 'scratch' instead ***"
|
||||
|
||||
msgerr() {
|
||||
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
|
||||
}
|
||||
|
||||
getdepends() {
|
||||
ppath=$(getportpath $1) || return 0
|
||||
grep "^# depends[[:blank:]]*:" $ppath/$BUILD_SCRIPT \
|
||||
| sed 's/^# depends[[:blank:]]*:[[:blank:]]*//' \
|
||||
| tr ' ' '\n' \
|
||||
| awk '!a[$0]++' \
|
||||
| sed 's/,//'
|
||||
}
|
||||
|
||||
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"
|
||||
|
||||
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 $?
|
||||
exit 0
|
||||
|
||||
33
pkgrebuild
Executable file
33
pkgrebuild
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# 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
|
||||
48
portcreate
Executable file
48
portcreate
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/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 :
|
||||
# homepage :
|
||||
# maintainer :
|
||||
# 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
|
||||
407
scratch
407
scratch
@@ -99,13 +99,31 @@ allinstalled() {
|
||||
grep ^name "$INDEX_DIR"/*/.pkginfo | awk '{print $3}'
|
||||
}
|
||||
|
||||
deps_alias() {
|
||||
[ -f "$ALIAS_FILE" ] || {
|
||||
echo $@
|
||||
return
|
||||
}
|
||||
while [ "$1" ]; do
|
||||
if [ "$(grep -w ^$1 $ALIAS_FILE)" ]; then
|
||||
getalias=$(grep -w ^$1 $ALIAS_FILE | awk '{print $2}')
|
||||
[ "$getalias" ] && echo "$getalias"
|
||||
else
|
||||
echo "$1"
|
||||
fi
|
||||
shift
|
||||
unset getalias
|
||||
done
|
||||
}
|
||||
|
||||
get_depends() {
|
||||
ppath=$(getportpath $1) || return 0
|
||||
grep "^# depends[[:blank:]]*:" $ppath/$BUILD_SCRIPT \
|
||||
deps=$(grep "^# depends[[:blank:]]*:" $ppath/$BUILD_SCRIPT \
|
||||
| sed 's/^# depends[[:blank:]]*:[[:blank:]]*//' \
|
||||
| tr ' ' '\n' \
|
||||
| awk '!a[$0]++' \
|
||||
| sed 's/,//'
|
||||
| sed 's/,//')
|
||||
deps_alias $deps
|
||||
}
|
||||
|
||||
confirm() {
|
||||
@@ -119,7 +137,7 @@ confirm() {
|
||||
}
|
||||
|
||||
checktool() {
|
||||
if ! type -p $1 >/dev/null; then
|
||||
if ! command -v $1 >/dev/null; then
|
||||
msgerr "'$1' not exist in your system!"
|
||||
exit 1
|
||||
fi
|
||||
@@ -192,6 +210,13 @@ scratch_lock() {
|
||||
done
|
||||
}
|
||||
|
||||
scratch_locate() {
|
||||
needarg $@
|
||||
for repo in $PORT_REPO; do
|
||||
grep -R $@ $repo/*/.pkgfiles | sed 's/:/ /;s/\/\.pkgfiles//' | awk '{print $1,$4}' | column -t
|
||||
done
|
||||
}
|
||||
|
||||
scratch_unlock() {
|
||||
needroot "Unlocking package"
|
||||
for pkg in "$@"; do
|
||||
@@ -272,37 +297,37 @@ post_triggers() {
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$trig_11" = 1 ] && [ $(type -p fc-cache) ]; then
|
||||
if [ "$trig_11" = 1 ] && [ $(command -v fc-cache) ]; then
|
||||
echo "trigger: Updating fontconfig cache..."
|
||||
fc-cache -s
|
||||
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..."
|
||||
gdk-pixbuf-query-loaders --update-cache
|
||||
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..."
|
||||
gio-querymodules /usr/lib/gio/modules
|
||||
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..."
|
||||
glib-compile-schemas /usr/share/glib-2.0/schemas
|
||||
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..."
|
||||
gtk-query-immodules-2.0 --update-cache
|
||||
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..."
|
||||
gtk-query-immodules-3.0 --update-cache
|
||||
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..."
|
||||
for dir in /usr/share/icons/* ; do
|
||||
if [ -e $dir/index.theme ]; then
|
||||
@@ -314,12 +339,12 @@ post_triggers() {
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$trig_4" = 1 ] && [ $(type -p udevadm) ]; then
|
||||
if [ "$trig_4" = 1 ] && [ $(command -v udevadm) ]; then
|
||||
echo "trigger: Updating hardware database..."
|
||||
udevadm hwdb --update
|
||||
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..."
|
||||
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
|
||||
@@ -330,12 +355,12 @@ post_triggers() {
|
||||
done
|
||||
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..."
|
||||
update-desktop-database --quiet
|
||||
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..."
|
||||
update-mime-database /usr/share/mime
|
||||
fi
|
||||
@@ -783,78 +808,79 @@ scratch_upgrade() {
|
||||
}
|
||||
for pkg in $PKGNAME; do
|
||||
if ! isinstalled $pkg; then
|
||||
msgerr "Package '$pkg' not installed."
|
||||
echo "Package '$pkg' not installed."
|
||||
continue
|
||||
elif [ ! $(getportpath $pkg) ]; then
|
||||
msgerr "Package '$pkg' not exist."
|
||||
echo "Package '$pkg' not exist."
|
||||
continue
|
||||
else
|
||||
. $(getportpath $pkg)/$BUILD_SCRIPT
|
||||
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
|
||||
fi
|
||||
fi
|
||||
upkg="$upkg $pkg"
|
||||
done
|
||||
[ "$upkg" ] || return 0
|
||||
[ "$NO_DEP" ] || {
|
||||
|
||||
UPGPKG=0
|
||||
NEWPKG=0
|
||||
if [ "$NODEP" != 1 ]; then
|
||||
echo "Resolving dependencies..."
|
||||
DEP=$(scratch_deplist $upkg $EXOPT | awk '{print $2}')
|
||||
for dep in $DEP; do
|
||||
if ! isinstalled $dep; then
|
||||
[ "$(getportpath $dep)" ] && newpkg="$newpkg $dep"
|
||||
echo
|
||||
for d in $DEP; do
|
||||
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
|
||||
done
|
||||
}
|
||||
echo
|
||||
tnew=0
|
||||
tup=0
|
||||
for i in $newpkg; do
|
||||
tnew=$(( tnew + 1 ))
|
||||
printf "[${CYAN}n${CRESET}] $i "
|
||||
done
|
||||
for i in $upkg; do
|
||||
tup=$(( tup + 1 ))
|
||||
printf "[${GREEN}u${CRESET}] $i "
|
||||
done
|
||||
else
|
||||
echo
|
||||
for dd in $upkg; do
|
||||
printf "[${GREEN}u${CRESET}] $dd "
|
||||
WILLINSTALL="$WILLINSTALL $dd"
|
||||
UPGPKG=$(( UPGPKG + 1 ))
|
||||
done
|
||||
fi
|
||||
echo; echo
|
||||
echo "( $tup upgrade, $tnew new install )"
|
||||
echo "( $UPGPKG upgrade, $NEWPKG new install )"
|
||||
echo
|
||||
[ "$NOCONFIRM" ] || {
|
||||
confirm "Continue upgrade/install these package(s)?" "Package upgrade cancelled." || exit $?
|
||||
echo
|
||||
}
|
||||
total=$(( tup + tnew ))
|
||||
count=0
|
||||
error=0
|
||||
if [ "$newpkg" ]; then
|
||||
for pkg in $newpkg; do
|
||||
count=$(( count + 1 ))
|
||||
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=0
|
||||
total=$(echo $WILLINSTALL | wc -w)
|
||||
for inst in $WILLINSTALL; do # install all required dependencies and target packages itself
|
||||
count=$(( count + 1 ))
|
||||
cd $(getportpath $pkg)
|
||||
settermtitle "[ $count/$total ] Upgrading $pkg..."
|
||||
cd $(getportpath $inst)
|
||||
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 || {
|
||||
error=1
|
||||
count=$(( count - 1 ))
|
||||
break
|
||||
}
|
||||
done_pkg="$done_pkg $pkg"
|
||||
fi
|
||||
cd - >/dev/null
|
||||
done_pkg="$done_pkg $inst"
|
||||
done
|
||||
settermtitle "triggering upgrade hook..."
|
||||
settermtitle "Triggering install hook."
|
||||
[ "$done_pkg" ] && scratch_trigger $done_pkg
|
||||
settermtitle "$count/$total package(s) upgraded."
|
||||
return "$error"
|
||||
@@ -1116,6 +1142,189 @@ deplist() {
|
||||
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:]]*//')
|
||||
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' ' ')
|
||||
|
||||
echo "Name: $1"
|
||||
echo "Path: $ppath"
|
||||
echo "Version: $version"
|
||||
echo "Release: $release"
|
||||
echo "Description: $desc"
|
||||
echo "Homepage: $url"
|
||||
echo "Maintainer: $maint"
|
||||
echo "Dependencies: $deps"
|
||||
}
|
||||
|
||||
scratch_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
|
||||
}
|
||||
|
||||
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 "$INDEX_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" $INDEX_DIR/*/.files \
|
||||
| sed "s:$INDEX_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 "$INDEX_DIR/$1/.files"
|
||||
else
|
||||
msg "Package '$1' not installed."
|
||||
fi
|
||||
}
|
||||
|
||||
scratch_help() {
|
||||
cat << EOF
|
||||
Usage:
|
||||
@@ -1127,40 +1336,57 @@ Options:
|
||||
-n|--no-dep skip dependencies
|
||||
-y|--yes skip ask user permission
|
||||
--exclude=* exclude dependencies, comma separated
|
||||
|
||||
|
||||
upgrade <ports> <arg> upgrade ports (use pkgbuild arg, except '-i' & '-r')
|
||||
-n|--no-dep skip dependencies
|
||||
-y|--yes skip ask user permission
|
||||
--exclude=* exclude dependencies, comma separated
|
||||
|
||||
|
||||
remove <ports> <arg> remove installed ports (use pkgdel arg)
|
||||
-y|--yes skip ask user permission
|
||||
|
||||
|
||||
sysup <arg> full system upgrade (use pkgbuild arg, except '-i', '-r' & '-u')
|
||||
-n|--no-dep skip dependencies
|
||||
-y|--yes skip ask user permission
|
||||
--exclude=* exclude dependencies, comma separated
|
||||
|
||||
|
||||
deplist <ports> print all dependencies for ports
|
||||
-q|--quick skip installed ports
|
||||
--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
|
||||
unlock <ports> unlock locked ports
|
||||
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
|
||||
search <pattern> find ports in repo
|
||||
outdate print outdated ports
|
||||
cache print and clear old pkg and src caches
|
||||
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
|
||||
|
||||
|
||||
Global options:
|
||||
--repo=<repo path> add custom repo path
|
||||
--nocolor disable colour for output
|
||||
|
||||
--append-repo=<repo path> append custom repo path
|
||||
--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
|
||||
}
|
||||
|
||||
@@ -1169,45 +1395,48 @@ print_runhelp_msg() {
|
||||
exit 2
|
||||
}
|
||||
|
||||
BUILD_SCRIPT="spkgbuild"
|
||||
INDEX_DIR="/var/lib/scratchpkg/index"
|
||||
REPO_FILE="/etc/scratchpkg.repo"
|
||||
|
||||
# default value from pkgbuild
|
||||
SOURCE_DIR="/var/cache/scratchpkg/sources"
|
||||
PACKAGE_DIR="/var/cache/scratchpkg/packages"
|
||||
COMPRESSION_MODE="xz"
|
||||
|
||||
mode=$1
|
||||
|
||||
if [ -z "$mode" ]; then
|
||||
[ "$mode" ] || {
|
||||
print_runhelp_msg
|
||||
fi
|
||||
}
|
||||
|
||||
shift
|
||||
|
||||
for opt in $@; do
|
||||
case $opt in
|
||||
--nocolor) nocolor;;
|
||||
--repo=*) PORT_REPO="$PORT_REPO ${opt#*=}";;
|
||||
--*) MAINOPTS="$MAINOPTS $opt";;
|
||||
-*) char=${#opt}; count=1
|
||||
while [ "$count" != "$char" ]; do
|
||||
count=$((count+1))
|
||||
MAINOPTS="$MAINOPTS -$(echo $opt | cut -c $count)"
|
||||
done;;
|
||||
*) MAINOPTS="$MAINOPTS $opt";;
|
||||
--nocolor) nocolor;;
|
||||
--repo=*) PORT_REPO="$PORT_REPO ${opt#*=}";;
|
||||
--repo-file=*) REPO_FILE="${opt#*=}";;
|
||||
--alias-file=*) ALIAS_FILE="${opt#*=}";;
|
||||
--*) MAINOPTS="$MAINOPTS $opt";;
|
||||
-*) char=${#opt}; count=1
|
||||
while [ "$count" != "$char" ]; do
|
||||
count=$((count+1))
|
||||
MAINOPTS="$MAINOPTS -$(printf '%s' $opt | cut -c $count)"
|
||||
done;;
|
||||
*) MAINOPTS="$MAINOPTS $opt";;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
BUILD_SCRIPT="spkgbuild"
|
||||
INDEX_DIR="/var/lib/scratchpkg/index"
|
||||
REPO_FILE="${REPO_FILE:-/etc/scratchpkg.repo}"
|
||||
ALIAS_FILE="${ALIAS_FILE:-/etc/scratchpkg.alias}"
|
||||
|
||||
# default value from pkgbuild
|
||||
SOURCE_DIR="/var/cache/scratchpkg/sources"
|
||||
PACKAGE_DIR="/var/cache/scratchpkg/packages"
|
||||
COMPRESSION_MODE="xz"
|
||||
|
||||
if [ -f "$REPO_FILE" ]; then
|
||||
for repodir in $(grep -Ev '^(#|$)' "$REPO_FILE" | awk '{print $1}'); do
|
||||
PORT_REPO="$PORT_REPO $repodir"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$(type -t scratch_$mode)" = "function" ]; then
|
||||
if [ "$(command -v scratch_$mode)" ]; then
|
||||
scratch_$mode $MAINOPTS
|
||||
else
|
||||
print_runhelp_msg
|
||||
|
||||
9
scratchpkg.alias
Normal file
9
scratchpkg.alias
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# /etc/scratchpkg.alias : scratchpkg alias file
|
||||
#
|
||||
# format:
|
||||
# <real package> <aliased package>
|
||||
#
|
||||
# example:
|
||||
# openssl libressl
|
||||
#
|
||||
@@ -9,7 +9,7 @@ MAKEFLAGS="-j$(nproc)"
|
||||
# SOURCE_DIR="/var/cache/scratchpkg/sources"
|
||||
# PACKAGE_DIR="/var/cache/scratchpkg/packages"
|
||||
# WORK_DIR="/var/cache/scratchpkg/work"
|
||||
# DOWNLOAD_PROG="wget"
|
||||
# DOWNLOAD_PROG="auto"
|
||||
# WGET_OPTS=""
|
||||
# CURL_OPTS=""
|
||||
# COMPRESSION_MODE="xz"
|
||||
@@ -24,8 +24,10 @@ MAKEFLAGS="-j$(nproc)"
|
||||
# -- buildflags: Enable buildflags (CFLAGS and CXXFLAGS)
|
||||
# -- makeflags: Enable makeflags (MAKEFLAGS)
|
||||
# -- checksum: Enable checking checksum
|
||||
# -- docs: Keep docs
|
||||
# -- locales: Keep locales
|
||||
#
|
||||
# -- These are default values for the options="" settings
|
||||
# -- add '!' in front of this option to disable it
|
||||
#
|
||||
# OPTIONS="!libtool emptydirs strip zipman buildflags makeflags checksum"
|
||||
# OPTIONS="!libtool emptydirs strip zipman buildflags makeflags checksum !docs !locales"
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
EDITOR=${EDITOR:-vi}
|
||||
|
||||
type -p $EDITOR >/dev/null || {
|
||||
echo "Editor '$EDITOR' not exist..."
|
||||
command -v $EDITOR >/dev/null || {
|
||||
echo "Editor '$EDITOR' not exist. Append 'EDITOR=<your editor>' to ${0##*/}."
|
||||
exit 2
|
||||
}
|
||||
|
||||
|
||||
100
xchroot
Executable file
100
xchroot
Executable file
@@ -0,0 +1,100 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# script to enter chroot
|
||||
#
|
||||
|
||||
printhelp() {
|
||||
cat << EOF
|
||||
|
||||
Usage:
|
||||
$(basename $0) <chroot-dir> [command]
|
||||
|
||||
If 'command' is unspecified, ${0##*/} will launch /bin/sh.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
msgerr() {
|
||||
echo "ERROR: $*"
|
||||
}
|
||||
|
||||
unmount() {
|
||||
while true; do
|
||||
mountpoint -q $1 || break
|
||||
umount $1 2>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
[ "$(id -u)" = "0" ] || {
|
||||
msgerr "$(basename $0) need root access!"
|
||||
printhelp
|
||||
exit 1
|
||||
}
|
||||
|
||||
TARGET=$1
|
||||
|
||||
[ "$1" ] || {
|
||||
msgerr "Please set directory for chroot!"
|
||||
printhelp
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -d "$TARGET" ] || {
|
||||
msgerr "Directory '$TARGET' not exist!"
|
||||
printhelp
|
||||
exit 1
|
||||
}
|
||||
|
||||
shift
|
||||
|
||||
if [ ! "$1" ]; then
|
||||
CMD="/bin/sh"
|
||||
else
|
||||
CMD=$*
|
||||
fi
|
||||
|
||||
if [ -e /sys/firmware/efi/systab ]; then
|
||||
EFI_SYSTEM=1
|
||||
fi
|
||||
|
||||
mount --bind /dev $TARGET/dev
|
||||
mount -t devpts devpts $TARGET/dev/pts -o gid=5,mode=620
|
||||
mount -t proc proc $TARGET/proc
|
||||
mount -t sysfs sysfs $TARGET/sys
|
||||
if [ -n "$EFI_SYSTEM" ]; then
|
||||
mount --bind /sys/firmware/efi/efivars $TARGET/sys/firmware/efi/efivars
|
||||
fi
|
||||
mount -t tmpfs tmpfs $TARGET/run
|
||||
|
||||
if [ -h $TARGET/dev/shm ]; then
|
||||
mkdir -p $TARGET/$(readlink $TARGET/dev/shm)
|
||||
fi
|
||||
|
||||
[ -f $TARGET/etc/resolv.conf ] && {
|
||||
backupresolvconf=1
|
||||
mv $TARGET/etc/resolv.conf $TARGET/etc/resolv.conf.tmp
|
||||
}
|
||||
cp -L /etc/resolv.conf $TARGET/etc
|
||||
|
||||
chroot "$TARGET" /usr/bin/env -i \
|
||||
HOME=/root \
|
||||
TERM="$TERM" \
|
||||
PS1='\u:\w\$ ' \
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin $CMD
|
||||
|
||||
retval=$?
|
||||
|
||||
[ "$backupresolvconf" = 1 ] && {
|
||||
mv $TARGET/etc/resolv.conf.tmp $TARGET/etc/resolv.conf
|
||||
}
|
||||
|
||||
unmount $TARGET/dev/pts
|
||||
unmount $TARGET/dev
|
||||
unmount $TARGET/run
|
||||
unmount $TARGET/proc
|
||||
if [ -n "$EFI_SYSTEM" ]; then
|
||||
unmount $TARGET/sys/firmware/efi/efivars
|
||||
fi
|
||||
unmount $TARGET/sys
|
||||
|
||||
exit $retval
|
||||
Reference in New Issue
Block a user