28 Commits

Author SHA1 Message Date
emmett1
d848402f95 fix pkgbuild 2023-03-26 18:03:38 +08:00
Emmett1
8c0c7b888c Merge pull request #37 from lumarogit/miup 2023-03-23 22:07:37 +08:00
Luis
af9d283eb4 minors updates 2023-03-23 13:03:59 +00:00
Emmett1
4e5a7573a6 Merge pull request #36 from lumarogit/readme 2023-03-23 14:31:13 +08:00
Luis
fb3406dc2d minors fixes 2023-03-22 09:35:45 +00:00
Luis
a12f8bf6e1 remove old help of pkgbuild 2023-03-22 09:26:57 +00:00
Luis
f41c087103 Update README file 2023-03-22 09:18:33 +00:00
Emmett1
b831ff55fd Merge pull request #35 from lumarogit/scratchpkg-up-first 2023-03-22 16:39:52 +08:00
Luis
a47859bcea scratch: fix upgrade scratchpkg first 2023-03-22 08:28:53 +00:00
Emmett1
20ac214cfa Merge pull request #33 from lumarogit/depth1 2023-03-14 22:45:26 +08:00
Luis
642e4aff85 portsync: clone faster adding depth 1 2023-03-14 06:55:18 +00:00
Emmett1
f481b9a025 Merge pull request #32 from lumarogit/toolchain 2023-03-12 11:24:38 +08:00
Luis
8d3d767ab6 pkgrebuild: update toolchain maintenance 2023-03-09 15:23:02 +00:00
emmett1
fdc5578ecd cleaup 2022-12-25 23:13:06 +08:00
emmett1
3b8d9a95b3 updates for scratch purge 2022-12-25 00:05:34 +08:00
emmett1
1324ed620c fix some small mess 2022-12-24 23:30:13 +08:00
emmett1
435209beb2 added -y opt to scratch_purge 2022-12-24 22:58:00 +08:00
emmett1
ee33aaa213 release allowed only number between 1 to 99 2022-12-24 22:02:33 +08:00
emmett1
1871acc25b added XZ_DEFAULTS to xz compressing in pkgbuild 2022-12-24 00:27:39 +08:00
emmett1
96e06ffc66 added scratch_purge 2022-12-23 23:47:29 +08:00
emmett1
ce703e988f update sysup, install, upgrade, remove & outdate 2022-12-23 22:32:45 +08:00
emmett1
a4d1ced5a0 fix scratch_search 2022-12-17 06:57:53 +08:00
emmett1
5c91ed92d5 fix scratch_search when only single port exist in repo 2022-12-07 21:25:34 +08:00
emmett1
fd39044819 only scratch_world print msg 2022-12-07 21:21:21 +08:00
emmett1
c80c3d42cf fix scratch outdate 2022-11-01 00:30:15 +08:00
emmett1
2a3393f1e2 Merge branch 'master' of https://github.com/venomlinux/scratchpkg 2022-09-18 00:19:17 +08:00
emmett1
aba826141c fix conflict check 2022-09-18 00:18:22 +08:00
Emmett1
14271ec0fd Merge pull request #29 from venomlinux/new-world-option
added scratch world option
2022-08-13 21:59:37 +08:00
8 changed files with 336 additions and 284 deletions

190
README.md
View File

@@ -86,14 +86,16 @@ Available options:
zipman: Compress manual (man and info) pages with gzip.
buildflags: Enable buildflags (CFLAGS and CXXFLAGS).
makeflags: Enable makeflags (MAKEFLAGS).
checksum: Enable checking checksum.
### pkgbuild
`pkgbuild` is a tool to build package from ports. Is will source `spkgbuild` to get build information before creating package. Package is created into `<name>-<version>-<release>.spkg.txz` format. To build package, you need `cd` into port directory before run `pkgbuild` command.
`pkgbuild` is a tool to build package from ports. Is will source `spkgbuild` to get build information before creating package. Package is created into `<name>-<version>-<release>.spkg.xz` format. To build package, you need `cd` into port directory before run `pkgbuild` command.
Usage:
pkgbuild [ <options> <arguments> ]
Options:
-q --quiet show only status messages and errors
-i, --install install package into system
-u, --upgrade upgrade package
-r, --reinstall reinstall package
@@ -104,23 +106,19 @@ Available options:
-g, --genmdsum generate md5sum
-o, --download download only source file
-x, --extract extract only source file
-p, --pkgfiles generate list files in package
-w, --keep-work keep working directory
-l, --log log build process
-h, --help show this help message
--clean remove downloaded sources and prebuilt packages
--config=<config> use custom config file
--srcdir=<path> override directory path for sources
--pkgdir=<path> override directory path for compiled package
--logdir=<path> override directory path for build logs
--workdir=<path> override directory path for working dir
--no-preinstall skip preinstall script before install package
--no-postinstall skip postinstall script after install package
--no-preupgrade skip preupgrade script before upgrade package
--no-postupgrade skip postupgrade script after upgrade package
--no-backup skip backup configuration file when upgrading package
--redownload re-download source file
Example:
pkgbuild -iw this will build, install package and keep working directory
pkgbuild -iw this will build, install package and keep working directory
Note:
* use pkgbuild without any options will only download source and build package by using other default options
@@ -129,12 +127,12 @@ Available options:
### pkgadd
`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 `PKGDB_DIR`.
`<name>-<version>-<release>.spkg.xz` 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
package and remove old file which not exist in new package (like Slackware pkgtool does).
Usage:
pkgadd package.spkg.txz <options>
pkgadd [ <options> <package.spkg.txz> ]
Options:
-u, --upgrade upgrade package
@@ -142,16 +140,13 @@ package and remove old file which not exist in new package (like Slackware pkgto
-c, --ignore-conflict ignore conflict when installing package
-v, --verbose print files installed
-h, --help show this help message
--no-preinstall skip preinstall script before build/install package
--no-postinstall skip postinstall script after install package
--no-preupgrade skip preupgrade script before upgrade package
--no-postupgrade skip postupgrade script after upgrade package
--no-backup skip backup when upgrading package
--root=<path> install to custom root directory
--print-dbdir print package database path
--root=<path> install to custom root directory
Example:
pkgadd foobar-1.0-1.spkg.txz -uc --no-backup upgrade package foobar-1.0-1 without backup its
old configuration files and skip conflict check
pkgadd foobar-1.0-1.spkg.txz -uc --no-backup upgrade package foobar-1.0-1 without backup its
old configuration files and skip conflict check
### pkgdel
`pkgdel` is a tool to remove package from system. It will read file listed in package `PKGDB_DIR` and remove it.
@@ -162,8 +157,6 @@ package and remove old file which not exist in new package (like Slackware pkgto
Options:
-h, --help show this help message
-v, --verbose print removed files
--no-preremove don't run pre-remove script
--no-postremove don't run post-remove script
--root=<path> remove package from custom root directory
Example:
@@ -175,78 +168,74 @@ pkgadd to install package into system. Its also has some extra functions like se
orphan package, duplicate ports, list installed package and etc. Run `scratch help` to see available functions.
Usage:
scratch [ mode ] [ <pkgname> <options> ]
scratch <options> [<arg>]
Options:
install <ports> <arg> install ports (use pkgbuild arg, except '-i' & '-u')
-r reinstall
-n skip dependencies
-y skip ask user confirmation
-o fetch sources only
--exclude=* exclude dependencies, comma separated
mode:
install <packages> install packages and its dependencies
upgrade <packages> upgrade packages and install new dependencies (if any)
build <package> build only packages
remove <packages> remove packages in system
depends <package> show depends of a package
deplist <packages> show list dependencies of a package
search <pattern> search packages in port's repos
lock <packages> lock packages from upgrade
unlock <packages> unlock packages from upgrade
listport <repo> list ports of a repo
cat <package> view a package build scripts
dependent <package> show package's dependent
own <file> show package's owner of file
pkgtree <package> show list files of installed package
path <package> show package's buildscripts path
sync update port's repo
sysup full system update
dup print duplicate ports in repo
readme print readme file if exist
listinst list installed package in system
listorphan list orphan package
integrity check integrity of package's files
outdate check for outdate packages
cache print leftover cache
rmcache remove leftover cache
missingdep check for mising dependency of installed package
foreignpkg print package installed without port in repo
listlocked print locked packages
help print this help message
options for:
build
-f, --force-rebuild force rebuild
-m, --skip-mdsum skip md5sum check for sources
-d, --no-dep skip dependency check
-e, --extract extract only
-w, --keep-work keep woring directory
-o, --download download source files only
--redownload re-download source files
--srcdir=<path> override default SOURCE_DIR
--pkgdir=<path> override default PACKAGE_DIR
--no-preinstall skip pre-install script
install
-d, --no-dep skip installing dependencies
-c, --ignore-conflict skip file conflict check
-r, --reinstall reinstall installed package
-v, --verbose print install process
--no-preinstall skip pre-install script
--no-postinstall skip post-install script
upgrade
-d, --no-dep skip installing dependencies (new dependencies)
-c, --ignore-conflict skip file conflict check
-v, --verbose print install process
--no-backup skip backup configuration file
--no-preupgrade skip pre-upgrade script
--no-postupgrade skip post-upgrade script
remove
-d, --no-dep skip dependency check
-v, --verbose print removed files
--no-preremove skip pre-remove script
--no-postremove skip post-remove script
global options:
--no-color disable colour for output
--debug debug scratch script
upgrade <ports> <arg> upgrade ports (use pkgbuild arg, except '-i' & '-r')
-n skip dependencies
-y skip ask user confirmation
-o fetch sources only
--exclude=* exclude dependencies, comma separated
remove <ports> <arg> remove installed ports (use pkgdel arg)
-y skip ask user confirmation
sysup <arg> full system upgrade (use pkgbuild arg, except '-i', '-r' & '-u')
-n skip dependencies
-y skip ask user confirmation
-o fetch sources only
--exclude=* exclude dependencies, comma separated
deplist <ports> print all dependencies for ports
-q skip installed ports
--exclude=* exclude dependencies, comma separated
build <ports> <arg> build ports (use pkgbuild arg, except '-i', '-u', '-r', '-g', & '-p')
--log log build process (/var/log/pkgbuild.log)
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 <file> print port's provided file
readme <port> print readme file, if exist
files <port> print files installed
info <port> print information
locate <file> print location of file in ports repo
isinstalled <port> check whether port is installed (status 0=installed, 1=not installed)
purge [ports] remove installed ports and its orphan dependencies
world [ports] print/add/remove world list
sync update ports database
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
missingdep print missing dependencies
orphan print orphan installed ports
foreign print foreign ports
printconfig <opts> print scratchpkg configs
help print this help msg
Global options:
--append-repo=<repo path> append custom local repo path (can use multiple times)
--prepend-repo=<repo path> prepend custom local repo path (can use multiple times)
--override-repo=<repo path> override repo in /etc/scratchpkg.repo with custom local repo (can use multiple times)
--repo-file=<repo file> use custom repo file (default: /etc/scratchpkg.repo)
--config-file=<config file> use custom config file (default: /etc/scratchpkg.conf)
--alias-file=<alias file> use custom alias file (default: /etc/scratchpkg.alias)
--mask-file=<mask file> use custom mask file (default: /etc/scratchpkg.mask)
--nocolor disable colour for output
Example:
scratch install firefox gvfs -cv build and install required dependencies and target package itself,
ignore file conflict check and be verbose.
@@ -258,8 +247,8 @@ orphan package, duplicate ports, list installed package and etc. Run `scratch he
Extra tools is some scripts come with scratchpkg to help users do things more easier. More extra scripts may added from time to
time.
* `vchroot`: Chroot script.
* `pkglibdepends`: Script to list package depends by shared libraries.
* `xchroot`: Chroot script.
* `pkgdepends`: Script to list package depends by shared libraries.
* `portcreate`: Script to create template port.
* `updateconf`: Script to update configuration files (*.spkgnew).
* `revdep`: A reverse dependency script (like in Gentoo and CRUX, but my version), need to run after upgrade and remove package to check broken package(s). Specify package name if want to check single package only.
@@ -315,11 +304,16 @@ Example of install script for `dbus`:
# <repo directory> <repo url for sync>
#
/usr/ports/core https://raw.githubusercontent.com/venomlinux/ports/master/core
/usr/ports/xorg https://raw.githubusercontent.com/venomlinux/ports/master/xorg
/usr/ports/extra https://raw.githubusercontent.com/venomlinux/ports/master/extra
/usr/ports/multilib https://raw.githubusercontent.com/venomlinux/ports/master/multilib
/usr/ports/community https://raw.githubusercontent.com/venomlinux/ports/master/community
# your local repo
/usr/ports/myrepo
# official venom repo
/usr/ports/core https://github.com/venomlinux/ports/tree/4.0/core
/usr/ports/main https://github.com/venomlinux/ports/tree/repos/main
/usr/ports/multilib https://github.com/venomlinux/ports/tree/repos/multilib
/usr/ports/nonfree https://github.com/venomlinux/ports/tree/repos/nonfree
#/usr/ports/testing https://github.com/venomlinux/ports/tree/repos/testing
*Note: url is optional. Add if need to sync it.*

18
pkgadd
View File

@@ -54,10 +54,6 @@ Options:
-c, --ignore-conflict ignore conflict when installing package
-v, --verbose print files installed
-h, --help show this help message
--no-preinstall skip preinstall script before build/install package
--no-postinstall skip postinstall script after install package
--no-preupgrade skip preupgrade script before upgrade package
--no-postupgrade skip postupgrade script after upgrade package
--no-backup skip backup when upgrading package
--print-dbdir print package database path
--root=<path> install to custom root directory
@@ -92,10 +88,6 @@ parse_opts() {
-c | --ignore-conflict) IGNORE_CONFLICT=yes ;;
-v | --verbose) VERBOSE_INSTALL="-v" ;;
-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 ;;
--print-dbdir) PRINTDBDIR=yes ;;
--root=*) ROOT_DIR="${1#*=}" ;;
@@ -132,24 +124,24 @@ ROOT_DIR="${ROOT_DIR%/}" # remove trailing slash
[ "$PRINTDBDIR" ] && {
echo "$ROOT_DIR/$PKGDB_DIR"
ret 0
exit 0
}
# show help page
[ "$SHOWHELP" ] || [ -z "$PKGNAME" ] && {
help
ret 0
exit 0
}
[ -d "$ROOT_DIR/$PKGDB_DIR" ] || {
msgerr "Package's database directory does not exist: $ROOT_DIR/$PKGDB_DIR"
ret 1
exit 1
}
# check for root access
[ "$(id -u)" = "0" ] || {
msgerr "Installing packages requires root access!"
ret 1
exit 1
}
# check for lock file
@@ -230,7 +222,7 @@ if [ ! "$IGNORE_CONFLICT" ]; then
if [ -e "$ROOT_DIR/$line" ] || [ -L "$ROOT_DIR/$line" ]; then
if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
if ! grep -Fqx "$line" "$ROOT_DIR/$PKGDB_DIR/$name"; then
_f=$(grep -x ^"$line"$ $ROOT_DIR/$PKGDB_DIR/* | cut -d : -f1 | awk -F / '{print $(NF)}' | head -n1 | grep -v $name)
_f=$(grep -x ^"$line"$ $ROOT_DIR/$PKGDB_DIR/* | cut -d : -f1 | awk -F / '{print $(NF)}' | head -n1 | grep -vx $name)
_f=${_f:-(none)}
echo "$_f $line"
touch "$TMP_CONFLICT"

View File

@@ -316,7 +316,7 @@ pkg_package() {
zstd) COMPRESS="--zstd" ;;
esac
tar -c $COMPRESS -f $PACKAGE_DIR/$PKGNAME * $addtotar || {
XZ_DEFAULTS='-T0' tar -c $COMPRESS -f $PACKAGE_DIR/$PKGNAME * $addtotar || {
rm -f $PACKAGE_DIR/$PKGNAME
msgerr "Packaging failed: $PKGNAME"
abort 1
@@ -376,9 +376,14 @@ check_buildscript() {
[ "$(basename $(pwd))" = "$name" ] || { msgerr "Port name and Directory name is different!"; exit 1; }
[ "$version" ] || { msgerr "'version' is empty!"; exit 1; }
[ "$release" ] || { msgerr "'release' is empty!"; exit 1; }
case $release in
*[A-Z]*|*[a-z]*|*-*|*\.*|*_*) msgerr "only numberic allowed in 'release'"; exit 1;;
esac
[ "$(command -v build)" ] || { msgerr "'build' function not exist!"; exit 1; }
[ "$(echo "$version" | grep '-')" ] && { msgerr "'version' should not contain '-'."; exit 1; }
[ "$(echo "$release" | grep '-')" ] && { msgerr "'release' should not contain '-'."; exit 1; }
echo "$version" | grep -q '-' && { msgerr "'version' should not contain '-'."; exit 1; }
if [ "$release" -gt 99 ] || [ "$release" -lt 1 ]; then
msgerr "'release' should numberic between 1 to 99"; exit 1
fi
[ "$description" ] || { msgerr "'description' is empty!"; exit 1; }
}

4
pkgdel
View File

@@ -118,13 +118,13 @@ LOCK_FILE="var/lib/scratchpkg/spkg.lock"
# show help page
[ "$SHOWHELP" ] || [ -z "$RMNAME" ] && {
help
ret 0
exit 0
}
# check for root access
[ "$(id -u)" = "0" ] || {
echo "Removing package need root access!"
ret 1
exit 1
}
# check for lock file

View File

@@ -24,7 +24,7 @@
LIST="/tmp/$(basename $0)-list"
touch $LIST
TOOLCHAIN="linux-api-headers glibc-pass1 binutils-pass1 gcc binutils glibc"
TOOLCHAIN="linux-api-headers glibc-pass1 binutils-pass1 gcc-pass1 glibc binutils gcc"
#scratch sync || exit 1
@@ -33,7 +33,7 @@ for tc in $TOOLCHAIN; do
pkgname="$(echo $tc | sed 's/-pass1//')"
scratch build -f $pkgname || exit 1
echo $tc >> $LIST
scratch install -r $pkgname --no-backup || exit 1
scratch install -r $pkgname || exit 1
fi
done
@@ -44,7 +44,7 @@ for pkg in $(scratch deplist base | awk '{print $2}'); do
if [ ! $(grep -x $pkg $LIST) ]; then
scratch build -f $pkg || exit 1
echo $pkg >> $LIST
scratch install -r $pkg --no-backup || exit 1
scratch install -r $pkg || exit 1
fi
done

View File

@@ -93,7 +93,7 @@ sync_repo() {
echo "fetching ports: $1"
# cloning ports repository
git clone -q -b $branch $url $tmprepo || {
git clone --depth 1 -q -b $branch $url $tmprepo || {
echo " failed sync repo"
exit 1
}

381
scratch
View File

@@ -51,11 +51,36 @@ msgnoinst() {
}
msgerr() {
printf "${RED}==> ERROR:${CRESET} %s\n" "$1" >&2
printf "${RED}ERROR:${CRESET} %s\n" "$1" >&2
}
msgwarn() {
printf "${YELLOW}==> WARNING:${CRESET} %s\n" "$1" >&2
printf "${YELLOW}WARNING:${CRESET} %s\n" "$1" >&2
}
msg_portnotfound() {
echo "Port '$1' not found."
}
msg_portnotinstalled() {
echo "Port '$1' not installed."
}
msg_portalreadyinstalled() {
echo "Port '$1' already installed."
}
msg_depsstatus() {
for i in $@; do
if scratch_isinstalled $i; then
msginst "$i"
elif getportpath $i >/dev/null; then
msgnoinst "$i"
else
msgmiss "$i"
fi
done
unset i
}
needroot() {
@@ -63,7 +88,7 @@ needroot() {
if [ "$#" -eq 0 ]; then
needroot "This operation"
else
msgerr "$* need root access!"
echo "$* need root access!"
fi
exit 1
fi
@@ -89,7 +114,7 @@ vercomp() {
fi
}
get_iver() {
get_iversion() {
head -n1 $PKGDB_DIR/$1 2>/dev/null | awk '{print $1}'
}
@@ -149,7 +174,7 @@ checktool() {
needarg() {
[ "$*" ] || {
msgerr "This operation required an arguments!"
echo "This operation required an arguments!"
exit 1
}
}
@@ -172,7 +197,7 @@ scratch_integrity() {
fi
done
else
echo "Package '$1' not installed."
msg_portnotinstalled $1
exit 1
fi
cd - >/dev/null
@@ -200,21 +225,6 @@ scratch_locate() {
done
}
scratch_isorphan() {
needarg $@
for pkg in $(allinstalled); do
if depend=$(get_depends $pkg); then
for dep in $depend; do
if [ $dep = $1 ]; then
return 1
fi
done
fi
unset depend dep
done
return 0
}
scratch_sync() {
portsync
}
@@ -473,7 +483,7 @@ scratch_build() {
}
for pkg in $PKGNAME; do
ppath=$(getportpath $pkg) || {
echo "Package '$pkg' not found."
msg_portnotfound $pkg
return 1
}
cd $ppath
@@ -518,9 +528,9 @@ scratch_install() {
error=0
for ii in $PKGNAME; do
if [ ! $(getportpath $ii) ]; then
echo "Package '$ii' not found."
msg_portnotfound $ii
elif ! scratch_isinstalled $ii; then
echo "Package '$ii' not installed."
msg_portnotinstalled $ii
else
cd $(getportpath $ii)
settermtitle "Reinstalling $ii..."
@@ -540,9 +550,9 @@ scratch_install() {
error=0
for ii in $PKGNAME; do
if [ ! $(getportpath $ii) ]; then
echo "Package '$ii' not found."
msg_portnotfound $ii
elif scratch_isinstalled $ii; then
echo "Package '$ii' already installed."
msg_portalreadyinstalled $ii
continue
else
cd $(getportpath $ii)
@@ -562,9 +572,9 @@ scratch_install() {
fi
for i in $PKGNAME; do
if [ ! $(getportpath $i) ]; then
echo "Package '$i' not found."
msg_portnotfound $i
elif scratch_isinstalled $i; then
echo "Package '$i' already installed."
msg_portalreadyinstalled $i
else
IPKG="$IPKG $i"
fi
@@ -575,11 +585,13 @@ scratch_install() {
if [ "$INST" ]; then
echo
pkgcount=0
installmsg="ACTION#PORTNAME#VERSION"
for pkg in $INST; do
pkgcount=$(( pkgcount + 1 ))
printf "[${GREEN}i${CRESET}] $pkg "
installmsg="$installmsg install#$pkg#$(get_version $pkg)-$(get_release $pkg)"
done
echo; echo
echo $installmsg | tr ' ' '\n' | tr '#' ' ' | column -t
echo
echo "( $pkgcount install )"
echo
if [ ! "$NOCONFIRM" ]; then
@@ -633,7 +645,7 @@ scratch_remove() {
}
for i in $PKGNAME; do
if ! scratch_isinstalled $i; then
echo "Package '$i' not installed."
msg_portnotinstalled $i
else
IPKG="$IPKG $i"
fi
@@ -643,11 +655,13 @@ scratch_remove() {
echo
pkgcount=0
count=0
installmsg="ACTION#PORTNAME#VERSION"
for pkg in $IPKG; do
pkgcount=$(( pkgcount + 1 ))
printf "[${RED}x${CRESET}] $pkg "
installmsg="$installmsg remove#$pkg#$(get_iversion $pkg)-$(get_irelease $pkg)"
done
echo; echo
echo $installmsg | tr ' ' '\n' | tr '#' ' ' | column -t
echo
echo "( $pkgcount remove )"
echo
[ "$NOCONFIRM" ] || {
@@ -658,7 +672,7 @@ scratch_remove() {
count=$(( count + 1 ))
pre_triggers $pkg
settermtitle "[ $count/$pkgcount ] Removing $pkg..."
echo "remove: $pkg-$(get_iver $pkg)-$(get_irelease $pkg)..."
echo "remove: $pkg-$(get_iversion $pkg)-$(get_irelease $pkg)..."
pkgdel $pkg $OPTS || {
error=1
break
@@ -670,30 +684,6 @@ scratch_remove() {
settermtitle "$pkgcount package(s) removed."
}
outdatepkg() {
OLDIFS=$IFS
IFS=,
for i in ${1#*=}; do exclude="$exclude $i"; done
IFS=$OLDIFS
for pkg in $(allinstalled); do
echo $exclude | grep -qw $pkg && continue
if [ -f "$MASK_FILE" ] && [ $(grep -Ev '^(#|$| )' $MASK_FILE | grep -x $pkg) ]; then
continue
fi
getportpath $pkg >/dev/null || continue
. $(getportpath $pkg)/$BUILD_SCRIPT
if [ ! "$name" ] || [ ! "$version" ]; then
continue
fi
iversion=$(get_iver $pkg)
irelease=$(get_irelease $pkg)
if [ "$release" != "$irelease" ] || [ "$version" != "$iversion" ]; then
echo $name
fi
unset iversion irelease version release
done
}
scratch_sysup() {
needroot "Upgrading package"
while [ "$1" ]; do
@@ -708,42 +698,55 @@ scratch_sysup() {
shift
done
echo "Checking for outdated packages..."
PKGOUTDATE=$(outdatepkg $EXOPT)
[ "$PKGOUTDATE" ] || {
PKGOUTDATE=$(check_outdated)
# filter out masked
for i in $PKGOUTDATE; do
case $i in
*#1) continue;;
*) ii="$ii ${i%%#*}";;
esac
done
EXPKG=${EXOPT#*=}
for i in $ii; do
echo $EXPKG | tr ',' '\n' | grep -x $i >/dev/null || PKG="$PKG $i"
done
[ "$PKG" ] || {
echo "All packages are up to date."
return 0
}
[ "$(echo $PKGOUTDATE | tr ' ' '\n' | grep -x scratchpkg)" ] && {
[ "$(echo $PKG | grep -w scratchpkg)" ] && {
echo
msgerr "Please upgrade 'scratchpkg' first."
return 1
}
UPGPKG=0
NEWPKG=0
NEWPKG=0
installmsg="ACTION#PORTNAME#VERSION#OLDVERSION"
if [ "$NODEP" != 1 ]; then
echo "Resolving dependencies..."
DEP=$(scratch_deplist $PKGOUTDATE $EXOPT | awk '{print $2}')
DEP=$(scratch_deplist $PKG $EXOPT | awk '{print $2}')
echo
for d in $DEP; do
if [ "$(echo $PKGOUTDATE | tr ' ' '\n' | grep -x $d)" = "$d" ]; then
printf "[${GREEN}u${CRESET}] $d "
if [ "$(echo $PKG | tr ' ' '\n' | grep -x $d)" = "$d" ]; then
installmsg="$installmsg upgrade#$d#$(get_version $d)-$(get_release $d)#$(get_iversion $d)-$(get_irelease $d)"
WILLINSTALL="$WILLINSTALL $d"
UPGPKG=$(( UPGPKG + 1 ))
elif ! scratch_isinstalled $d && [ "$(getportpath "$d")" ]; then
printf "[${CYAN}n${CRESET}] $d "
installmsg="$installmsg install#$d#$(get_version $d)-$(get_release $d)#$(get_iversion $d)-$(get_irelease $d)"
WILLINSTALL="$WILLINSTALL $d"
NEWPKG=$(( NEWPKG + 1 ))
fi
done
else
echo
for dd in $PKGOUTDATE; do
for dd in $PKG; do
printf "[${GREEN}u${CRESET}] $dd "
WILLINSTALL="$WILLINSTALL $dd"
UPGPKG=$(( UPGPKG + 1 ))
done
fi
echo; echo
echo $installmsg | tr ' ' '\n' | tr '#' ' ' | column -t
echo
echo "( $UPGPKG upgrade, $NEWPKG new install )"
echo
[ "$NOCONFIRM" ] || {
@@ -827,14 +830,14 @@ scratch_upgrade() {
}
for pkg in $PKGNAME; do
if ! scratch_isinstalled $pkg; then
echo "Package '$pkg' not installed."
msg_portnotinstalled $pkg
continue
elif [ ! $(getportpath $pkg) ]; then
echo "Package '$pkg' not exist."
continue
else
. $(getportpath $pkg)/$BUILD_SCRIPT
if [ "$(get_iver $pkg)-$(get_irelease $pkg)" = "$version-$release" ]; then
if [ "$(get_iversion $pkg)-$(get_irelease $pkg)" = "$version-$release" ]; then
echo "Package '$pkg' is up to date."
continue
fi
@@ -844,18 +847,19 @@ scratch_upgrade() {
[ "$upkg" ] || return 0
UPGPKG=0
NEWPKG=0
NEWPKG=0
installmsg="ACTION#PORTNAME#VERSION#OLDVERSION"
if [ "$NODEP" != 1 ]; then
echo "Resolving dependencies..."
DEP=$(scratch_deplist $upkg $EXOPT | awk '{print $2}')
echo
for d in $DEP; do
if [ "$(echo $upkg | tr ' ' '\n' | grep -x $d)" = "$d" ]; then
printf "[${GREEN}u${CRESET}] $d "
installmsg="$installmsg upgrade#$d#$(get_version $d)-$(get_release $d)#$(get_iversion $d)-$(get_irelease $d)"
WILLINSTALL="$WILLINSTALL $d"
UPGPKG=$(( UPGPKG + 1 ))
elif ! scratch_isinstalled $d && [ "$(getportpath "$d")" ]; then
printf "[${CYAN}n${CRESET}] $d "
installmsg="$installmsg install#$d#$(get_version $d)-$(get_release $d)#$(get_iversion $d)-$(get_irelease $d)"
WILLINSTALL="$WILLINSTALL $d"
NEWPKG=$(( NEWPKG + 1 ))
fi
@@ -863,12 +867,13 @@ scratch_upgrade() {
else
echo
for dd in $upkg; do
printf "[${GREEN}u${CRESET}] $dd "
installmsg="$installmsg upgrade#$d#$(get_version $d)-$(get_release $d)#$(get_iversion $d)-$(get_irelease $d)"
WILLINSTALL="$WILLINSTALL $dd"
UPGPKG=$(( UPGPKG + 1 ))
done
fi
echo; echo
echo $installmsg | tr ' ' '\n' | tr '#' ' ' | column -t
echo
echo "( $UPGPKG upgrade, $NEWPKG new install )"
echo
[ "$NOCONFIRM" ] || {
@@ -914,43 +919,56 @@ scratch_isinstalled() {
return 0
}
scratch_outdate() {
get_version() {
p=$(getportpath $1)
[ "$p" ] && . $p/$BUILD_SCRIPT || version=0
echo $version
}
get_release() {
p=$(getportpath $1)
[ "$p" ] && . $p/$BUILD_SCRIPT || release=0
echo $release
}
check_outdated() {
for pkg in $(allinstalled); do
if [ "$(getportpath $pkg)" ]; then
. $(getportpath $pkg)/$BUILD_SCRIPT
if [ -z "$name" ] || [ -z "$version" ]; then
continue
fi
iversion=$(get_iver $pkg)
irelease=$(get_irelease $pkg)
if [ -f "$MASK_FILE" ] && [ $(grep -Ev '^(#|$| )' $MASK_FILE | grep $pkg) ]; then
ITSLOCK="[masked]"
fi
outdatemsg="$name $iversion-$irelease => $version-$release $ITSLOCK"
newerinstmsg="$name $iversion-$irelease => $version-$release [newer installed] $ITSLOCK"
if [ "$version" != "$iversion" ]; then
vercomp $version $iversion
if [ $? = 2 ]; then
echo "$outdatemsg"
OUTDATE=yes
elif [ $? = 1 ]; then
echo "$newerinstmsg"
OUTDATE=yes
fi
elif [ "$release" != "$irelease" ]; then
vercomp $release $irelease
if [ $? = 2 ]; then
echo "$outdatemsg"
OUTDATE=yes
elif [ $? = 1 ]; then
echo "$newerinstmsg"
OUTDATE=yes
fi
fi
unset ITSLOCK name version
NEWINSTALLED=0
MASKED=0
p=$(getportpath $pkg)
[ "$p" ] || continue
. $p/$BUILD_SCRIPT
if [ ! "$name" ] || [ ! "$version" ]; then
continue
fi
iversion=$(get_iversion $pkg)
irelease=$(get_irelease $pkg)
[ $version$release = $iversion$irelease ] && continue
if [ "$version" != "$iversion" ]; then
vercomp $version $iversion
[ $? = 1 ] && NEWINSTALLED="1"
elif [ "$release" != "$irelease" ]; then
vercomp $release $irelease
[ $? = 1 ] && NEWINSTALLED="1"
fi
[ "$(grep -Ev '^(#|$| )' $MASK_FILE | grep -x $pkg)" ] && MASKED="1"
echo "$pkg#$iversion-$irelease#$version-$release#$NEWINSTALLED#$MASKED"
done
}
scratch_outdate() {
for i in $(check_outdated); do
OUTDATE=1
unset ii
pname=${i%%#*}; i=${i#*#}
oldver=${i%%#*}; i=${i#*#}
newver=${i%%#*}; i=${i#*#}
newins=${i%%#*}; i=${i#*#}
masked=${i%%#*}; i=${i#*#}
[ "$newins" = 1 ] && ii=" [newer installed]"
[ "$masked" = 1 ] && ii="$ii [masked]"
echo "$pname $oldver => $newver$ii"
done
[ ! "$OUTDATE" ] && msg "All packages are up to date."
}
@@ -959,7 +977,11 @@ scratch_search() {
arg=$*
for repo in $PORT_REPO; do
[ -d $repo ] || continue
out=$(grep -R "# description" $repo/*/$BUILD_SCRIPT | grep -i "$arg" | awk -F : '{print $1}' | sort)
dummyport=/tmp/dummyport/$BUILD_SCRIPT
mkdir -p ${dummyport%/*}
touch $dummyport
out=$(grep -R "# description" $repo/*/$BUILD_SCRIPT $dummyport | grep -i "$arg" | awk -F : '{print $1}' | sort)
rm -fr $dummyport
[ "$out" ] || continue
found=1
for line in $out; do
@@ -1091,14 +1113,14 @@ scratch_deplist() {
done
IFS=$OLDIFS
[ "$PKG" ] || {
echo "Please specify package(s) to list dependencies."
echo "Please specify port(s) to list dependencies."
return 1
}
for p in $PKG; do
if [ "$(getportpath $p)" ]; then
PPKG="$PPKG $p"
else
[ "$quick" = 1 ] || msgerr "Package '$p' not exist."
[ "$quick" = 1 ] || msg_portnotfound $p
fi
done
@@ -1111,13 +1133,7 @@ scratch_deplist() {
if [ "$quick" = 1 ]; then
echo $DEP | tr ' ' '\n'
else
for p in $DEP; do
if scratch_isinstalled $p; then
echo "[*] $p"
else
echo "[-] $p"
fi
done
msg_depsstatus $DEP
if [ "$MISSINGDEP" ]; then
for m in $MISSINGDEP; do
echo "Missing deps: $m" | sed 's/(/ (/'
@@ -1144,15 +1160,15 @@ deplist() {
CHECK="$CHECK $1"
# check dependencies
for i in $(get_depends $1); do
if [ "$quick" = 1 ] && scratch_isinstalled $i; then
for deplist in $(get_depends $1); do
if [ "$quick" = 1 ] && scratch_isinstalled $deplist; then
continue
else
if ! echo $DEP | tr " " "\n" | grep -qx $i; then
if ! getportpath $i >/dev/null; then
MISSINGDEP="$MISSINGDEP $i($1)"
if ! echo $DEP | tr " " "\n" | grep -qx $deplist; then
if ! getportpath $deplist >/dev/null; then
MISSINGDEP="$MISSINGDEP $deplist($1)"
else
deplist $i
deplist $deplist
fi
fi
fi
@@ -1176,7 +1192,7 @@ scratch_cat() {
if PPATH=$(getportpath "$1"); then
cat "$PPATH/$BUILD_SCRIPT"
else
msgerr "Port '$1' not exist."
msg_portnotfound $1
return 1
fi
}
@@ -1184,15 +1200,17 @@ scratch_cat() {
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
for dpd in $(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); do
msg_depsstatus $dpd
done
else
msgerr "Port '$1' not exist."
msg_portnotfound $1
return 1
fi
}
@@ -1202,19 +1220,10 @@ scratch_depends() {
if getportpath "$1" >/dev/null; then
depends=$(get_depends $1)
else
msgerr "Port '$1' not exist."
msg_portnotfound $1
return 1
fi
for dep in $depends; do
if scratch_isinstalled $dep; then
msginst "$dep"
elif getportpath $dep >/dev/null; then
msgnoinst "$dep"
else
msgmiss "$dep"
fi
done
msg_depsstatus $depends
}
scratch_dup() {
@@ -1235,7 +1244,7 @@ scratch_dup() {
scratch_foreign() {
for pkg in $(allinstalled); do
if ! getportpath $pkg >/dev/null; then
iversion=$(get_iver $pkg)
iversion=$(get_iversion $pkg)
irelease=$(get_irelease $pkg)
echo "$pkg $iversion-$irelease"
fi
@@ -1245,7 +1254,10 @@ scratch_foreign() {
scratch_info() {
needarg $@
ppath=$(getportpath $1) || return 1
ppath=$(getportpath $1) || {
msg_portnotfound $1
return 1
}
. $ppath/$BUILD_SCRIPT
desc=$(grep "^# description[[:blank:]]*:" $ppath/$BUILD_SCRIPT | sed 's/^# description[[:blank:]]*:[[:blank:]]*//')
@@ -1261,12 +1273,12 @@ scratch_info() {
echo "Maintainer: $maint"
echo "Homepage: $homep"
echo "Dependencies: $deps"
echo "Installed: $(get_iver $1)-$(get_irelease $1)"
echo "Installed: $(get_iversion $1)-$(get_irelease $1)"
}
scratch_installed() {
for all in $(allinstalled); do
echo "$all $(get_iver $all)-$(get_irelease $all)"
echo "$all $(get_iversion $all)-$(get_irelease $all)"
done
}
@@ -1278,10 +1290,10 @@ scratch_missingdep() {
if [ "$depends" ]; then
for d in $depends; do
if ! scratch_isinstalled $d; then
if [ -z "$msd" ]; then
msd="$d"
else
if [ "$msd" ]; then
msd="$msd $d"
else
msd="$d"
fi
fi
done
@@ -1291,10 +1303,56 @@ scratch_missingdep() {
done
}
scratch_purge() {
needroot "Purging package"
while [ "$1" ]; do
case $1 in
-*) PURGEOPTS="$PURGEOPTS $1";;
*) PURGENAME="$PURGENAME $1";;
esac
shift
done
if [ "$PURGENAME" ]; then
for i in $PURGENAME; do
scratch_isinstalled $i || {
msg_portnotinstalled $i
needexit=1
}
done
fi
[ "$needexit" ] && exit 1
echo "Resolving dependencies..."
orphan=$(scratch_orphan $PURGENAME)
if [ "$PURGENAME" ]; then
for purge in $PURGENAME; do
unset DEP pkg
deplist $purge
for ii in $DEP; do
echo $orphan | tr ' ' '\n' | grep -qx $ii && pkg="$pkg $ii"
done
[ "$pkg" ] || echo "Cant purge '$purge', it required by other package(s)..."
if [ "$remove" ]; then
remove="$remove $pkg"
else
remove="$pkg"
fi
done
else
remove=$orphan
fi
if [ "$remove" ]; then
scratch_remove $remove $PURGEOPTS
else
echo "No orphan packages found..."
fi
}
scratch_orphan() {
tmpdeplistworld="/tmp/.deplistworld.$$"
tmpallinstalled="/tmp/.allinstalled.$$"
for i in $(cat $WORLD_FILE); do
echo $@ | tr ' ' '\n' | grep -qx $i && continue
echo $DEP | tr ' ' '\n' | grep -qx $i && continue
deplist $i
done
echo $DEP | tr ' ' '\n' > $tmpdeplistworld
@@ -1308,7 +1366,7 @@ scratch_path() {
if PPATH=$(getportpath "$1"); then
echo "$PPATH"
else
msgerr "Port '$1' not exist."
msg_portnotfound $1
return 1
fi
}
@@ -1327,10 +1385,10 @@ scratch_readme() {
if [ -f "$PPATH/readme" ]; then
cat "$PPATH/readme"
else
msgerr "Port '$1' does not have readme."
echo "Port '$1' does not have readme."
fi
else
msgerr "Port '$1' not exist."
msg_portnotfound $1
exit 1
fi
}
@@ -1363,18 +1421,17 @@ scratch_files() {
if scratch_isinstalled $1; then
cat "$PKGDB_DIR/$1"
else
msg "Package '$1' not installed."
msg_portnotinstalled $1
fi
}
world_add() {
grep -qx $1 "$WORLD_FILE" && return
scratch_isinstalled $1 || {
echo "'$1' not installed"
msg_portnotinstalled $1
return 1
}
echo "$1" >> "$WORLD_FILE"
echo "world: '$1' added to world"
sort "$WORLD_FILE" -o "$WORLD_FILE" # sort world
sed '/^$/d' -i "$WORLD_FILE" # delete empty lines
}
@@ -1382,7 +1439,6 @@ world_add() {
world_del() {
grep -qx $1 "$WORLD_FILE" || return
sed "/^$1$/d" -i "$WORLD_FILE"
echo "world: '$1' deleted from world"
sed '/^$/d' -i "$WORLD_FILE" # delete empty lines
}
@@ -1392,8 +1448,10 @@ scratch_world() {
touch "$WORLD_FILE"
while [ "$1" ]; do
if [ ! $(grep -x $1 "$WORLD_FILE") ] ; then
echo "world: '$1' added to world"
world_add $1
else
echo "world: '$1' deleted from world"
world_del $1
fi
shift
@@ -1454,6 +1512,8 @@ Options:
info <port> print information
locate <file> print location of file in ports repo
isinstalled <port> check whether port is installed (status 0=installed, 1=not installed)
purge [ports] remove installed ports and its orphan dependencies
world [ports] print/add/remove world list
sync update ports database
outdate print outdated ports
cache print and clear old pkg and src caches
@@ -1463,7 +1523,6 @@ Options:
missingdep print missing dependencies
orphan print orphan installed ports
foreign print foreign ports
world [ports] print/add/remove world list
printconfig <opts> print scratchpkg configs
help print this help msg
@@ -1556,7 +1615,7 @@ fi
for f in $REPO_FILE $ALIAS_FILE $MASK_FILE $CONFIG_FILE; do
if [ ! -f "$f" ]; then
msgerr "file not found: $CONFIG_FILE"
msgerr "file not found: $f"
exit 3
fi
done

View File

@@ -5,6 +5,8 @@
# <repo directory> <repo url for sync>
#
# example:
# /usr/ports/core https://raw.githubusercontent.com/emmett1/ports/master/core
# /usr/ports/localports
#
# /usr/ports/myrepo
# /usr/ports/core https://github.com/venomlinux/ports/tree/venom4/core
# /usr/ports/main https://github.com/venomlinux/ports/tree/repos/main
# /usr/ports/multilib https://github.com/venomlinux/ports/tree/repos/multilib
#