mirror of
https://github.com/outbackdingo/scratchpkg.git
synced 2026-03-22 01:45:03 +00:00
Compare commits
97 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d848402f95 | ||
|
|
8c0c7b888c | ||
|
|
af9d283eb4 | ||
|
|
4e5a7573a6 | ||
|
|
fb3406dc2d | ||
|
|
a12f8bf6e1 | ||
|
|
f41c087103 | ||
|
|
b831ff55fd | ||
|
|
a47859bcea | ||
|
|
20ac214cfa | ||
|
|
642e4aff85 | ||
|
|
f481b9a025 | ||
|
|
8d3d767ab6 | ||
|
|
fdc5578ecd | ||
|
|
3b8d9a95b3 | ||
|
|
1324ed620c | ||
|
|
435209beb2 | ||
|
|
ee33aaa213 | ||
|
|
1871acc25b | ||
|
|
96e06ffc66 | ||
|
|
ce703e988f | ||
|
|
a4d1ced5a0 | ||
|
|
5c91ed92d5 | ||
|
|
fd39044819 | ||
|
|
c80c3d42cf | ||
|
|
2a3393f1e2 | ||
|
|
aba826141c | ||
|
|
14271ec0fd | ||
|
|
1161d001b8 | ||
|
|
a70018062e | ||
|
|
70fa8b3bf2 | ||
|
|
4a631ea4a7 | ||
|
|
b7cd1114da | ||
|
|
7612d83368 | ||
|
|
41151b383e | ||
|
|
ca93ecfe94 | ||
|
|
cdd4cdd71c | ||
|
|
31bba79556 | ||
|
|
643a7ec6bf | ||
|
|
b06326bfd0 | ||
|
|
9eef7b197b | ||
|
|
6626017ff7 | ||
|
|
0b3092bbfb | ||
|
|
da5d1be623 | ||
|
|
da7cce1e23 | ||
|
|
d353ba3bfa | ||
|
|
d53b1b7b08 | ||
|
|
819f42df3a | ||
|
|
c254ac0dc6 | ||
|
|
61dd798a5f | ||
|
|
31e52cc3b5 | ||
|
|
4adcc4bfe9 | ||
|
|
a432db4c26 | ||
|
|
073e7433f7 | ||
|
|
e1dd623125 | ||
|
|
f396d41551 | ||
|
|
59ea432704 | ||
|
|
3dcdee4f9d | ||
|
|
8691210b76 | ||
|
|
d56e9e4d6c | ||
|
|
278bc6c512 | ||
|
|
b9e49bcfac | ||
|
|
5c5324970f | ||
|
|
ece22a4c4a | ||
|
|
1234389c38 | ||
|
|
e2588ff9c8 | ||
|
|
f94e5714a1 | ||
|
|
d800fa1f91 | ||
|
|
0444fb4937 | ||
|
|
c6131b545a | ||
|
|
57c3779d86 | ||
|
|
80e4afcaac | ||
|
|
0e1dd428c0 | ||
|
|
b14ab18b8d | ||
|
|
e651bf371f | ||
|
|
059174e644 | ||
|
|
8c3f3e4bc7 | ||
|
|
6c85489b2c | ||
|
|
dba27d791f | ||
|
|
7e07dcdd0a | ||
|
|
fd011dd3dc | ||
|
|
bc77ed9758 | ||
|
|
b42c48a88c | ||
|
|
497b92c1cd | ||
|
|
f3018114dd | ||
|
|
eee0a24f61 | ||
|
|
ab23dbde67 | ||
|
|
f74b026a13 | ||
|
|
552e0c7bfe | ||
|
|
34b9568afb | ||
|
|
0aa9868d15 | ||
|
|
f0ff3d070e | ||
|
|
985f59fc97 | ||
|
|
2651ad3188 | ||
|
|
3602e0a8e8 | ||
|
|
c816e3b409 | ||
|
|
8d4b7902eb |
@@ -16,8 +16,8 @@ install -dm777 ${DESTDIR}${CACHE_DIR}/packages
|
|||||||
install -dm777 ${DESTDIR}${CACHE_DIR}/sources
|
install -dm777 ${DESTDIR}${CACHE_DIR}/sources
|
||||||
install -dm777 ${DESTDIR}${CACHE_DIR}/work
|
install -dm777 ${DESTDIR}${CACHE_DIR}/work
|
||||||
|
|
||||||
install -m755 xchroot revdep pkgadd pkgdel pkgbuild pkgquery scratch updateconf \
|
install -m755 xchroot revdep pkgadd pkgdel pkgbuild scratch updateconf portsync \
|
||||||
pkgbase pkgdepends pkgrebuild pkgfix portcreate ${DESTDIR}${BINDIR}
|
pkgbase pkgdepends pkgrebuild portcreate ${DESTDIR}${BINDIR}
|
||||||
install -m644 scratchpkg.conf scratchpkg.repo scratchpkg.alias ${DESTDIR}${CONFDIR}
|
install -m644 scratchpkg.conf scratchpkg.repo scratchpkg.alias scratchpkg.mask ${DESTDIR}${CONFDIR}
|
||||||
|
|
||||||
install -m644 revdep.conf ${DESTDIR}${REVDEPCONF}
|
install -m644 revdep.conf ${DESTDIR}${REVDEPCONF}
|
||||||
|
|||||||
178
README.md
178
README.md
@@ -86,14 +86,16 @@ Available options:
|
|||||||
zipman: Compress manual (man and info) pages with gzip.
|
zipman: Compress manual (man and info) pages with gzip.
|
||||||
buildflags: Enable buildflags (CFLAGS and CXXFLAGS).
|
buildflags: Enable buildflags (CFLAGS and CXXFLAGS).
|
||||||
makeflags: Enable makeflags (MAKEFLAGS).
|
makeflags: Enable makeflags (MAKEFLAGS).
|
||||||
|
checksum: Enable checking checksum.
|
||||||
|
|
||||||
### pkgbuild
|
### 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:
|
Usage:
|
||||||
pkgbuild [ <options> <arguments> ]
|
pkgbuild [ <options> <arguments> ]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
-q --quiet show only status messages and errors
|
||||||
-i, --install install package into system
|
-i, --install install package into system
|
||||||
-u, --upgrade upgrade package
|
-u, --upgrade upgrade package
|
||||||
-r, --reinstall reinstall package
|
-r, --reinstall reinstall package
|
||||||
@@ -104,20 +106,16 @@ Available options:
|
|||||||
-g, --genmdsum generate md5sum
|
-g, --genmdsum generate md5sum
|
||||||
-o, --download download only source file
|
-o, --download download only source file
|
||||||
-x, --extract extract only source file
|
-x, --extract extract only source file
|
||||||
|
-p, --pkgfiles generate list files in package
|
||||||
-w, --keep-work keep working directory
|
-w, --keep-work keep working directory
|
||||||
-l, --log log build process
|
|
||||||
-h, --help show this help message
|
-h, --help show this help message
|
||||||
|
--clean remove downloaded sources and prebuilt packages
|
||||||
--config=<config> use custom config file
|
--config=<config> use custom config file
|
||||||
--srcdir=<path> override directory path for sources
|
--srcdir=<path> override directory path for sources
|
||||||
--pkgdir=<path> override directory path for compiled package
|
--pkgdir=<path> override directory path for compiled package
|
||||||
--logdir=<path> override directory path for build logs
|
|
||||||
--workdir=<path> override directory path for working dir
|
--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
|
--no-backup skip backup configuration file when upgrading package
|
||||||
--redownload re-download source file
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
pkgbuild -iw this will build, install package and keep working directory
|
pkgbuild -iw this will build, install package and keep working directory
|
||||||
@@ -129,12 +127,12 @@ Available options:
|
|||||||
|
|
||||||
### pkgadd
|
### pkgadd
|
||||||
`pkgadd` is a tool to install and upgrade package created by `pkgbuild`. Install package is simply extract
|
`pkgadd` is a tool to install and upgrade package created by `pkgbuild`. Install package is simply extract
|
||||||
`<name>-<version>-<release>.spkg.txz` by using tar into real system then save list extracted file into package `INDEX_DIR`.
|
`<name>-<version>-<release>.spkg.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
|
Upgrading package is also using same extract as install, it will replace old files then compare list file from old and new
|
||||||
package and remove old file which not exist in new package (like Slackware pkgtool does).
|
package and remove old file which not exist in new package (like Slackware pkgtool does).
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
pkgadd package.spkg.txz <options>
|
pkgadd [ <options> <package.spkg.txz> ]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-u, --upgrade upgrade package
|
-u, --upgrade upgrade package
|
||||||
@@ -142,11 +140,8 @@ package and remove old file which not exist in new package (like Slackware pkgto
|
|||||||
-c, --ignore-conflict ignore conflict when installing package
|
-c, --ignore-conflict ignore conflict when installing package
|
||||||
-v, --verbose print files installed
|
-v, --verbose print files installed
|
||||||
-h, --help show this help message
|
-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
|
--no-backup skip backup when upgrading package
|
||||||
|
--print-dbdir print package database path
|
||||||
--root=<path> install to custom root directory
|
--root=<path> install to custom root directory
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
@@ -154,7 +149,7 @@ package and remove old file which not exist in new package (like Slackware pkgto
|
|||||||
old configuration files and skip conflict check
|
old configuration files and skip conflict check
|
||||||
|
|
||||||
### pkgdel
|
### pkgdel
|
||||||
`pkgdel` is a tool to remove package from system. It will read file listed in package `INDEX_DIR` and remove it.
|
`pkgdel` is a tool to remove package from system. It will read file listed in package `PKGDB_DIR` and remove it.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
pkgdel [ <options> <package name> ]
|
pkgdel [ <options> <package name> ]
|
||||||
@@ -162,8 +157,6 @@ package and remove old file which not exist in new package (like Slackware pkgto
|
|||||||
Options:
|
Options:
|
||||||
-h, --help show this help message
|
-h, --help show this help message
|
||||||
-v, --verbose print removed files
|
-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
|
--root=<path> remove package from custom root directory
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
@@ -175,77 +168,73 @@ 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.
|
orphan package, duplicate ports, list installed package and etc. Run `scratch help` to see available functions.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
scratch [ mode ] [ <pkgname> <options> ]
|
scratch <options> [<arg>]
|
||||||
|
|
||||||
mode:
|
Options:
|
||||||
install <packages> install packages and its dependencies
|
install <ports> <arg> install ports (use pkgbuild arg, except '-i' & '-u')
|
||||||
upgrade <packages> upgrade packages and install new dependencies (if any)
|
-r reinstall
|
||||||
build <package> build only packages
|
-n skip dependencies
|
||||||
remove <packages> remove packages in system
|
-y skip ask user confirmation
|
||||||
depends <package> show depends of a package
|
-o fetch sources only
|
||||||
deplist <packages> show list dependencies of a package
|
--exclude=* exclude dependencies, comma separated
|
||||||
search <pattern> search packages in port's repos
|
|
||||||
lock <packages> lock packages from upgrade
|
upgrade <ports> <arg> upgrade ports (use pkgbuild arg, except '-i' & '-r')
|
||||||
unlock <packages> unlock packages from upgrade
|
-n skip dependencies
|
||||||
listport <repo> list ports of a repo
|
-y skip ask user confirmation
|
||||||
cat <package> view a package build scripts
|
-o fetch sources only
|
||||||
dependent <package> show package's dependent
|
--exclude=* exclude dependencies, comma separated
|
||||||
own <file> show package's owner of file
|
|
||||||
pkgtree <package> show list files of installed package
|
remove <ports> <arg> remove installed ports (use pkgdel arg)
|
||||||
path <package> show package's buildscripts path
|
-y skip ask user confirmation
|
||||||
sync update port's repo
|
|
||||||
sysup full system update
|
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
|
dup print duplicate ports in repo
|
||||||
readme print readme file if exist
|
installed print all installed ports
|
||||||
listinst list installed package in system
|
missingdep print missing dependencies
|
||||||
listorphan list orphan package
|
orphan print orphan installed ports
|
||||||
integrity check integrity of package's files
|
foreign print foreign ports
|
||||||
outdate check for outdate packages
|
printconfig <opts> print scratchpkg configs
|
||||||
cache print leftover cache
|
help print this help msg
|
||||||
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:
|
Global options:
|
||||||
build
|
--append-repo=<repo path> append custom local repo path (can use multiple times)
|
||||||
-f, --force-rebuild force rebuild
|
--prepend-repo=<repo path> prepend custom local repo path (can use multiple times)
|
||||||
-m, --skip-mdsum skip md5sum check for sources
|
--override-repo=<repo path> override repo in /etc/scratchpkg.repo with custom local repo (can use multiple times)
|
||||||
-d, --no-dep skip dependency check
|
--repo-file=<repo file> use custom repo file (default: /etc/scratchpkg.repo)
|
||||||
-e, --extract extract only
|
--config-file=<config file> use custom config file (default: /etc/scratchpkg.conf)
|
||||||
-w, --keep-work keep woring directory
|
--alias-file=<alias file> use custom alias file (default: /etc/scratchpkg.alias)
|
||||||
-o, --download download source files only
|
--mask-file=<mask file> use custom mask file (default: /etc/scratchpkg.mask)
|
||||||
--redownload re-download source files
|
--nocolor disable colour for output
|
||||||
--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
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
scratch install firefox gvfs -cv build and install required dependencies and target package itself,
|
scratch install firefox gvfs -cv build and install required dependencies and target package itself,
|
||||||
@@ -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
|
Extra tools is some scripts come with scratchpkg to help users do things more easier. More extra scripts may added from time to
|
||||||
time.
|
time.
|
||||||
|
|
||||||
* `vchroot`: Chroot script.
|
* `xchroot`: Chroot script.
|
||||||
* `pkglibdepends`: Script to list package depends by shared libraries.
|
* `pkgdepends`: Script to list package depends by shared libraries.
|
||||||
* `portcreate`: Script to create template port.
|
* `portcreate`: Script to create template port.
|
||||||
* `updateconf`: Script to update configuration files (*.spkgnew).
|
* `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.
|
* `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>
|
# <repo directory> <repo url for sync>
|
||||||
#
|
#
|
||||||
|
|
||||||
/usr/ports/core https://raw.githubusercontent.com/venomlinux/ports/master/core
|
# your local repo
|
||||||
/usr/ports/xorg https://raw.githubusercontent.com/venomlinux/ports/master/xorg
|
/usr/ports/myrepo
|
||||||
/usr/ports/extra https://raw.githubusercontent.com/venomlinux/ports/master/extra
|
|
||||||
/usr/ports/multilib https://raw.githubusercontent.com/venomlinux/ports/master/multilib
|
# official venom repo
|
||||||
/usr/ports/community https://raw.githubusercontent.com/venomlinux/ports/master/community
|
/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.*
|
*Note: url is optional. Add if need to sync it.*
|
||||||
|
|
||||||
|
|||||||
152
pkgadd
152
pkgadd
@@ -36,11 +36,11 @@ msg2() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
msgerr() {
|
msgerr() {
|
||||||
echo "==> ERROR: $1"
|
echo "==> ERROR: $1" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
msgwarn() {
|
msgwarn() {
|
||||||
echo "==> WARNING: $1"
|
echo "==> WARNING: $1" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
help() {
|
help() {
|
||||||
@@ -54,11 +54,8 @@ Options:
|
|||||||
-c, --ignore-conflict ignore conflict when installing package
|
-c, --ignore-conflict ignore conflict when installing package
|
||||||
-v, --verbose print files installed
|
-v, --verbose print files installed
|
||||||
-h, --help show this help message
|
-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
|
--no-backup skip backup when upgrading package
|
||||||
|
--print-dbdir print package database path
|
||||||
--root=<path> install to custom root directory
|
--root=<path> install to custom root directory
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
@@ -91,11 +88,8 @@ parse_opts() {
|
|||||||
-c | --ignore-conflict) IGNORE_CONFLICT=yes ;;
|
-c | --ignore-conflict) IGNORE_CONFLICT=yes ;;
|
||||||
-v | --verbose) VERBOSE_INSTALL="-v" ;;
|
-v | --verbose) VERBOSE_INSTALL="-v" ;;
|
||||||
-h | --help) SHOWHELP=yes ;;
|
-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 ;;
|
--no-backup) NO_BACKUP=yes ;;
|
||||||
|
--print-dbdir) PRINTDBDIR=yes ;;
|
||||||
--root=*) ROOT_DIR="${1#*=}" ;;
|
--root=*) ROOT_DIR="${1#*=}" ;;
|
||||||
*.spkg.tar.*) PKGNAME="$(realpath $1)" ;;
|
*.spkg.tar.*) PKGNAME="$(realpath $1)" ;;
|
||||||
*) msg "Invalid option! ($1)"; exit 1 ;;
|
*) msg "Invalid option! ($1)"; exit 1 ;;
|
||||||
@@ -112,53 +106,53 @@ ret() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isinstalled() {
|
isinstalled() {
|
||||||
if [ -s "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo" ] && grep -q "$1" "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo"; then
|
if [ -s "$ROOT_DIR/$PKGDB_DIR/$1" ]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
run_scripts() {
|
|
||||||
if [ "$ROOT_DIR" ]; then
|
|
||||||
xchroot "$ROOT_DIR" sh $@
|
|
||||||
else
|
|
||||||
sh $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
parse_opts $(extract_opts "$@")
|
parse_opts $(extract_opts "$@")
|
||||||
|
|
||||||
SCRATCHPKG_DIR="var/lib/scratchpkg"
|
SCRATCHPKG_DIR="var/lib/scratchpkg"
|
||||||
INDEX_DIR="$SCRATCHPKG_DIR/index"
|
PKGDB_DIR="$SCRATCHPKG_DIR/db"
|
||||||
|
PKGDBPERMS_DIR="$PKGDB_DIR.perms"
|
||||||
LOCK_FILE="$SCRATCHPKG_DIR/spkg.lock"
|
LOCK_FILE="$SCRATCHPKG_DIR/spkg.lock"
|
||||||
|
|
||||||
|
ROOT_DIR="${ROOT_DIR%/}" # remove trailing slash
|
||||||
|
|
||||||
|
[ "$PRINTDBDIR" ] && {
|
||||||
|
echo "$ROOT_DIR/$PKGDB_DIR"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
# show help page
|
# show help page
|
||||||
[ "$SHOWHELP" ] || [ -z "$PKGNAME" ] && {
|
[ "$SHOWHELP" ] || [ -z "$PKGNAME" ] && {
|
||||||
help
|
help
|
||||||
ret 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -d "$ROOT_DIR/$INDEX_DIR" ] || {
|
[ -d "$ROOT_DIR/$PKGDB_DIR" ] || {
|
||||||
msgerr "Package's database directory not exist! ($ROOT_DIR/$INDEX_DIR)"
|
msgerr "Package's database directory does not exist: $ROOT_DIR/$PKGDB_DIR"
|
||||||
ret 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# check for root access
|
# check for root access
|
||||||
[ "$(id -u)" = "0" ] || {
|
[ "$(id -u)" = "0" ] || {
|
||||||
msgerr "Installing package need root access!"
|
msgerr "Installing packages requires root access!"
|
||||||
ret 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# check for lock file
|
# check for lock file
|
||||||
[ -f "$ROOT_DIR/$LOCK_FILE" ] && {
|
[ -f "$ROOT_DIR/$LOCK_FILE" ] && {
|
||||||
msgerr "Cant install/remove package simultaneously."
|
msgerr "Cannot install/remove package simultaneously."
|
||||||
msgerr "remove '$ROOT_DIR/$LOCK_FILE' if no install/remove package process running."
|
msgerr "remove '$ROOT_DIR/$LOCK_FILE' if no install/remove package process running."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
touch "$ROOT_DIR/$LOCK_FILE" 2>/dev/null || {
|
touch "$ROOT_DIR/$LOCK_FILE" 2>/dev/null || {
|
||||||
msgerr "Cant create lock file in '$ROOT_DIR/$LOCK_FILE'."
|
msgerr "Cannot create lock file in '$ROOT_DIR/$LOCK_FILE'."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +160,7 @@ BASEPKGNAME=$(basename $PKGNAME)
|
|||||||
|
|
||||||
# check existence of package file
|
# check existence of package file
|
||||||
[ -f "$PKGNAME" ] || {
|
[ -f "$PKGNAME" ] || {
|
||||||
msgerr "Package '$1' not exist!"
|
msgerr "Package '$1' does not exist!"
|
||||||
ret 1
|
ret 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,8 +172,8 @@ name=${noextname%-*}
|
|||||||
|
|
||||||
# get package information if installed
|
# get package information if installed
|
||||||
if isinstalled $name; then
|
if isinstalled $name; then
|
||||||
iversion=$(grep ^version $ROOT_DIR/$INDEX_DIR/$name/.pkginfo | cut -d " " -f3-)
|
iversion=$(head -n1 $ROOT_DIR/$PKGDB_DIR/$name | awk '{print $1}')
|
||||||
irelease=$(grep ^release $ROOT_DIR/$INDEX_DIR/$name/.pkginfo | cut -d " " -f3-)
|
irelease=$(head -n1 $ROOT_DIR/$PKGDB_DIR/$name | awk '{print $2}')
|
||||||
ALREADYINSTALLED=yes
|
ALREADYINSTALLED=yes
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -207,7 +201,7 @@ TMP_PKGINSTALL="$ROOT_DIR/$SCRATCHPKG_DIR/.tmp_pkginstall"
|
|||||||
TMP_CONFLICT="$ROOT_DIR/$SCRATCHPKG_DIR/.tmp_conflict"
|
TMP_CONFLICT="$ROOT_DIR/$SCRATCHPKG_DIR/.tmp_conflict"
|
||||||
|
|
||||||
# check integrity of package and save list file/dirs to install in the meantime
|
# check integrity of package and save list file/dirs to install in the meantime
|
||||||
tar -tf $PKGNAME > $TMP_PKGADD 2>/dev/null || {
|
tar -tvf $PKGNAME > $TMP_PKGADD 2>/dev/null || {
|
||||||
msgerr "Package '$1' is corrupted!"
|
msgerr "Package '$1' is corrupted!"
|
||||||
ret 1
|
ret 1
|
||||||
}
|
}
|
||||||
@@ -221,18 +215,22 @@ echo "$opr: $name-$version-$release..."
|
|||||||
|
|
||||||
# check for file conflict
|
# check for file conflict
|
||||||
if [ ! "$IGNORE_CONFLICT" ]; then
|
if [ ! "$IGNORE_CONFLICT" ]; then
|
||||||
grep -Ev "^.pkg*" "$TMP_PKGADD" | grep -v '/$' | while read -r line; do
|
grep -v '/$' "$TMP_PKGADD" | awk '{print $6}' | while read -r line; do
|
||||||
if [ "$line" = "${line%.*}.spkgnew" ]; then
|
if [ "$line" = "${line%.*}.spkgnew" ]; then
|
||||||
line=${line%.*}
|
line=${line%.*}
|
||||||
fi
|
fi
|
||||||
if [ -e "$ROOT_DIR/$line" ] || [ -L "$ROOT_DIR/$line" ]; then
|
if [ -e "$ROOT_DIR/$line" ] || [ -L "$ROOT_DIR/$line" ]; then
|
||||||
if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
|
if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
|
||||||
if ! grep -Fqx "$line" "$ROOT_DIR/$INDEX_DIR/$name/.files"; then
|
if ! grep -Fqx "$line" "$ROOT_DIR/$PKGDB_DIR/$name"; then
|
||||||
echo "$line"
|
_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"
|
touch "$TMP_CONFLICT"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "$line"
|
_f=$(grep -x ^"$line"$ $ROOT_DIR/$PKGDB_DIR/* | cut -d : -f1 | awk -F / '{print $(NF)}' | head -n1)
|
||||||
|
_f=${_f:-(none)}
|
||||||
|
echo "$_f $line"
|
||||||
touch "$TMP_CONFLICT"
|
touch "$TMP_CONFLICT"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -244,32 +242,10 @@ if [ ! "$IGNORE_CONFLICT" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# pre-install and pre-upgrade script
|
|
||||||
if grep -qx .pkginstall $TMP_PKGADD; then
|
|
||||||
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"/
|
|
||||||
run_scripts "$TMP_PKGINSTALL_SCRIPT" pre-install "$version"
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
if [ "$UPGRADE_PKG" ] && [ ! "$NO_PREUPGRADE" ]; then
|
|
||||||
(cd "$ROOT_DIR"/
|
|
||||||
run_scripts "$TMP_PKGINSTALL_SCRIPT" pre-upgrade "$version" "$iversion"
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
rm -f "$ROOT_DIR/$TMP_PKGINSTALL_SCRIPT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# exclude .pkg* files when extract into system
|
|
||||||
for i in $(grep "^.pkg*" $TMP_PKGADD); do
|
|
||||||
excludefile="$excludefile --exclude=$i"
|
|
||||||
done
|
|
||||||
|
|
||||||
rm -f $TMP_PKGINSTALL
|
rm -f $TMP_PKGINSTALL
|
||||||
|
|
||||||
# extract package into ROOT_DIR
|
# extract package into ROOT_DIR
|
||||||
tar --keep-directory-symlink -p -x -v -f "$PKGNAME" -C "$ROOT_DIR"/ $excludefile | while read -r line; do
|
tar -xvhpf "$PKGNAME" -C "$ROOT_DIR"/ | while read -r line; do
|
||||||
if [ "$line" = "${line%.*}.spkgnew" ]; then
|
if [ "$line" = "${line%.*}.spkgnew" ]; then
|
||||||
line=${line%.*}
|
line=${line%.*}
|
||||||
if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
|
if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
|
||||||
@@ -286,54 +262,26 @@ done
|
|||||||
|
|
||||||
# remove old files from old package that not exist in new package
|
# remove old files from old package that not exist in new package
|
||||||
if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
|
if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
|
||||||
rmlist_file="$ROOT_DIR/$SCRATCHPKG_DIR/.rmlist_file"
|
tail -n+2 "$ROOT_DIR/$PKGDB_DIR/$name" | tac | while read -r line; do
|
||||||
rmlist_dir="$ROOT_DIR/$SCRATCHPKG_DIR/.rmlist_dir"
|
case $line in
|
||||||
reserve_dir="$ROOT_DIR/$SCRATCHPKG_DIR/.reserve_dir"
|
*/) grep "^$line$" $ROOT_DIR/$PKGDB_DIR/* "$TMP_PKGINSTALL" 2>/dev/null | grep -qv "$ROOT_DIR/$PKGDB_DIR/$name" || rmdir $([ "$VERBOSE_INSTALL" ] && echo -v) "$ROOT_DIR/$line";;
|
||||||
rmlist_all="$ROOT_DIR/$SCRATCHPKG_DIR/.rmlist_all"
|
*) grep -q "^$line$" "$TMP_PKGINSTALL" || rm $([ "$VERBOSE_INSTALL" ] && echo -v) "$ROOT_DIR/$line";;
|
||||||
grep '/$' $ROOT_DIR/$INDEX_DIR/*/.files \
|
esac
|
||||||
| grep -v $ROOT_DIR/$INDEX_DIR/$name/.files \
|
done
|
||||||
| 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
|
|
||||||
)
|
|
||||||
rm -f "$rmlist_file" "$rmlist_dir" "$reserve_dir" "$rmlist_all"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# register package into database
|
# register package into database
|
||||||
rm -fr "$ROOT_DIR/$INDEX_DIR/$name"
|
echo "$version $release" > "$ROOT_DIR/$PKGDB_DIR/$name"
|
||||||
mkdir "$ROOT_DIR/$INDEX_DIR/$name"
|
cat "$TMP_PKGINSTALL" >> "$ROOT_DIR/$PKGDB_DIR/$name"
|
||||||
echo "name = $name" > "$ROOT_DIR/$INDEX_DIR/$name/.pkginfo"
|
mkdir -p "$ROOT_DIR/$PKGDBPERMS_DIR"
|
||||||
echo "version = $version" >> "$ROOT_DIR/$INDEX_DIR/$name/.pkginfo"
|
rm -f "$ROOT_DIR/$PKGDBPERMS_DIR/$name"
|
||||||
echo "release = $release" >> "$ROOT_DIR/$INDEX_DIR/$name/.pkginfo"
|
grep '/$' $TMP_PKGADD | while read -r perms own junk1 junk2 junk3 dir junk4; do
|
||||||
install -m644 "$TMP_PKGINSTALL" "$ROOT_DIR/$INDEX_DIR/$name/.files"
|
if [ "$perms" != drwxr-xr-x ] || [ "$own" != root/root ]; then
|
||||||
|
echo "$perms $own $dir" >> "$ROOT_DIR/$PKGDBPERMS_DIR/$name"
|
||||||
for ii in $(grep ^.pkg* $TMP_PKGADD); do
|
[ -s "$ROOT_DIR/$PKGDBPERMS_DIR/$name" ] || rm "$ROOT_DIR/$PKGDBPERMS_DIR/$name"
|
||||||
pkgfiles="$pkgfiles $ii"
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$pkgfiles" ]; then
|
|
||||||
tar -x -f "$PKGNAME" -C "$ROOT_DIR/$INDEX_DIR/$name" $pkgfiles >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$ROOT_DIR/$INDEX_DIR/$name/.pkginstall" ]; then
|
|
||||||
if [ ! "$NO_POSTINSTALL" ] && [ ! "$UPGRADE_PKG" ]; then
|
|
||||||
(cd "$ROOT_DIR"/
|
|
||||||
run_scripts "$INDEX_DIR/$name/.pkginstall" post-install "$version"
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
if [ "$UPGRADE_PKG" ] && [ ! "$NO_POSTUPGRADE" ]; then
|
|
||||||
(cd "$ROOT_DIR"/
|
|
||||||
run_scripts "$INDEX_DIR/$name/.pkginstall" post-upgrade "$version" "$iversion"
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# running ldconfig
|
# running ldconfig
|
||||||
if [ -x "$ROOT_DIR"/sbin/ldconfig ]; then
|
if [ -x "$ROOT_DIR"/sbin/ldconfig ]; then
|
||||||
"$ROOT_DIR"/sbin/ldconfig -r "$ROOT_DIR"/
|
"$ROOT_DIR"/sbin/ldconfig -r "$ROOT_DIR"/
|
||||||
|
|||||||
26
pkgbase
26
pkgbase
@@ -1,5 +1,23 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
|
# scratchpkg
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 by Emmett1 (emmett1.2miligrams@gmail.com)
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
# script to remove all packages other than base and any user input
|
# script to remove all packages other than base and any user input
|
||||||
#
|
#
|
||||||
|
|
||||||
@@ -28,6 +46,8 @@ Options:
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error=0
|
||||||
|
|
||||||
parseopt "$@"
|
parseopt "$@"
|
||||||
|
|
||||||
echo "Calculate packages to keep..."
|
echo "Calculate packages to keep..."
|
||||||
@@ -47,8 +67,10 @@ done
|
|||||||
done
|
done
|
||||||
echo "This is dry-run, no real action is run!"
|
echo "This is dry-run, no real action is run!"
|
||||||
} || {
|
} || {
|
||||||
scratch remove $yes $remove
|
scratch remove $yes $remove || error=1
|
||||||
}
|
}
|
||||||
|
} || {
|
||||||
|
echo "Already on base, nothing to remove."
|
||||||
}
|
}
|
||||||
|
|
||||||
exit $?
|
exit $error
|
||||||
|
|||||||
501
pkgbuild
501
pkgbuild
@@ -27,52 +27,53 @@ msg2() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
msgerr() {
|
msgerr() {
|
||||||
echo "==> ERROR: $1"
|
echo "==> ERROR: $1" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
msgwarn() {
|
msgwarn() {
|
||||||
echo "==> WARNING: $1"
|
echo "==> WARNING: $1" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
updatemdsum() {
|
pkg_genchecksums() {
|
||||||
msg "Generating .checksums..."
|
for i in $(get_filepath); do
|
||||||
|
[ -f "$i" ] || {
|
||||||
|
msgerr "File missing: $i"
|
||||||
|
err=1
|
||||||
|
}
|
||||||
|
done
|
||||||
|
[ "$err" = 1 ] && abort 1
|
||||||
generatemdsum > .checksums
|
generatemdsum > .checksums
|
||||||
|
msg "Checksums updated."
|
||||||
}
|
}
|
||||||
|
|
||||||
generatemdsum() {
|
generatemdsum() {
|
||||||
if [ -z "$source" ]; then
|
for s in $(get_filepath); do
|
||||||
echo SKIP
|
if [ -f $s ]; then
|
||||||
return 0
|
needupdatechecksum="$needupdatechecksum $s"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for src in $source; do
|
|
||||||
if echo $src | grep -qE "::(ftp|http|https)://"; then
|
|
||||||
FILENAME=$SOURCE_DIR/$(echo $src | awk -F '::' '{print $1}')
|
|
||||||
elif echo $src | grep -qE "(ftp|http|https)://"; then
|
|
||||||
FILENAME=$SOURCE_DIR/$(basename $src)
|
|
||||||
else
|
|
||||||
FILENAME=$src
|
|
||||||
fi
|
|
||||||
needupdatechecksum="$needupdatechecksum $FILENAME"
|
|
||||||
done
|
done
|
||||||
|
if [ "$needupdatechecksum" ]; then
|
||||||
md5sum $needupdatechecksum | sed -e 's| .*/| |' | sort -k 2
|
md5sum $needupdatechecksum | sed -e 's| .*/| |' | sort -k 2
|
||||||
|
else
|
||||||
|
echo SKIP
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
checkmdsum() {
|
pkg_checksum() {
|
||||||
TMPCHECKSUM=$WORK_DIR/checksumstmp.$$
|
TMPCHECKSUM=$WORK_DIR/checksumstmp.$$
|
||||||
ORICHECKSUM=$WORK_DIR/checksumsori.$$
|
ORICHECKSUM=$WORK_DIR/checksumsori.$$
|
||||||
DIFCHECKSUM=$WORK_DIR/checksumsdiff.$$
|
DIFCHECKSUM=$WORK_DIR/checksumsdiff.$$
|
||||||
|
|
||||||
if [ ! -f .checksums ]; then
|
if [ ! -f .checksums ]; then
|
||||||
msg "Generating .checksums..."
|
pkg_genchecksums
|
||||||
generatemdsum > .checksums
|
|
||||||
else
|
else
|
||||||
|
if [ "$IGNORE_MDSUM" != "yes" ] && [ "$IGNORE_MDSUM" != 1 ]; then
|
||||||
msg "Checking checksums..."
|
msg "Checking checksums..."
|
||||||
generatemdsum > "$TMPCHECKSUM"
|
generatemdsum > "$TMPCHECKSUM"
|
||||||
sort -k2 .checksums > "$ORICHECKSUM"
|
sort -k2 .checksums > "$ORICHECKSUM"
|
||||||
diff -w -t -U 0 "$ORICHECKSUM" "$TMPCHECKSUM" > "$DIFCHECKSUM"
|
diff -w -t -U 0 "$ORICHECKSUM" "$TMPCHECKSUM" > "$DIFCHECKSUM"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
[ -s "$DIFCHECKSUM" ] && {
|
[ -s "$DIFCHECKSUM" ] && {
|
||||||
mismatch=1
|
mismatch=1
|
||||||
@@ -89,53 +90,38 @@ checkmdsum() {
|
|||||||
[ "$mismatch" = 1 ] && abort 1
|
[ "$mismatch" = 1 ] && abort 1
|
||||||
}
|
}
|
||||||
|
|
||||||
download_src() {
|
get_filepath() {
|
||||||
for FILE in $source; do
|
for i in $source; do
|
||||||
if echo $FILE | grep -Eq '::(http|https|ftp)://'; then
|
case $i in
|
||||||
FILENAME=$(echo $FILE | awk -F '::' '{print $1}')
|
*::*) echo $SOURCE_DIR/${i%::*};;
|
||||||
SRCURL=$(echo $FILE | awk -F '::' '{print $2}')
|
*://*) echo $SOURCE_DIR/${i##*/};;
|
||||||
else
|
*) echo $PWD/$i;;
|
||||||
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
|
esac
|
||||||
if [ "$FILENAME" != "$FILE" ]; then
|
|
||||||
if [ ! -f "$SOURCE_DIR/$FILENAME" ] || [ "$REDOWNLOAD_SOURCE" ]; then
|
|
||||||
[ "$REDOWNLOAD_SOURCE" ] && rm -f "$SOURCE_DIR/$FILENAME.partial"
|
|
||||||
if [ -f "$SOURCE_DIR/$FILENAME.partial" ]; then
|
|
||||||
msg "Resuming '$SRCURL'."
|
|
||||||
else
|
|
||||||
msg "Downloading '$SRCURL'."
|
|
||||||
fi
|
|
||||||
$DLCMD $SRCURL
|
|
||||||
if [ $? = 0 ]; then
|
|
||||||
[ "$REDOWNLOAD_SOURCE" ] && rm -f "$SOURCE_DIR/$FILENAME"
|
|
||||||
mv $SOURCE_DIR/$FILENAME.partial $SOURCE_DIR/$FILENAME
|
|
||||||
else
|
|
||||||
msgerr "Failed downloading '$FILENAME'."
|
|
||||||
abort 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ ! -f "$FILENAME" ]; then
|
|
||||||
msgerr "Source '$FILENAME' not found."
|
|
||||||
abort 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_src() {
|
pkg_fetch() {
|
||||||
[ "$IGNORE_MDSUM" -o "$CHECK_MDSUM" = 0 ] || checkmdsum
|
for i in $source; do
|
||||||
|
case $i in
|
||||||
|
*::*) filepath="$SOURCE_DIR/${i%::*}"; url=${i#*::};;
|
||||||
|
*://*) filepath="$SOURCE_DIR/${i##*/}"; url=$i;;
|
||||||
|
*) continue;;
|
||||||
|
esac
|
||||||
|
[ -f "$filepath" ] && {
|
||||||
|
msg "Source found: $filepath"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
[ -f "$filepath.partial" ] && COPT="-C -"
|
||||||
|
msg "Fetching: $i"
|
||||||
|
curl $COPT -L --fail --ftp-pasv --retry 3 --retry-delay 3 -o $filepath.partial $CURL_OPTS $url || {
|
||||||
|
msgerr "Fetching failed: $i"
|
||||||
|
abort 1
|
||||||
|
}
|
||||||
|
mv $filepath.partial $filepath
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
pkg_unpack() {
|
||||||
SRC=$WORK_DIR/$name/src
|
SRC=$WORK_DIR/$name/src
|
||||||
PKG=$WORK_DIR/$name/pkg
|
PKG=$WORK_DIR/$name/pkg
|
||||||
|
|
||||||
@@ -145,83 +131,84 @@ prepare_src() {
|
|||||||
|
|
||||||
mkdir -p $SRC $PKG
|
mkdir -p $SRC $PKG
|
||||||
|
|
||||||
if [ "$source" ]; then
|
TAR=tar
|
||||||
for FILE in $source; do
|
[ $(command -v bsdtar) ] && TAR=bsdtar
|
||||||
if echo $FILE | grep -Eq '::(http|https|ftp)://'; then
|
|
||||||
FILENAME=$SOURCE_DIR/$(echo $FILE | awk -F '::' '{print $1}')
|
for i in $(get_filepath); do
|
||||||
elif echo $FILE | grep -Eq '^(http|https|ftp)://'; then
|
if [ ! -f "$i" ]; then
|
||||||
FILENAME=$SOURCE_DIR/$(basename $FILE)
|
msgerr "Source missing: $i"
|
||||||
else
|
abort 1
|
||||||
FILENAME=$PWD/$(basename $FILE)
|
|
||||||
fi
|
fi
|
||||||
for NOEXT in $noextract; do
|
for n in $noextract; do
|
||||||
if [ "$NOEXT" = "$(basename $FILENAME)" ]; then
|
if [ ${i##*/} = $n ]; then
|
||||||
nxt=1
|
msg "Preparing: $i"
|
||||||
break
|
cp $i $SRC || {
|
||||||
|
msgerr "Preparing failed: $i"
|
||||||
|
abort 1
|
||||||
|
}
|
||||||
|
continue 2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ "$FILENAME" != "$FILE" ] && [ "$nxt" != 1 ]; then
|
case $i in
|
||||||
case $FILENAME in
|
*.tar|*.tar.gz|*.tar.Z|*.tgz|*.tar.bz2|*.tar.lz|*.tbz2|*.tar.xz|*.txz|*.tar.lzma|*.zip|*.rpm)
|
||||||
*.tar|*.tar.gz|*.tar.Z|*.tgz|*.tar.bz2|*.tbz2|*.tar.xz|*.txz|*.tar.lzma|*.zip|*.rpm)
|
msg "Unpacking: $i"
|
||||||
if [ $(command -v bsdtar) ]; then
|
$TAR -p -o -C $SRC -xf $i;;
|
||||||
COMMAND="bsdtar -p -o -C $SRC -xf $FILENAME"
|
|
||||||
else
|
|
||||||
COMMAND="tar -p -o -C $SRC -xf $FILENAME"
|
|
||||||
fi
|
|
||||||
MODE="Unpacking" ;;
|
|
||||||
*)
|
*)
|
||||||
COMMAND="cp $FILENAME $SRC"
|
msg "Preparing: $i"
|
||||||
MODE="Preparing" ;;
|
cp $i $SRC;;
|
||||||
esac
|
esac
|
||||||
msg "$MODE '$(basename $FILENAME)'..."
|
[ $? = 0 ] || {
|
||||||
$COMMAND || {
|
msgerr "Unpacking/Preparing failed: $i"
|
||||||
msgerr "$MODE '$FILENAME' failed."
|
|
||||||
abort 1
|
abort 1
|
||||||
}
|
}
|
||||||
else
|
|
||||||
MODE="Preparing"
|
|
||||||
msg "$MODE '$(basename $FILENAME)'..."
|
|
||||||
cp "$FILENAME" "$SRC" || {
|
|
||||||
msgerr "$MODE '$FILENAME' failed."
|
|
||||||
abort 1
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
unset nxt
|
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run_build() {
|
pkg_build() {
|
||||||
[ "$(id -u)" = 0 ] || {
|
[ "$(id -u)" = 0 ] || {
|
||||||
msgerr "You must build package as root, or use fakeroot."
|
msgerr "You must build package as root, or use fakeroot."
|
||||||
abort 1
|
abort 1
|
||||||
}
|
}
|
||||||
|
|
||||||
msg "Start build '$name-$version-$release'."
|
msg "Build start: $name-$version-$release"
|
||||||
|
|
||||||
[ "$MAKE_FLAGS" = 1 ] && export MAKEFLAGS || unset MAKEFLAGS
|
|
||||||
[ "$BUILD_FLAGS" = 1 ] && export CFLAGS CXXFLAGS || unset CFLAGS CXXFLAGS
|
|
||||||
|
|
||||||
cd $SRC >/dev/null
|
cd $SRC >/dev/null
|
||||||
|
if [ "$QUIET" ]; then
|
||||||
|
(set -e -x; build) 2> /dev/null
|
||||||
|
else
|
||||||
(set -e -x; build 2>&1)
|
(set -e -x; build 2>&1)
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
msgerr "Build '$name-$version-$release' failed."
|
msgerr "Build failed: $name-$version-$release"
|
||||||
abort 1
|
abort 1
|
||||||
else
|
else
|
||||||
msg "Build '$name-$version-$release' success."
|
msg "Build success: $name-$version-$release"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd - >/dev/null
|
cd - >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
removeemptydirs() {
|
pkglint() {
|
||||||
find . -type d -empty -delete
|
linterror=0
|
||||||
}
|
|
||||||
|
|
||||||
removelibtool() {
|
# cant package empty PKG
|
||||||
find . ! -type d -name "*.la" -delete
|
if [ ! "$(find $PKG/* -maxdepth 1 -type d 2>/dev/null)" ]; then
|
||||||
|
msgerr "PKG is empty"
|
||||||
|
abort 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check for backup file
|
||||||
|
for f in $backup; do
|
||||||
|
if [ ! -f $PKG/$f ]; then
|
||||||
|
msgerr "Backup file '$f' does not exist in PKG!"
|
||||||
|
linterror=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$linterror" = 1 ]; then
|
||||||
|
abort 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
strip_files() {
|
strip_files() {
|
||||||
@@ -237,20 +224,20 @@ strip_files() {
|
|||||||
find . -type f -printf "%P\n" 2>/dev/null | $FILTER | while read -r binary ; do
|
find . -type f -printf "%P\n" 2>/dev/null | $FILTER | while read -r binary ; do
|
||||||
case "$(file -bi "$binary")" in
|
case "$(file -bi "$binary")" in
|
||||||
*application/x-sharedlib*) # Libraries (.so)
|
*application/x-sharedlib*) # Libraries (.so)
|
||||||
strip --strip-unneeded "$binary" 2>/dev/null ;;
|
${CROSS_COMPILE}strip --strip-unneeded "$binary" 2>/dev/null ;;
|
||||||
*application/x-pie-executable*) # Libraries (.so)
|
*application/x-pie-executable*) # Libraries (.so)
|
||||||
strip --strip-unneeded "$binary" 2>/dev/null ;;
|
${CROSS_COMPILE}strip --strip-unneeded "$binary" 2>/dev/null ;;
|
||||||
*application/x-archive*) # Libraries (.a)
|
*application/x-archive*) # Libraries (.a)
|
||||||
strip --strip-debug "$binary" 2>/dev/null ;;
|
${CROSS_COMPILE}strip --strip-debug "$binary" 2>/dev/null ;;
|
||||||
*application/x-object*)
|
*application/x-object*)
|
||||||
case "$binary" in
|
case "$binary" in
|
||||||
*.ko) # Kernel module
|
*.ko) # Kernel module
|
||||||
strip --strip-unneeded "$binary" 2>/dev/null ;;
|
${CROSS_COMPILE}strip --strip-unneeded "$binary" 2>/dev/null ;;
|
||||||
*)
|
*)
|
||||||
continue;;
|
continue;;
|
||||||
esac;;
|
esac;;
|
||||||
*application/x-executable*) # Binaries
|
*application/x-executable*) # Binaries
|
||||||
strip --strip-all "$binary" 2>/dev/null ;;
|
${CROSS_COMPILE}strip --strip-all "$binary" 2>/dev/null ;;
|
||||||
*)
|
*)
|
||||||
continue ;;
|
continue ;;
|
||||||
esac
|
esac
|
||||||
@@ -258,12 +245,12 @@ strip_files() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compressinfomanpages() {
|
compressinfomanpages() {
|
||||||
find . -type f -path "*/man/man*/*" | while read -r file; do
|
find . -type f -path "*/share/man/*" | while read -r file; do
|
||||||
if [ "$file" = "${file%%.gz}" ]; then
|
if [ "$file" = "${file%%.gz}" ]; then
|
||||||
gzip -9 -f "$file"
|
gzip -9 -f "$file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
find . -type l -path "*/man/man*/*" | while read -r file; do
|
find . -type l -path "*/share/man/*" | while read -r file; do
|
||||||
FILE="${file%%.gz}.gz"
|
FILE="${file%%.gz}.gz"
|
||||||
TARGET="$(readlink $file)"
|
TARGET="$(readlink $file)"
|
||||||
TARGET="${TARGET##*/}"
|
TARGET="${TARGET##*/}"
|
||||||
@@ -274,53 +261,16 @@ compressinfomanpages() {
|
|||||||
ln -sf $TARGET $FILE
|
ln -sf $TARGET $FILE
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ -d usr/share/info ]; then
|
find . -type f -path "*/share/info/*" | while read -r file; do
|
||||||
(cd usr/share/info
|
|
||||||
for file in $(find . -type f); do
|
|
||||||
if [ "$file" = "${file%%.gz}" ]; then
|
if [ "$file" = "${file%%.gz}" ]; then
|
||||||
gzip -9 "$file"
|
gzip -9 -f "$file"
|
||||||
fi
|
|
||||||
done
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
backupconf() {
|
|
||||||
for FILE in $backup; do
|
|
||||||
if [ ! -f $FILE ]; then
|
|
||||||
msgerr "File '$FILE' not exist!"
|
|
||||||
abort 1
|
|
||||||
else
|
|
||||||
mv $FILE $FILE.spkgnew
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
removedocs() {
|
pkg_package() {
|
||||||
for i in doc gtk-doc info; do
|
# lint $PKG before packaging
|
||||||
rm -fr \
|
pkglint
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
packaging() {
|
|
||||||
for FILE in $INCLUDEINPKG; do
|
|
||||||
if [ -f $FILE ]; then
|
|
||||||
install -m644 $FILE $PKG/.pkg$FILE
|
|
||||||
addtotar="$addtotar .pkg$FILE"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
cd $PKG >/dev/null
|
cd $PKG >/dev/null
|
||||||
|
|
||||||
@@ -332,18 +282,28 @@ packaging() {
|
|||||||
find usr/share/fonts \( -name fonts.dir -o -name fonts.scale \) -delete
|
find usr/share/fonts \( -name fonts.dir -o -name fonts.scale \) -delete
|
||||||
}
|
}
|
||||||
|
|
||||||
# remove pseudo directories
|
if [ "$KEEP_LIBTOOL" = 0 ] || [ "$KEEP_LIBTOOL" = "no" ]; then
|
||||||
#rm -fr dev sys proc run tmp
|
find . ! -type d -name "*.la" -delete
|
||||||
|
fi
|
||||||
|
|
||||||
[ "$KEEP_EMPTYDIR" = 0 ] && removeemptydirs
|
if [ "$KEEP_LOCALE" = 0 ] || [ "$KEEP_LOCALE" = "no" ]; then
|
||||||
[ "$KEEP_LIBTOOL" = 0 ] && removelibtool
|
rm -fr usr/share/locale usr/locale usr/lib/locale
|
||||||
[ "$STRIP_BINARY" = 1 ] && strip_files
|
fi
|
||||||
[ "$ZIP_MAN" = 1 ] && compressinfomanpages
|
|
||||||
[ "$KEEP_DOCS" = 0 ] && removedocs
|
|
||||||
[ "$KEEP_LOCALES" = 0 ] && removelocales
|
|
||||||
|
|
||||||
if [ "${#backup[@]}" -gt 0 ]; then
|
if [ "$KEEP_DOC" = 0 ] || [ "$KEEP_DOC" = "no" ]; then
|
||||||
backupconf
|
rm -fr usr/share/doc usr/share/gtk-doc usr/doc usr/gtk-doc
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$NO_STRIP" = 0 ] || [ "$NO_STRIP" = "no" ]; then
|
||||||
|
strip_files
|
||||||
|
fi
|
||||||
|
|
||||||
|
compressinfomanpages
|
||||||
|
|
||||||
|
if [ "$backup" ]; then
|
||||||
|
for FILE in $backup; do
|
||||||
|
mv $FILE $FILE.spkgnew
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ "$FORCE_REBUILD" ] && rm -f "$PACKAGE_DIR/$PKGNAME"
|
[ "$FORCE_REBUILD" ] && rm -f "$PACKAGE_DIR/$PKGNAME"
|
||||||
@@ -352,118 +312,85 @@ packaging() {
|
|||||||
xz) COMPRESS="-J" ;;
|
xz) COMPRESS="-J" ;;
|
||||||
gz) COMPRESS="-z" ;;
|
gz) COMPRESS="-z" ;;
|
||||||
bz2) COMPRESS="-j" ;;
|
bz2) COMPRESS="-j" ;;
|
||||||
|
lz4) COMPRESS="--lz4" ;;
|
||||||
|
zstd) COMPRESS="--zstd" ;;
|
||||||
esac
|
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
|
rm -f $PACKAGE_DIR/$PKGNAME
|
||||||
msgerr "Packaging '$PKGNAME' failed."
|
msgerr "Packaging failed: $PKGNAME"
|
||||||
abort 1
|
abort 1
|
||||||
}
|
}
|
||||||
|
|
||||||
tar -tvf $PACKAGE_DIR/$PKGNAME | sort -k 6
|
tar -tvf $PACKAGE_DIR/$PKGNAME | sort -k 6
|
||||||
|
|
||||||
msg "Successfully created package '$PKGNAME'. ($(ls -lh $PACKAGE_DIR/$PKGNAME | awk '{print $5}'))"
|
msg "Packaging success: $PKGNAME ($(ls -lh $PACKAGE_DIR/$PKGNAME | awk '{print $5}'))"
|
||||||
|
|
||||||
cd - >/dev/null
|
cd - >/dev/null
|
||||||
|
|
||||||
[ -f .pkgfiles ] || generate_pkgfiles
|
if [ ! -f .pkgfiles ] || [ "$(head -n1 .pkgfiles)" != "$name-$version-$release" ]; then
|
||||||
|
pkg_genpkgfiles
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_pkgfiles() {
|
pkg_genpkgfiles() {
|
||||||
[ -f "$PACKAGE_DIR/$PKGNAME" ] || {
|
[ -f "$PACKAGE_DIR/$PKGNAME" ] || {
|
||||||
msgerr "Package '$PKGNAME' not found."
|
msgerr "Package not found: $PKGNAME"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in $INCLUDEINPKG; do
|
echo "$name-$version-$release" > .pkgfiles
|
||||||
excludefile="$excludefile --exclude=.pkg$i"
|
|
||||||
done
|
|
||||||
|
|
||||||
msg "Generating .pkgfiles..."
|
tar -tvf "$PACKAGE_DIR/$PKGNAME" \
|
||||||
tar -tvf "$PACKAGE_DIR/$PKGNAME" $excludefile \
|
|
||||||
| awk '{$3=$4=$5=""; print $0}' \
|
| awk '{$3=$4=$5=""; print $0}' \
|
||||||
| sed "s,lib/modules/$(uname -r),lib/modules/<kernelversion>,g" \
|
| sort -k 3 >> .pkgfiles
|
||||||
| sort -k 3 > .pkgfiles
|
msg "Pkgfiles updated."
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup() {
|
pkg_clean() {
|
||||||
[ -e "$PACKAGE_DIR/$PKGNAME" ] && {
|
[ -e "$PACKAGE_DIR/$PKGNAME" ] && {
|
||||||
msg "Removing $PACKAGE_DIR/$PKGNAME"
|
|
||||||
rm -f "$PACKAGE_DIR/$PKGNAME"
|
rm -f "$PACKAGE_DIR/$PKGNAME"
|
||||||
|
msg "Package removed: $PACKAGE_DIR/$PKGNAME"
|
||||||
|
}
|
||||||
|
for i in $(get_filepath); do
|
||||||
|
case $i in
|
||||||
|
$PWD/*) continue;;
|
||||||
|
esac
|
||||||
|
[ -e "$i" ] && {
|
||||||
|
rm -f "$i"
|
||||||
|
msg "File removed: $i"
|
||||||
|
}
|
||||||
|
[ -e "$i.partial" ] && {
|
||||||
|
rm -f "$i.partial"
|
||||||
|
msg "File removed: $i.partial"
|
||||||
}
|
}
|
||||||
for src in $source; do
|
|
||||||
if echo $src | grep -qE "::(ftp|http|https)://"; then
|
|
||||||
FILENAME=$SOURCE_DIR/$(echo $src | awk -F '::' '{print $1}')
|
|
||||||
elif echo $src | grep -qE "^(ftp|http|https)://"; then
|
|
||||||
FILENAME=$SOURCE_DIR/$(basename $src)
|
|
||||||
else
|
|
||||||
FILENAME=$src
|
|
||||||
fi
|
|
||||||
if [ -e "$FILENAME" ] && [ "$FILENAME" != "$src" ]; then
|
|
||||||
msg "Removing $FILENAME"
|
|
||||||
rm -f "$FILENAME"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
check_buildscript() {
|
check_buildscript() {
|
||||||
# check the required field in buildscript
|
# check the required field in buildscript
|
||||||
if [ -z "$name" ]; then
|
[ "$name" ] || { msgerr "'name' is empty!"; exit 1; }
|
||||||
msgerr "'name' is empty!"
|
case $name in
|
||||||
exit 1
|
*[A-Z]*) msgerr "Capital letters for port name are not allowed!"; exit 1;;
|
||||||
elif [ "$(basename $(pwd))" != "$name" ]; then
|
|
||||||
msgerr "Port name and Directory name is different!"
|
|
||||||
exit 1
|
|
||||||
elif [ -z "$version" ]; then
|
|
||||||
msgerr "'version' is empty!"
|
|
||||||
exit 1
|
|
||||||
elif [ -z "$release" ]; then
|
|
||||||
msgerr "'release' is empty!"
|
|
||||||
exit 1
|
|
||||||
elif [ ! "$(command -v build)" ]; then
|
|
||||||
msgerr "'build' function not exist!"
|
|
||||||
exit 1
|
|
||||||
elif echo "$version" | grep -q '-'; then
|
|
||||||
msgerr "'version' should not contain '-'."
|
|
||||||
exit 1
|
|
||||||
elif echo "$release" | grep -q '-'; then
|
|
||||||
msgerr "'release' should not contain '-'."
|
|
||||||
exit 1
|
|
||||||
elif [ -z "$description" ]; then
|
|
||||||
msgerr "'description' cant empty."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
set_options() {
|
|
||||||
for OPT in $OPTIONS $options; do
|
|
||||||
case $OPT in
|
|
||||||
libtool) KEEP_LIBTOOL=1 ;;
|
|
||||||
!libtool) KEEP_LIBTOOL=0 ;;
|
|
||||||
emptydirs) KEEP_EMPTYDIR=1;;
|
|
||||||
!emptydirs) KEEP_EMPTYDIR=0;;
|
|
||||||
strip) STRIP_BINARY=1 ;;
|
|
||||||
!strip) STRIP_BINARY=0 ;;
|
|
||||||
zipman) ZIP_MAN=1 ;;
|
|
||||||
!zipman) ZIP_MAN=0 ;;
|
|
||||||
buildflags) BUILD_FLAGS=1 ;;
|
|
||||||
!buildflags) BUILD_FLAGS=0 ;;
|
|
||||||
makeflags) MAKE_FLAGS=1 ;;
|
|
||||||
!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
|
esac
|
||||||
done
|
[ "$(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 -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; }
|
||||||
}
|
}
|
||||||
|
|
||||||
checkdir() {
|
checkdir() {
|
||||||
for DIR in "$@"; do
|
for DIR in "$@"; do
|
||||||
if [ ! -d $DIR ]; then
|
if [ ! -d $DIR ]; then
|
||||||
msgerr "Directory '$DIR' not exist."
|
msgerr "Directory '$DIR' does not exist."
|
||||||
exit 1
|
exit 1
|
||||||
elif [ ! -w $DIR ]; then
|
elif [ ! -w $DIR ]; then
|
||||||
msgerr "Directory '$DIR' not writable."
|
msgerr "Directory '$DIR' not writable."
|
||||||
@@ -475,10 +402,10 @@ checkdir() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
clearworkdir() {
|
pkg_cleanup() {
|
||||||
if [ ! "$KEEP_WORK" ]; then
|
if [ ! "$KEEP_WORK" ]; then
|
||||||
if [ "$name" ]; then
|
if [ "$name" ]; then
|
||||||
rm -fr $WORK_DIR/$name
|
rm -fr "$WORK_DIR/$name"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -490,13 +417,14 @@ interrupted() {
|
|||||||
|
|
||||||
abort() {
|
abort() {
|
||||||
rm -f "$LOCK_FILE"
|
rm -f "$LOCK_FILE"
|
||||||
clearworkdir
|
pkg_cleanup
|
||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_opts() {
|
parse_opts() {
|
||||||
while [ "$1" ]; do
|
while [ "$1" ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
|
-q | --quiet) QUIET=yes ;;
|
||||||
-i | --install) INSTALL_PKG=yes ;;
|
-i | --install) INSTALL_PKG=yes ;;
|
||||||
-u | --upgrade) UPGRADE_PKG=yes; OPTS="$OPTS $1" ;;
|
-u | --upgrade) UPGRADE_PKG=yes; OPTS="$OPTS $1" ;;
|
||||||
-r | --reinstall) REINSTALL_PKG=yes; OPTS="$OPTS $1" ;;
|
-r | --reinstall) REINSTALL_PKG=yes; OPTS="$OPTS $1" ;;
|
||||||
@@ -511,13 +439,8 @@ parse_opts() {
|
|||||||
-p | --pkgfiles) GENPKGFILES=yes ;;
|
-p | --pkgfiles) GENPKGFILES=yes ;;
|
||||||
-h | --help) SHOWHELP=yes ;;
|
-h | --help) SHOWHELP=yes ;;
|
||||||
--clean) CLEANUP=yes ;;
|
--clean) CLEANUP=yes ;;
|
||||||
--root=*) OPTS="$OPTS $1" ;;
|
|
||||||
--no-preinstall) OPTS="$OPTS $1" ;;
|
|
||||||
--no-postinstall) OPTS="$OPTS $1" ;;
|
|
||||||
--no-preupgrade) OPTS="$OPTS $1" ;;
|
|
||||||
--no-postupgrade) OPTS="$OPTS $1" ;;
|
|
||||||
--no-backup) OPTS="$OPTS $1" ;;
|
--no-backup) OPTS="$OPTS $1" ;;
|
||||||
--redownload) REDOWNLOAD_SOURCE=yes ;;
|
--root=*) OPTS="$OPTS $1" ;;
|
||||||
--config=*) PKGBUILD_CONF="${1#*=}" ;;
|
--config=*) PKGBUILD_CONF="${1#*=}" ;;
|
||||||
--srcdir=*) CUSTOM_SOURCE_DIR="${1#*=}" ;;
|
--srcdir=*) CUSTOM_SOURCE_DIR="${1#*=}" ;;
|
||||||
--pkgdir=*) CUSTOM_PACKAGE_DIR="${1#*=}" ;;
|
--pkgdir=*) CUSTOM_PACKAGE_DIR="${1#*=}" ;;
|
||||||
@@ -534,6 +457,7 @@ Usage:
|
|||||||
$(basename $0) [ <options> <arguments> ]
|
$(basename $0) [ <options> <arguments> ]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
-q --quiet show only status messages and errors
|
||||||
-i, --install install package into system
|
-i, --install install package into system
|
||||||
-u, --upgrade upgrade package
|
-u, --upgrade upgrade package
|
||||||
-r, --reinstall reinstall package
|
-r, --reinstall reinstall package
|
||||||
@@ -552,12 +476,7 @@ Options:
|
|||||||
--srcdir=<path> override directory path for sources
|
--srcdir=<path> override directory path for sources
|
||||||
--pkgdir=<path> override directory path for compiled package
|
--pkgdir=<path> override directory path for compiled package
|
||||||
--workdir=<path> override directory path for working dir
|
--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
|
--no-backup skip backup configuration file when upgrading package
|
||||||
--redownload re-download source file
|
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@@ -584,7 +503,7 @@ main() {
|
|||||||
if [ -f "$PKGBUILD_CONF" ]; then
|
if [ -f "$PKGBUILD_CONF" ]; then
|
||||||
. "$PKGBUILD_CONF"
|
. "$PKGBUILD_CONF"
|
||||||
else
|
else
|
||||||
msgerr "Config file not found ('$PKGBUILD_CONF')"
|
msgerr "Config file not found: $PKGBUILD_CONF"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -609,42 +528,39 @@ main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
check_buildscript
|
check_buildscript
|
||||||
set_options
|
|
||||||
|
|
||||||
case $COMPRESSION_MODE in
|
case $COMPRESSION_MODE in
|
||||||
gz|bz2|xz) PKGNAME="$name-$version-$release.spkg.tar.$COMPRESSION_MODE" ;;
|
gz|bz2|xz|lz4|zstd) PKGNAME="$name-$version-$release.spkg.tar.$COMPRESSION_MODE" ;;
|
||||||
*) msgerr "Invalid compression mode. ($COMPRESSION_MODE)"; exit 1 ;;
|
*) msgerr "Invalid compression mode: $COMPRESSION_MODE"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# generate .pkgfiles
|
# generate .pkgfiles
|
||||||
[ "$GENPKGFILES" ] && {
|
[ "$GENPKGFILES" ] && {
|
||||||
generate_pkgfiles
|
pkg_genpkgfiles
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# download source only
|
# download source only
|
||||||
[ "$DOWNLOAD_ONLY" ] && {
|
[ "$DOWNLOAD_ONLY" ] && {
|
||||||
download_src
|
pkg_fetch
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# extract source only
|
# extract source only
|
||||||
[ "$EXTRACT_ONLY" ] && {
|
[ "$EXTRACT_ONLY" ] && {
|
||||||
download_src
|
pkg_unpack
|
||||||
prepare_src
|
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# update md5sum
|
# update md5sum
|
||||||
[ "$UPDATE_MDSUM" ] && {
|
[ "$UPDATE_MDSUM" ] && {
|
||||||
download_src
|
pkg_genchecksums
|
||||||
updatemdsum
|
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# remove source and package
|
# remove source and package
|
||||||
[ "$CLEANUP" ] && {
|
[ "$CLEANUP" ] && {
|
||||||
cleanup
|
pkg_clean
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -652,30 +568,41 @@ main() {
|
|||||||
|
|
||||||
# check for lock file
|
# check for lock file
|
||||||
[ -f "$LOCK_FILE" ] && {
|
[ -f "$LOCK_FILE" ] && {
|
||||||
msgerr "Cant build same package simultaneously."
|
msgerr "Cannot build same package simultaneously."
|
||||||
msgerr "remove '$LOCK_FILE' if no build process for '$name'."
|
msgerr "remove '$LOCK_FILE' if no build process for '$name'."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# create lock file
|
# create lock file
|
||||||
touch "$LOCK_FILE" 2>/dev/null || {
|
touch "$LOCK_FILE" 2>/dev/null || {
|
||||||
msgerr "Cant create lock file in '$LOCK_FILE'."
|
msgerr "Cannot create lock file in '$LOCK_FILE'."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# build package
|
# build package
|
||||||
if [ -f "$PACKAGE_DIR/$PKGNAME" ] && [ ! "$FORCE_REBUILD" ]; then
|
if [ -f "$PACKAGE_DIR/$PKGNAME" ] && [ ! "$FORCE_REBUILD" ]; then
|
||||||
if [ ! "$INSTALL_PKG" ] && [ ! "$REINSTALL_PKG" ] && [ ! "$UPGRADE_PKG" ]; then
|
if [ ! "$INSTALL_PKG" ] && [ ! "$REINSTALL_PKG" ] && [ ! "$UPGRADE_PKG" ]; then
|
||||||
echo "Package '$PKGNAME' is up-to-date."
|
msg "Package is up-to-date: $PKGNAME"
|
||||||
abort 0
|
abort 0
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
msg "Building '$name-$version-$release'..."
|
if [ "$QUIET" ]; then
|
||||||
download_src
|
msg "Building: $name-$version-$release"
|
||||||
prepare_src
|
pkg_fetch 2> /dev/null
|
||||||
run_build
|
pkg_checksum > /dev/null
|
||||||
packaging
|
pkg_unpack > /dev/null
|
||||||
clearworkdir
|
pkg_build > /dev/null
|
||||||
|
pkg_package > /dev/null
|
||||||
|
pkg_cleanup > /dev/null
|
||||||
|
else
|
||||||
|
msg "Building: $name-$version-$release"
|
||||||
|
pkg_fetch
|
||||||
|
pkg_checksum
|
||||||
|
pkg_unpack
|
||||||
|
pkg_build
|
||||||
|
pkg_package
|
||||||
|
pkg_cleanup
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install package
|
# install package
|
||||||
@@ -696,11 +623,11 @@ PKGBUILD_BSCRIPT="spkgbuild"
|
|||||||
SOURCE_DIR="/var/cache/scratchpkg/sources"
|
SOURCE_DIR="/var/cache/scratchpkg/sources"
|
||||||
PACKAGE_DIR="/var/cache/scratchpkg/packages"
|
PACKAGE_DIR="/var/cache/scratchpkg/packages"
|
||||||
WORK_DIR="/var/cache/scratchpkg/work"
|
WORK_DIR="/var/cache/scratchpkg/work"
|
||||||
DOWNLOAD_PROG="auto"
|
|
||||||
COMPRESSION_MODE="xz"
|
COMPRESSION_MODE="xz"
|
||||||
|
NO_STRIP="no"
|
||||||
OPTIONS="!libtool emptydirs strip zipman buildflags makeflags checksum !docs !locales"
|
IGNORE_MDSUM="no"
|
||||||
|
KEEP_LIBTOOL="no"
|
||||||
INCLUDEINPKG="install readme mkdirs"
|
KEEP_LOCALE="no"
|
||||||
|
KEEP_DOC="no"
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
88
pkgbuild.8
88
pkgbuild.8
@@ -1,88 +0,0 @@
|
|||||||
." Man page for pkgbuild
|
|
||||||
."
|
|
||||||
.TH pkgbuild 8 "" ""
|
|
||||||
.SH NAME
|
|
||||||
pkgbuild - package creator
|
|
||||||
|
|
||||||
.SH SYNOPSIS
|
|
||||||
pkgbuild <options>
|
|
||||||
|
|
||||||
.SH DESCRIPTION
|
|
||||||
\fIpkgbuild\fP is a tool to build package from ports. Is will source \fIspkgbuild\fP
|
|
||||||
to get build information before creating package. Package is created into
|
|
||||||
\fI<name>-<version>-<release>.spkg.tar.xz\fP format. To build package, you need
|
|
||||||
change into port directory before run \fIpkgbuild\fP command.
|
|
||||||
|
|
||||||
.SH OPTIONS
|
|
||||||
.TP
|
|
||||||
.B "-i, --install"
|
|
||||||
install package into system
|
|
||||||
.TP
|
|
||||||
.B "-u, --upgrade"
|
|
||||||
upgrade package
|
|
||||||
.TP
|
|
||||||
.B "-r, --reinstall"
|
|
||||||
reinstall package
|
|
||||||
.TP
|
|
||||||
.B "-c, --ignore-conflict"
|
|
||||||
ignore conflict when installing package
|
|
||||||
.TP
|
|
||||||
.B "-v, --verbose"
|
|
||||||
verbose install process
|
|
||||||
.TP
|
|
||||||
.B "-f, --force-rebuild"
|
|
||||||
rebuild package
|
|
||||||
.TP
|
|
||||||
.B "-m, --skip-mdsum"
|
|
||||||
skip md5sum checking
|
|
||||||
.TP
|
|
||||||
.B "-g, --genmdsum"
|
|
||||||
generate md5sum
|
|
||||||
.TP
|
|
||||||
.B "-o, --download"
|
|
||||||
download only source file
|
|
||||||
.TP
|
|
||||||
.B "-x, --extract"
|
|
||||||
extract only source file
|
|
||||||
.TP
|
|
||||||
.B "-w, --keep-work"
|
|
||||||
keep working directory
|
|
||||||
.TP
|
|
||||||
.B "-s, --silent"
|
|
||||||
print install message in simple format
|
|
||||||
.TP
|
|
||||||
.B "-h, --help"
|
|
||||||
show this help message
|
|
||||||
.TP
|
|
||||||
.B "--srcdir=<path>"
|
|
||||||
override directory path for sources
|
|
||||||
.TP
|
|
||||||
.B "--pkgdir=<path>"
|
|
||||||
override directory path for compiled package
|
|
||||||
.TP
|
|
||||||
.B "--no-prebuild"
|
|
||||||
skip prebuild script before build package
|
|
||||||
.TP
|
|
||||||
.B "--no-preinstall"
|
|
||||||
skip preinstall script before install package
|
|
||||||
.TP
|
|
||||||
.B "--no-postinstall"
|
|
||||||
skip postinstall script after install package
|
|
||||||
.TP
|
|
||||||
.B "--no-preupgrade"
|
|
||||||
skip preupgrade script before upgrade package
|
|
||||||
.TP
|
|
||||||
.B "--no-postupgrade"
|
|
||||||
skip postupgrade script after upgrade package
|
|
||||||
.TP
|
|
||||||
.B "--no-backup"
|
|
||||||
skip backup configuration file when upgrading package
|
|
||||||
.TP
|
|
||||||
.B "--redownload"
|
|
||||||
re-download source file
|
|
||||||
|
|
||||||
.SH AUTHOR
|
|
||||||
Emmett1 <emmett1.2miligrams@gmail.com>
|
|
||||||
|
|
||||||
.SH SEE ALSO
|
|
||||||
pkgadd(8), pkgdel(8), revdep(8)
|
|
||||||
90
pkgdel
90
pkgdel
@@ -36,11 +36,11 @@ msg2() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
msgerr() {
|
msgerr() {
|
||||||
echo "==> ERROR: $1"
|
echo "==> ERROR: $1" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
msgwarn() {
|
msgwarn() {
|
||||||
echo "==> WARNING: $1"
|
echo "==> WARNING: $1" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
help() {
|
help() {
|
||||||
@@ -51,8 +51,6 @@ Usage:
|
|||||||
Options:
|
Options:
|
||||||
-h, --help show this help message
|
-h, --help show this help message
|
||||||
-v, --verbose print removed files
|
-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
|
--root=<path> remove package from custom root directory
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
@@ -82,8 +80,6 @@ parse_opts() {
|
|||||||
case $1 in
|
case $1 in
|
||||||
-h | --help) SHOWHELP=yes ;;
|
-h | --help) SHOWHELP=yes ;;
|
||||||
-v | --verbose) VERBOSE_REMOVE="-v" ;;
|
-v | --verbose) VERBOSE_REMOVE="-v" ;;
|
||||||
--no-preremove) NO_PREREMOVE=yes ;;
|
|
||||||
--no-postremove) NO_POSTREMOVE=yes ;;
|
|
||||||
--root=*) ROOT_DIR="${1#*=}" ;;
|
--root=*) ROOT_DIR="${1#*=}" ;;
|
||||||
-*) msg "Invalid option: ($1)"; exit 1 ;;
|
-*) msg "Invalid option: ($1)"; exit 1 ;;
|
||||||
*) RMNAME=$1 ;;
|
*) RMNAME=$1 ;;
|
||||||
@@ -95,52 +91,51 @@ parse_opts() {
|
|||||||
|
|
||||||
ret() {
|
ret() {
|
||||||
# remove lock file on exit
|
# remove lock file on exit
|
||||||
rm -f "$ROOT_DIR/$LOCK_FILE" "$reserve" "$dirs" "$remove" "$files"
|
rm -f "$ROOT_DIR/$LOCK_FILE"
|
||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
isinstalled() {
|
isinstalled() {
|
||||||
if [ -s "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo" ] && grep -q "$1" "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo"; then
|
if [ -s "$ROOT_DIR/$PKGDB_DIR/$1" ]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
run_scripts() {
|
command -v pkgadd >/dev/null 2>&1 || {
|
||||||
if [ "$ROOT_DIR" ]; then
|
msgerr "'pkgadd' not found in \$PATH!"
|
||||||
xchroot "$ROOT_DIR" sh $@
|
exit 1
|
||||||
else
|
|
||||||
sh $@
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_opts $(extract_opts "$@")
|
parse_opts $(extract_opts "$@")
|
||||||
|
|
||||||
INDEX_DIR="var/lib/scratchpkg/index"
|
PKGDB_DIR="$(pkgadd --print-dbdir)"
|
||||||
|
PKGDB_DIR="${PKGDB_DIR##/}" # remove leading /
|
||||||
|
PKGDBPERMS_DIR="$PKGDB_DIR.perms"
|
||||||
LOCK_FILE="var/lib/scratchpkg/spkg.lock"
|
LOCK_FILE="var/lib/scratchpkg/spkg.lock"
|
||||||
|
|
||||||
# show help page
|
# show help page
|
||||||
[ "$SHOWHELP" ] || [ -z "$RMNAME" ] && {
|
[ "$SHOWHELP" ] || [ -z "$RMNAME" ] && {
|
||||||
help
|
help
|
||||||
ret 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# check for root access
|
# check for root access
|
||||||
[ "$(id -u)" = "0" ] || {
|
[ "$(id -u)" = "0" ] || {
|
||||||
echo "Removing package need root access!"
|
echo "Removing package need root access!"
|
||||||
ret 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# check for lock file
|
# check for lock file
|
||||||
[ -f "$ROOT_DIR/$LOCK_FILE" ] && {
|
[ -f "$ROOT_DIR/$LOCK_FILE" ] && {
|
||||||
msgerr "Cant install/remove package simultaneously."
|
msgerr "Cannot install/remove package simultaneously."
|
||||||
msgerr "remove '$ROOT_DIR/$LOCK_FILE' if no install/remove package process running."
|
msgerr "remove '$ROOT_DIR/$LOCK_FILE' if no install/remove package process running."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
touch "$ROOT_DIR/$LOCK_FILE" 2>/dev/null || {
|
touch "$ROOT_DIR/$LOCK_FILE" 2>/dev/null || {
|
||||||
msgerr "Cant create lock file in '$ROOT_DIR/$LOCK_FILE'"
|
msgerr "Cannot create lock file in '$ROOT_DIR/$LOCK_FILE'"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,56 +144,25 @@ if ! isinstalled "$RMNAME"; then
|
|||||||
ret 1
|
ret 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
name=$(grep ^name $ROOT_DIR/$INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
|
name=$RMNAME
|
||||||
version=$(grep ^version $ROOT_DIR/$INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
|
version=$(head -n1 $ROOT_DIR/$PKGDB_DIR/$name | awk '{print $1}')
|
||||||
release=$(grep ^release $ROOT_DIR/$INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
|
release=$(head -n1 $ROOT_DIR/$PKGDB_DIR/$name | awk '{print $2}')
|
||||||
|
|
||||||
if [ -z "$name" ] && [ -z "$version" ] && [ -z "$release" ]; then
|
if [ -z "$version" ] && [ -z "$release" ]; then
|
||||||
msgerr "Package '$RMNAME' not installed but exist in database."
|
msgerr "Package '$RMNAME' is not installed but exists in database."
|
||||||
ret 1
|
ret 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create list for reserve and remove (dirs and files)
|
tail -n+2 "$ROOT_DIR/$PKGDB_DIR"/$name | tac | while read -r line; do
|
||||||
reserve="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_reserve"
|
case $line in
|
||||||
remove="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_remove"
|
*/) grep "^$line$" "$ROOT_DIR/$PKGDB_DIR"/* 2>/dev/null | grep -qv "$ROOT_DIR/$PKGDB_DIR"/$name: || rmdir $([ "$VERBOSE_REMOVE" ] && echo -v) "$ROOT_DIR/$line";;
|
||||||
dirs="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_dirs"
|
*) rm $([ "$VERBOSE_REMOVE" ] && echo -v) "$ROOT_DIR/$line";;
|
||||||
files="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_files"
|
esac
|
||||||
|
done
|
||||||
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 '/$' "$ROOT_DIR/$INDEX_DIR/$name/.files" | tac >> "$files"
|
|
||||||
|
|
||||||
echo "remove: $name-$version-$release..."
|
|
||||||
|
|
||||||
# pre-remove script
|
|
||||||
if [ ! "$NO_PREREMOVE" ] && [ -f "$ROOT_DIR/$INDEX_DIR/$name/.pkginstall" ]; then
|
|
||||||
(cd "$ROOT_DIR"/
|
|
||||||
run_scripts "$INDEX_DIR/$name/.pkginstall" pre-remove "$version"
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# remove files and dirs
|
|
||||||
(cd "$ROOT_DIR"/
|
|
||||||
[ -s $files ] && xargs -a $files -d'\n' rm $VERBOSE_REMOVE
|
|
||||||
[ -s $dirs ] && xargs -a $dirs -d'\n' rmdir $VERBOSE_REMOVE
|
|
||||||
)
|
|
||||||
|
|
||||||
rm -f "$reserve" "$dirs" "$remove" "$files"
|
|
||||||
|
|
||||||
# post-remove script
|
|
||||||
if [ ! "$NO_POSTREMOVE" ] && [ -f "$ROOT_DIR/$INDEX_DIR/$name/.pkginstall" ]; then
|
|
||||||
(cd "$ROOT_DIR"/
|
|
||||||
run_scripts "$INDEX_DIR/$name/.pkginstall" post-remove "$version"
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# remove from database
|
# remove from database
|
||||||
rm -rf "$ROOT_DIR/$INDEX_DIR/$name"
|
rm -f "$ROOT_DIR/$PKGDB_DIR/$name"
|
||||||
|
rm -f "$ROOT_DIR/$PKGDBPERMS_DIR/$name"
|
||||||
|
|
||||||
# running ldconfig
|
# running ldconfig
|
||||||
if [ -x "$ROOT_DIR"/sbin/ldconfig ]; then
|
if [ -x "$ROOT_DIR"/sbin/ldconfig ]; then
|
||||||
|
|||||||
21
pkgdepends
21
pkgdepends
@@ -1,7 +1,24 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# script to check dependencies
|
# scratchpkg
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 by Emmett1 (emmett1.2miligrams@gmail.com)
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# script to check shared libraries dependencies
|
||||||
#
|
#
|
||||||
|
|
||||||
get_libpath() {
|
get_libpath() {
|
||||||
|
|||||||
140
pkgfix
140
pkgfix
@@ -1,140 +0,0 @@
|
|||||||
#!/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
|
|
||||||
23
pkgquery
23
pkgquery
@@ -1,23 +0,0 @@
|
|||||||
#!/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/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
echo "*** ${0##*/} is deprecated, please use 'scratch' instead ***"
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
24
pkgrebuild
24
pkgrebuild
@@ -1,12 +1,30 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
|
# scratchpkg
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 by Emmett1 (emmett1.2miligrams@gmail.com)
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
# script to rebuild base packages in right toolchain order
|
# script to rebuild base packages in right toolchain order
|
||||||
#
|
#
|
||||||
|
|
||||||
LIST="/tmp/$(basename $0)-list"
|
LIST="/tmp/$(basename $0)-list"
|
||||||
touch $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
|
#scratch sync || exit 1
|
||||||
|
|
||||||
@@ -15,7 +33,7 @@ for tc in $TOOLCHAIN; do
|
|||||||
pkgname="$(echo $tc | sed 's/-pass1//')"
|
pkgname="$(echo $tc | sed 's/-pass1//')"
|
||||||
scratch build -f $pkgname || exit 1
|
scratch build -f $pkgname || exit 1
|
||||||
echo $tc >> $LIST
|
echo $tc >> $LIST
|
||||||
scratch install -r $pkgname --no-backup || exit 1
|
scratch install -r $pkgname || exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -26,7 +44,7 @@ for pkg in $(scratch deplist base | awk '{print $2}'); do
|
|||||||
if [ ! $(grep -x $pkg $LIST) ]; then
|
if [ ! $(grep -x $pkg $LIST) ]; then
|
||||||
scratch build -f $pkg || exit 1
|
scratch build -f $pkg || exit 1
|
||||||
echo $pkg >> $LIST
|
echo $pkg >> $LIST
|
||||||
scratch install -r $pkg --no-backup || exit 1
|
scratch install -r $pkg || exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -25,13 +25,11 @@ else
|
|||||||
mkdir "$1"
|
mkdir "$1"
|
||||||
echo "# description :
|
echo "# description :
|
||||||
# homepage :
|
# homepage :
|
||||||
# maintainer :
|
|
||||||
# depends :
|
# depends :
|
||||||
|
|
||||||
name=$1
|
name=$1
|
||||||
version=
|
version=
|
||||||
release=1
|
release=1
|
||||||
options=\"\"
|
|
||||||
noextract=\"\"
|
noextract=\"\"
|
||||||
backup=\"\"
|
backup=\"\"
|
||||||
source=\"\"
|
source=\"\"
|
||||||
|
|||||||
129
portsync
Executable file
129
portsync
Executable file
@@ -0,0 +1,129 @@
|
|||||||
|
#!/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/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
cmp_copy() {
|
||||||
|
# usage:
|
||||||
|
# cmp_copy <source dir> <target dir>
|
||||||
|
#
|
||||||
|
reponame=${2##*/}
|
||||||
|
for p in $1/*; do
|
||||||
|
[ -d $p ] || continue
|
||||||
|
pname=${p##*/}
|
||||||
|
if [ ! -d $2/$pname ]; then
|
||||||
|
mkdir -p $2/$pname
|
||||||
|
for f in $p/* $p/.pkgfiles $p/.checksums; do
|
||||||
|
[ -f $f ] || continue
|
||||||
|
case $f in
|
||||||
|
*/update) continue;;
|
||||||
|
esac
|
||||||
|
fname=${f##*/}
|
||||||
|
echo "+ $reponame/$pname/$fname"
|
||||||
|
cp $f $2/$pname/$fname
|
||||||
|
done
|
||||||
|
else
|
||||||
|
for f in $p/* $p/.pkgfiles $p/.checksums; do
|
||||||
|
[ -f $f ] || continue
|
||||||
|
case $f in
|
||||||
|
*/update) continue;;
|
||||||
|
esac
|
||||||
|
fname=${f##*/}
|
||||||
|
cmp -s $f $2/$pname/$fname || {
|
||||||
|
echo "* $reponame/$pname/$fname"
|
||||||
|
cp $f $2/$pname/$fname
|
||||||
|
}
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
for p in $2/*; do
|
||||||
|
[ -d $p ] || continue
|
||||||
|
pname=${p##*/}
|
||||||
|
for f in $p/* $p/.pkgfiles $p/.checksums; do
|
||||||
|
[ -f $f ] || continue
|
||||||
|
fname=${f##*/}
|
||||||
|
if [ ! -f $1/$pname/$fname ]; then
|
||||||
|
echo "- $reponame/$pname/$fname"
|
||||||
|
rm $2/$pname/$fname
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ ! -d $1/$pname ]; then
|
||||||
|
rmdir $2/$pname
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_repo() {
|
||||||
|
# usage:
|
||||||
|
# sync_repo <repo url> <ports dir>
|
||||||
|
#
|
||||||
|
url=$(echo $1 | cut -d / -f -5)
|
||||||
|
portdir=$2
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
*github.com/*)
|
||||||
|
branch=$(echo $1 | cut -d / -f 7)
|
||||||
|
repodir=$(echo $1 | cut -d / -f 8-);;
|
||||||
|
*gitlab.com/*)
|
||||||
|
branch=$(echo $1 | cut -d / -f 8)
|
||||||
|
repodir=$(echo $1 | cut -d / -f 9-);;
|
||||||
|
*) # will add more git service
|
||||||
|
branch=$(echo $1 | cut -d / -f 8)
|
||||||
|
repodir=$(echo $1 | cut -d / -f 9-);;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# if branch not in the url, assume it master branch
|
||||||
|
[ "$branch" ] || branch=master
|
||||||
|
|
||||||
|
echo "fetching ports: $1"
|
||||||
|
|
||||||
|
# cloning ports repository
|
||||||
|
git clone --depth 1 -q -b $branch $url $tmprepo || {
|
||||||
|
echo " failed sync repo"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# copying ports to port directory by comparing
|
||||||
|
cmp_copy $tmprepo/$repodir $portdir
|
||||||
|
|
||||||
|
# cleanup tmp cloned repo
|
||||||
|
rm -fr $tmprepo
|
||||||
|
|
||||||
|
echo "ports synced: $2"
|
||||||
|
}
|
||||||
|
|
||||||
|
tmprepo=/tmp/tmprepo
|
||||||
|
repo_file=/etc/scratchpkg.repo
|
||||||
|
|
||||||
|
if [ ! -e "$repo_file" ]; then
|
||||||
|
echo "missing repo file: $repo_file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$(id -u)" != 0 ]; then
|
||||||
|
echo "this operation need root access."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
grep -Ev '^(#|$)' "$repo_file" | awk '{print $1,$2}' | while read -r repodir repourl; do
|
||||||
|
if [ "$repodir" ] && [ "$repourl" ]; then
|
||||||
|
sync_repo $repourl $repodir
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
||||||
72
revdep
72
revdep
@@ -114,7 +114,7 @@ rebuild() {
|
|||||||
confirm "Continue rebuild & reinstall broken packages?" "Operation cancelled."
|
confirm "Continue rebuild & reinstall broken packages?" "Operation cancelled."
|
||||||
fi
|
fi
|
||||||
for p in $order; do
|
for p in $order; do
|
||||||
scratch build -f $p && scratch install -r $p || { cleanup; exit 1; }
|
scratch install -fr $p || { cleanup; exit 1; }
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -161,10 +161,43 @@ rev_exclude() {
|
|||||||
EXCLUDED_LIBS=$(echo $EXCLUDE_LIBS | tr ' ' '\n' | sort | uniq)
|
EXCLUDED_LIBS=$(echo $EXCLUDE_LIBS | tr ' ' '\n' | sort | uniq)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_pythonmodules() {
|
||||||
|
command -v python3 >/dev/null || return
|
||||||
|
pylibpath=$(python3 -c "import sys; print(':'.join(x for x in sys.path if x))" | tr ':' '\n' | sort | head -n1)
|
||||||
|
for i in /usr/lib/python3.*; do
|
||||||
|
[ -d "$i" ] || continue
|
||||||
|
[ "$i" = "$pylibpath" ] && continue
|
||||||
|
brokenpkg="$brokenpkg $(scratch provide $i/$ | awk '{print $1}')"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
check_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
|
||||||
|
}
|
||||||
|
|
||||||
|
check_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
|
||||||
|
}
|
||||||
|
|
||||||
trap "interrupted" 1 2 3 15
|
trap "interrupted" 1 2 3 15
|
||||||
|
|
||||||
|
command -v pkgadd >/dev/null 2>&1 || {
|
||||||
|
echo "'pkgadd' not found in \$PATH!"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# package database directory
|
# package database directory
|
||||||
INDEX_DIR="/var/lib/scratchpkg/index"
|
PKGDB_DIR="$(pkgadd --print-dbdir)"
|
||||||
SEARCH_DIRS="/bin /usr/bin /sbin /usr/sbin /lib /usr/lib /lib64 /usr/lib64 /usr/libexec"
|
SEARCH_DIRS="/bin /usr/bin /sbin /usr/sbin /lib /usr/lib /lib64 /usr/lib64 /usr/libexec"
|
||||||
|
|
||||||
parse_opt $(extract_opts "$@")
|
parse_opt $(extract_opts "$@")
|
||||||
@@ -174,7 +207,7 @@ if [ "$(id -u)" != 0 ] && [ "$REBUILD" = 1 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$PKG" ] && [ ! -f "$INDEX_DIR/$PKG/.files" ]; then
|
if [ "$PKG" ] && [ ! -f "$PKGDB_DIR/$PKG" ]; then
|
||||||
echo "ERROR: Package '$PKG' not installed"
|
echo "ERROR: Package '$PKG' not installed"
|
||||||
cleanup
|
cleanup
|
||||||
exit 1
|
exit 1
|
||||||
@@ -249,7 +282,7 @@ if [ "$PKG" ]; then
|
|||||||
filterdir=cat
|
filterdir=cat
|
||||||
fi
|
fi
|
||||||
printf "Find '$PKG' files... "
|
printf "Find '$PKG' files... "
|
||||||
sed 's/^/\//' $INDEX_DIR/$PKG/.files | grep $gx | $filterfile | $filterdir > $FILE_LIST
|
tail -n +2 $PKGDB_DIR/$PKG | sed 's/^/\//' | grep $gx | $filterfile | $filterdir > $FILE_LIST
|
||||||
else
|
else
|
||||||
printf "Find all files... "
|
printf "Find all files... "
|
||||||
find $SEARCH_DIRS $EXCLUDED_DIRS $EXCLUDED_FILES -type f \( -perm /+u+x -o -name '*.so' -o -name '*.so.*' \) -print 2> /dev/null | sort -u > $FILE_LIST
|
find $SEARCH_DIRS $EXCLUDED_DIRS $EXCLUDED_FILES -type f \( -perm /+u+x -o -name '*.so' -o -name '*.so.*' \) -print 2> /dev/null | sort -u > $FILE_LIST
|
||||||
@@ -264,7 +297,7 @@ echo "Checking for broken linkage..."
|
|||||||
|
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
count=$(( count + 1 ))
|
count=$(( count + 1 ))
|
||||||
libname=$(basename "$line")
|
libname=${line##*/}
|
||||||
printf " $(( 100*count/total ))%% $libname\033[0K\r"
|
printf " $(( 100*count/total ))%% $libname\033[0K\r"
|
||||||
case "$(file -bi "$line")" in
|
case "$(file -bi "$line")" in
|
||||||
*application/x-sharedlib* | *application/x-executable* | *application/x-pie-executable*)
|
*application/x-sharedlib* | *application/x-executable* | *application/x-pie-executable*)
|
||||||
@@ -275,13 +308,12 @@ while read -r line; do
|
|||||||
NEW_LIB_NAME="$NEW_LIB_NAME $l"
|
NEW_LIB_NAME="$NEW_LIB_NAME $l"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
[ "$NEW_LIB_NAME" ] || continue
|
||||||
LIB_NAME=$NEW_LIB_NAME
|
LIB_NAME=$NEW_LIB_NAME
|
||||||
[ "$LIB_NAME" ] || continue
|
PKG_NAME=${line#?} # remove leading slash
|
||||||
PKG_NAME=$(echo $line | sed 's#^/##')
|
PKG_NAME=$(grep -Rx $PKG_NAME "$PKGDB_DIR"/* | awk -F : '{print $1}')
|
||||||
PKG_NAME=$(grep -Rx $PKG_NAME "$INDEX_DIR"/*/.files | cut -d : -f1)
|
|
||||||
[ "$PKG_NAME" ] || continue
|
[ "$PKG_NAME" ] || continue
|
||||||
PKG_NAME=$(dirname $PKG_NAME)
|
PKG_NAME=${PKG_NAME##*/}
|
||||||
PKG_NAME=$(basename $PKG_NAME)
|
|
||||||
echo $expkg | tr ' ' '\n' | grep -qx $PKG_NAME && continue
|
echo $expkg | tr ' ' '\n' | grep -qx $PKG_NAME && continue
|
||||||
REQ_LIB=$(objdump -p $line 2>/dev/null | grep NEEDED | awk '{print $2}' | tr '\n' ' ')
|
REQ_LIB=$(objdump -p $line 2>/dev/null | grep NEEDED | awk '{print $2}' | tr '\n' ' ')
|
||||||
for i in $LIB_NAME; do
|
for i in $LIB_NAME; do
|
||||||
@@ -303,6 +335,24 @@ done < $FILE_LIST
|
|||||||
|
|
||||||
printf "\033[0K"
|
printf "\033[0K"
|
||||||
|
|
||||||
|
[ "$PKG" ] || {
|
||||||
|
echo
|
||||||
|
echo "Checking for broken packages..."
|
||||||
|
check_pythonmodules
|
||||||
|
check_perlmodules
|
||||||
|
check_rubygem
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$brokenpkg" ]; then
|
||||||
|
for i in $brokenpkg; do
|
||||||
|
if echo "$ALLPKG" | tr ' ' '\n' | grep -qx "$i"; then
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
ALLPKG="$ALLPKG $i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$ALLPKG" ]; then
|
if [ "$ALLPKG" ]; then
|
||||||
echo
|
echo
|
||||||
echo "Broken package(s):"
|
echo "Broken package(s):"
|
||||||
@@ -313,7 +363,7 @@ if [ "$ALLPKG" ]; then
|
|||||||
rebuild
|
rebuild
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "All packages is doing fine."
|
echo "All packages are doing fine."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|||||||
@@ -2,32 +2,17 @@
|
|||||||
# Configuration file for scratchpkg
|
# Configuration file for scratchpkg
|
||||||
#
|
#
|
||||||
|
|
||||||
CFLAGS="-O2 -march=x86-64 -pipe"
|
# export CFLAGS="-O2 -march=x86-64 -pipe"
|
||||||
CXXFLAGS="${CFLAGS}"
|
# export CXXFLAGS="${CFLAGS}"
|
||||||
MAKEFLAGS="-j$(nproc)"
|
# export MAKEFLAGS="-j$(nproc)"
|
||||||
|
|
||||||
# SOURCE_DIR="/var/cache/scratchpkg/sources"
|
# SOURCE_DIR="/var/cache/scratchpkg/sources"
|
||||||
# PACKAGE_DIR="/var/cache/scratchpkg/packages"
|
# PACKAGE_DIR="/var/cache/scratchpkg/packages"
|
||||||
# WORK_DIR="/var/cache/scratchpkg/work"
|
# WORK_DIR="/var/cache/scratchpkg/work"
|
||||||
# DOWNLOAD_PROG="auto"
|
|
||||||
# WGET_OPTS=""
|
|
||||||
# CURL_OPTS=""
|
# CURL_OPTS=""
|
||||||
# COMPRESSION_MODE="xz"
|
# COMPRESSION_MODE="xz"
|
||||||
|
# NO_STRIP="no"
|
||||||
#
|
# IGNORE_MDSUM="no"
|
||||||
# GLOBAL PACKAGE OPTIONS
|
# KEEP_LIBTOOL="no"
|
||||||
#
|
# KEEP_LOCALE="no"
|
||||||
# -- libtool: Keep libtool file (*.la) in packages
|
# KEEP_DOC="no"
|
||||||
# -- emptydirs: Keep empty directories in packages
|
|
||||||
# -- strip: Strip symbols from binaries/libraries
|
|
||||||
# -- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
|
|
||||||
# -- buildflags: Enable buildflags (CFLAGS and CXXFLAGS)
|
|
||||||
# -- makeflags: Enable makeflags (MAKEFLAGS)
|
|
||||||
# -- checksum: Enable checking checksum
|
|
||||||
# -- 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 !docs !locales"
|
|
||||||
|
|||||||
3
scratchpkg.mask
Normal file
3
scratchpkg.mask
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#
|
||||||
|
# /etc/scratchpkg.mask : exclude packages from sysup
|
||||||
|
#
|
||||||
@@ -5,6 +5,8 @@
|
|||||||
# <repo directory> <repo url for sync>
|
# <repo directory> <repo url for sync>
|
||||||
#
|
#
|
||||||
# example:
|
# example:
|
||||||
# /usr/ports/core https://raw.githubusercontent.com/emmett1/ports/master/core
|
# /usr/ports/myrepo
|
||||||
# /usr/ports/localports
|
# /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
|
||||||
#
|
#
|
||||||
Reference in New Issue
Block a user