diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 283e19f0048941..00000000000000 --- a/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -syntax: glob - -masterdir/ -xbps-src/etc/xbps-src.conf -xbps-src/libexec/capchroot -xbps-src/libexec/capmount -xbps-src/libexec/capumount -xbps-src/libexec/chroot-helper -xbps-src/libexec/doinst-helper -xbps-src/libexec/getdeps-helper -xbps-src/shutils/chroot.sh -xbps-src/shutils/init_funcs.sh -xbps-src/shutils/pkgtarget_funcs.sh -xbps-src/shutils/tmpl_funcs.sh -xbps-src/xbps-src - -*.bak - -upstream.json diff --git a/.hgignore b/.hgignore deleted file mode 100644 index 16108fe4fb6b57..00000000000000 --- a/.hgignore +++ /dev/null @@ -1,14 +0,0 @@ -syntax: glob - -masterdir/ -etc/xbps-src.conf -xbps-src/libexec/xbps-src-capchroot -xbps-src/libexec/xbps-src-chroot-capmount -xbps-src/libexec/xbps-src-chroot-capumount -xbps-src/libexec/xbps-src-chroot-helper -xbps-src/libexec/xbps-src-doinst-helper -xbps-src/shutils/chroot.sh -xbps-src/shutils/init_funcs.sh -xbps-src/shutils/pkgtarget_funcs.sh -xbps-src/xbps-src -*.bak diff --git a/README b/README index 70d1ac4eae2756..9c912ebcbf0590 100644 --- a/README +++ b/README @@ -1,44 +1,18 @@ -Void GNU/Linux is a new distribution that uses XBPS as its package system, -The X Binary Package System has been designed from scratch, please visit -http://code.google.com/p/xbps for more information. +This repository contains the source package tree to build XBPS binary +packages from sources for Void GNU/Linux. -Void GNU/Linux is a simple and minimal distribution that can be customized -in many ways, through the use of virtual packages. Currently there are -1600 packages in the current repository that you can build and install. -There is support for i686 and x86_64 architectures, more may be added in -a future (i.e. ARM) but it's not a high priority. +You can find more info about XBPS and Void GNU/Linux on: -Some features: - - It's not a fork or customized version of any distro, it has been created - from scratch making it an extremely lightweight distro. Base install is - approximately 150MB. - - Rolling release. - - Uses the latest stable Linux kernel. The development snapshot from kernel.org - can also be installed in parallel. - - Kernel images/modules are never removed, providing an always-bootable system. - - Uses a modified "initramfs-tools" version from Debian to handle initial - ramdisk images. - - Uses a modified "casper" version from Ubuntu to boot from live images. - - Uses *systemd* as system and session manager, no SysV compatibility! - - Uses its own binary package system: XBPS -- A faster/leaner alternative to Debian's - dpkg/apt, RedHat's RPM, ArchLinux's Pacman, etc. - - You don't need wrappers of wrappers for the XBPS utils to rebuild/reinstall - packages. The provided tools are all that you need. - - Uses a BSD port-like system to build binary packages in chroot jails - without requiring root permissions. This allows building packages as a regular user - without interfering with your installed system! + http://code.google.com/p/xbps -When a new stable XBPS version comes out, a new live image is created for -testing purposes along with the minimal base system. +To use this repository the 'xbps-src' utility is required. If you don't use +Void GNU/Linux you can fetch its sources from: -You can find the Live Images at: + https://github.com/xtraeme/xbps-src -http://xbps.nopcode.org/live/ +Or alternatively if you are already using Void and/or XBPS you can install +the binary package with: -If you have questions or contributions please use the google groups forum: + $ xbps-bin -y install xbps-src -http://groups.google.com/group/xbps - -or join us at irc.freenode.net #xbps. - -Enjoy and happy hacking! +Enjoy and happy hacking! meet us at xbps@irc.freenode.net. diff --git a/xbps-src/Makefile b/xbps-src/Makefile deleted file mode 100644 index 4ad676dbd3e015..00000000000000 --- a/xbps-src/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -include vars.mk - -BINS = xbps-src -SUBDIRS = etc libexec helpers shutils - -.PHONY: all -all: - for bin in $(BINS); do \ - sed -e "s|@@XBPS_INSTALL_PREFIX@@|$(PREFIX)|g" \ - -e "s|@@XBPS_INSTALL_ETCDIR@@|$(ETCDIR)|g" \ - -e "s|@@XBPS_INSTALL_SHAREDIR@@|$(SHAREDIR)|g" \ - -e "s|@@XBPS_INSTALL_SBINDIR@@|$(SBINDIR)|g" \ - -e "s|@@XBPS_INSTALL_LIBEXECDIR@@|$(LIBEXECDIR)|g" \ - $$bin.sh.in > $$bin; \ - done - for dir in $(SUBDIRS); do \ - $(MAKE) -C $$dir || exit 1; \ - done - -.PHONY: clean -clean: - -rm -f $(BINS) - for dir in $(SUBDIRS); do \ - $(MAKE) -C $$dir clean || exit 1; \ - done - -.PHONY: install -install: all - install -d $(SBINDIR) - for bin in $(BINS); do \ - install -m 755 $$bin $(SBINDIR); \ - done - for dir in $(SUBDIRS); do \ - $(MAKE) -C $$dir install || exit 1; \ - done - -.PHONY: uninstall -uninstall: - for bin in $(BINS); do \ - rm -f $(SBINDIR)/$$bin; \ - done - for dir in $(SUBDIRS); do \ - $(MAKE) -C $$dir uninstall || exit 1; \ - done diff --git a/xbps-src/README b/xbps-src/README deleted file mode 100644 index 49143a6e0dbdb4..00000000000000 --- a/xbps-src/README +++ /dev/null @@ -1,242 +0,0 @@ -xbps-src - building packages from source -======================================== - -Introduction ------------- -`xbps-src` is the utility used by the _X binary package system_ to build -binary packages from source distribution files. A root directory (`srcpkgs`) -contains multiple subdirs, each one to build a package as its name -indicates. The following directory structure illustrates it: - + -................................. - xbps-templates/ - | - |-----srcpkgs/ - | - |-----binutils/ - |-----gcc/ - |-----glibc/ -.................................. - -A package subdirectory always has a `template` file, that are the -specifications to download and build the binary package from its source files. -Additionally some packages may have additional subdirs on it: `files` -and `patches`. The `files` subdir may contain configuration files, or -any other file required to build the package. The `patches` subdir contains -patches that are applied to the source before building. - + - -Some packages may provide `subpackages`; they are different binary packages -that are built from the same source package. Each `subpackage` in the directory -structure (as shown above) is a symlink to the `real` package subdir, like this: - + -.................................... - srcpkgs/ - | - |-----gcc/ - |-----libgomp -> gcc - |-----libmudflap -> gcc - |-----libstdc++ -> gcc -.................................... - -Each subpackage uses its own `template` build file that is contained in -the `real` package subdir, and they have exactly the same name than the -symlink pointing to the `real` package subdir. The following example -illustrates the structure used by the _udev_ package in the filesystem: - + -....................................... - srcpkgs/ - | - |-----libgudev-devel -> udev - |-----libgudev -> udev - |-----libudev-devel -> udev - |-----libudev -> udev - |-----udev/ - |----template - |----libgudev-devel.template - |----libgudev.template - |----libudev-devel.template - |----libudev.template -....................................... - + - -Subpackages use a reduced version of the main `template` build file, because -the build and main install process is all done in the real `template` file. -Usually those `.template` files only move files and directories -to the `subpackage` destination directory, so they are always smaller. - -Requirements ------------- -The following software is required in the host system to install xbps-src -and its helpers: - - - GCC, make, sed and libcap (depelopment package and setcap(8) command). - -To build binary packages with xbps-src also the following software needs -to be installed into the host system: - - - awk, bash, gcc c++, gettext, patch, texinfo, perl and fakeroot. - - xbps static utilities, available from http://code.google.com/p/xbps. - (use the latest available stable version) or - 'xbps-bin -y install xbps-static' if using Void GNU/Linux. - -Additionally if you want to work as 'root': - - - sudo - -Starting up ------------ -Firstly you'll have to download the `git` repository that contains `xbps-src` -and the build template files. To clone it with `git` use: - ------------------------------------------------------------------ -$ git clone https://code.google.com/p/xbps.packages xbps-packages ------------------------------------------------------------------ - -`xbps-src` and its shell utilities need to be installed in a directory -for correct operation, that is accomplished by issuing: - --------------------------------------------------- -$ cd xbps-packages/xbps-src && make install clean --------------------------------------------------- - -This will install all files into `/usr/local` by default, can be changed -by specifying `PREFIX` and `DESTDIR` to make(1). - -Building packages from source ------------------------------ -`xbps-src` always look for a `template` file in current directory, that's what -it specifies the package build definitions and such. The build templates -are located in the `srcpkgs` directory, you should change the cwd to the -directory matching the package that you want to work on, i.e for binutils, -its directory is `srcpkgs/binutils`. - + - + - -If configuration file is not specified from the command line with the -`-c` flag, it will first try to use the default location at -`/usr/local/etc/xbps-src.conf` (or the installation prefix that was specified -to the make(1) command), and as last resort in the etc directory of the -current directory. - + - + - -To avoid problems with libtool and configure scripts finding stuff that is -available in the host system, almost all packages must be built inside of a -chroot. So the first thing would be to create the required set of packages -that will be used in the chroot: - ----------------------------------------------------------------- -$ xbps-src bootstrap ----------------------------------------------------------------- - -This will build all required packages via fakeroot in masterdir, therefore you -can run it as normal user. Once 'xbps-src-chroot' has been built and installed -into the 'masterdir' all packages will be built inside of the chroot. - + - + - -'xbps-src' supports building packages in the chroot with your normal user, -thanks to the *POSIX.1e Capabilities* support in the Linux kernel. To use this -the target filesystem must support *extended attributes*; right now they -are supported on almost all Linux filesytems, such as *ext2*, *ext3*, *ext4*, -*xfs*, and others. This option is enabled by default in *xbps-src.conf*. - + - + - -I believe it's the most easier and faster way to handle clean dependencies; -another reason would be that xbps packages are meant to be used in a system and -not just for ordinary users. So once all packages are built, you can create and -enter to the chroot with: - ----------------------- -$ xbps-src chroot ----------------------- - -Press Control + D to exit from the chroot. The following targets will require -to be done in the chroot (_once base-chroot is installed_): -*build, configure, install and install-destdir*. - + - + - -Now let's explain some more about the targets that you can use. To start -installing packages you should use the install target, all source packages -are located in the `srcpkgs` directory, so to install glib: - ------------------------------------------- -$ cd srcpkgs/ && xbps-src install ------------------------------------------- - -If the package is properly installed, it will be "stowned" automatically. -``stowned'' means that this package is available in the master directory, -on which xpbs has symlinked all files from DESTDIR/. - + - -To remove a currently installed (and stowned) package, you can use: - ------------------------------------------ -$ cd srcpkgs/ && xbps-src remove ------------------------------------------ - -Please note that when you remove it, the package will also be removed -from XBPS_DESTDIR and previously `unstowned`. - + - -To stow an already installed package (from XBPS_DESTDIR/): - ---------------------------------------- -$ cd srcpkgs/ && xbps-src stow ---------------------------------------- - -To unstow an already installed (stowned) package: - ------------------------------------------ -$ cd srcpkgs/ && xbps-src unstow ------------------------------------------ - -You can also print some stuff about any template build file, e.g: - ---------------------------------------- -$ cd srcpkgs/ && xbps-src info ---------------------------------------- - -To list installed (stowned) packages, use this: ---------------- -$ xbps-src list ---------------- - -To only extract the distfiles, without configuring/building/installing: - ------------------------------------------- -$ cd srcpkgs/ && xbps-src extract ------------------------------------------- - -To not remove the build directory after successful installation: - ---------------------------------------------- -$ cd srcpkgs/ && xbps-src -C install ---------------------------------------------- - -To only fetch the distfile: ----------------------------------------- -$ cd srcpkgs/ && xbps-src fetch ----------------------------------------- - -To only install the package, _without_ stowning it into the master directory: --------------------------------------------------- -$ cd srcpkgs/ && xbps-src install-destdir --------------------------------------------------- - -To list files installed by a package, note that package must be installed -into destination directory first: ------------------------------- -$ xbps-src listfiles ------------------------------- - -That should be enough to get you started. If you have any question or -suggestion about *xbps-src* and the build templates, don't forget that there -is a mailing list to talk about it on: - -http://groups.google.com/xbps - -or join us at #xbps on irc.freenode.net. diff --git a/xbps-src/TODO b/xbps-src/TODO deleted file mode 100644 index 84d416c642bef9..00000000000000 --- a/xbps-src/TODO +++ /dev/null @@ -1,13 +0,0 @@ -- Make src packages self contained, without requiring to download - the whole repository. - -- Add documentation explaining stuff to create build templates. - Explain extensively available variables, build phases, etc. - -- Fix packages with the "XXX" mark. - -- Make all packages use $homepage and $license. base-files installs - common license files into /usr/share/licenses, if any package uses any - other license not installed there, it should be installed into - /usr/share/licenses/$pkgname. Also $license should match the file names - available in /usr/share/licenses when using common licenses. diff --git a/xbps-src/etc/Makefile b/xbps-src/etc/Makefile deleted file mode 100644 index f9277a0b7bb03d..00000000000000 --- a/xbps-src/etc/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -include ../vars.mk - -# Find out the real path for the xbps-src distribdir. -_CURDIR = $(shell dirname $(shell pwd)) -ifeq ($(shell basename ${_CURDIR}), xbps-src) -DISTRIBDIR = $(subst /xbps-src,,${_CURDIR}) -else -DISTRIBDIR = ${_CURDIR} -endif - -CONF_FILE = xbps-src.conf - -.PHONY: all -all: - sed -e "s|@@XBPS_DISTRIBDIR@@|${DISTRIBDIR}|" \ - ${CONF_FILE}.in > ${CONF_FILE} - -.PHONY: clean -clean: - -rm -f ${CONF_FILE} - -.PHONY: install -install: - if [ ! -d $(DESTDIR)$(ETCDIR) ]; then \ - install -d $(DESTDIR)$(ETCDIR); \ - fi - if [ ! -f $(DESTDIR)$(ETCDIR)/$(CONF_FILE) ]; then \ - install -m644 $(CONF_FILE) $(DESTDIR)$(ETCDIR); \ - fi - -.PHONY: uninstall -uninstall: diff --git a/xbps-src/etc/xbps-src.conf.in b/xbps-src/etc/xbps-src.conf.in deleted file mode 100644 index 80829856288fe5..00000000000000 --- a/xbps-src/etc/xbps-src.conf.in +++ /dev/null @@ -1,89 +0,0 @@ -# --*-- shell --*-- -# Configuration file for the XBPS source build system. -# -# To disable an option comment it out, don't set it to another value i.e: -# FOO=no -> wrong -# #FOO=yes -> correct - -# [REQUIRED] -# Directory where the xbps-src GIT repository is stored. This is -# required to be mounted in the chroot. You shouldn't need to modify this -# one unless your xbps-packages git repo has been moved to another path. -XBPS_DISTRIBUTIONDIR=@@XBPS_DISTRIBDIR@@ - -# [REQUIRED] -# Chroot master directory. This is where the packages are built and installed. -XBPS_MASTERDIR=$XBPS_DISTRIBUTIONDIR/masterdir - -# [OPTIONAL] -# Host directory to be (bind) mounted into the chroot (masterdir) containing -# directories for downloaded cached packages from xbps-bin(8), packages -# created by xbps-src, downloaded source distribution tarballs, etc. -# -# Basically your directory will contain this structure: -# -# /dir -# |_ /binpkgs -# |_ /repocache -# |_ /sources -# -# When created, those names are constants, so you cannot change them, even -# they are case sensitive. -# -# NOTE: You must create your toplevel /dir yourself -# -#XBPS_HOSTDIR=/path/to/your/host/directory - -# [OPTIONAL] -# Compilation flags for C and C++. -XBPS_CFLAGS="-O2 -pipe -mtune=generic" -XBPS_CXXFLAGS="$XBPS_CFLAGS" - -# [OPTIONAL] -# Enable or disable ccache when building packages. -#XBPS_CCACHE=yes - -# [OPTIONAL] -# Linker flags passed to the compiler. By default we use --as-needed to -# avoid linking extra libraries into binaries. See the following link -# for info: http://www.gentoo.org/proj/en/qa/asneeded.xml -XBPS_LDFLAGS="-Wl,--as-needed" - -# [OPTIONAL] -# Number of parallel jobs to execute when building packages that -# use make(1) or alike commands. -#XBPS_MAKEJOBS=4 - -# [REQUIRED] -# Compression program used to build the binary packages. -# Possible value: gzip, bzip2 or xz. Default xz. -XBPS_COMPRESS_CMD=xz - -# [OPTIONAL] -# Compression level used in XBPS_COMPRESS_CMD to build the -# binary packages. Possible values: 1-9. If unset, default value -# by the command will be used. -XBPS_COMPRESS_LEVEL=9 - -# [OPTIONAL] -# Install required package dependencies from binary packages, through -# binary package repositories as specified in the XBPS repositories.plist -# configuration file. -# -# Only dependencies for non bootstrap packages will be installed. -# Make sure that you modify the repositories.plist file from: -# -# XBPS >= 0.10.0: -# /usr/local/etc/xbps/repositories.plist. -# XBPS < 0.10.0: -# /usr/local/etc/xbps-conf.plist -# -#XBPS_PREFER_BINPKG_DEPS=yes - -# [OPTIONAL] -# Build packages with your unprivileged user in the chroot thanks -# to POSIX.1e Capabilities as explained in capabilities(7) on GNU/Linux. -# -# fakeroot is only used for the installation stage via the helper -# script doinst-helper. -XBPS_USE_CAPABILITIES=yes diff --git a/xbps-src/helpers/Makefile b/xbps-src/helpers/Makefile deleted file mode 100644 index 78499158b34b92..00000000000000 --- a/xbps-src/helpers/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -include ../vars.mk - -.PHONY: all -all: - -.PHONY: clean -clean: - -.PHONY: install -install: - install -d $(DESTDIR)$(SHAREDIR)/helpers - install -m 644 *.sh $(DESTDIR)$(SHAREDIR)/helpers - -.PHONY: uninstall -uninstall: - -rm -rf $(DESTDIR)$(SHAREDIR)/helpers diff --git a/xbps-src/helpers/cmake.sh b/xbps-src/helpers/cmake.sh deleted file mode 100644 index ac207c137b1f0c..00000000000000 --- a/xbps-src/helpers/cmake.sh +++ /dev/null @@ -1,11 +0,0 @@ -# -# This helper is for templates using cmake. -# -do_configure() { - [ -z "$configure_script" ] && configure_script=cmake - ${configure_script} -DCMAKE_INSTALL_PREFIX=/usr \ - -DCMAKE_BUILD_TYPE=Release ${configure_args} -} - -# cmake scripts use make(1) to build/install. -. $XBPS_HELPERSDIR/gnu-makefile.sh diff --git a/xbps-src/helpers/configure.sh b/xbps-src/helpers/configure.sh deleted file mode 100644 index cdb8e7cab97235..00000000000000 --- a/xbps-src/helpers/configure.sh +++ /dev/null @@ -1,12 +0,0 @@ -# -# This helper is for templates using configure scripts (not generated -# by the GNU autotools). -# - -do_configure() { - [ -z "$configure_script" ] && configure_script="./configure" - ${configure_script} ${configure_args} -} - -# configure scripts use make(1) to build/install. -. $XBPS_HELPERSDIR/gnu-makefile.sh diff --git a/xbps-src/helpers/gnu-configure.sh b/xbps-src/helpers/gnu-configure.sh deleted file mode 100644 index 771152ce53a235..00000000000000 --- a/xbps-src/helpers/gnu-configure.sh +++ /dev/null @@ -1,14 +0,0 @@ -# -# This helper is for templates using GNU configure script. -# - -# This variable can be used for packages wanting to use common arguments -# to GNU configure scripts. -# -do_configure() { - [ -z "$configure_script" ] && configure_script="./configure" - ${configure_script} ${CONFIGURE_SHARED_ARGS} ${configure_args} -} - -# GNU configure scripts use make(1) to build/install. -. $XBPS_HELPERSDIR/gnu-makefile.sh diff --git a/xbps-src/helpers/gnu-makefile.sh b/xbps-src/helpers/gnu-makefile.sh deleted file mode 100644 index cc3d71c72e433e..00000000000000 --- a/xbps-src/helpers/gnu-makefile.sh +++ /dev/null @@ -1,23 +0,0 @@ -# -# This helper is for templates using GNU Makefiles. -# -do_build() { - if [ -z "$make_cmd" ]; then - make_cmd=make - fi - ${make_cmd} ${makejobs} ${make_build_args} ${make_build_target} -} - -do_install() { - local target - - if [ -z "$make_install_target" ]; then - target="DESTDIR=${DESTDIR} install" - else - target="${make_install_target}" - fi - if [ -z "$make_cmd" ]; then - make_cmd=make - fi - ${make_cmd} ${make_install_args} ${target} -} diff --git a/xbps-src/helpers/perl-module.sh b/xbps-src/helpers/perl-module.sh deleted file mode 100644 index 15ddab006c1818..00000000000000 --- a/xbps-src/helpers/perl-module.sh +++ /dev/null @@ -1,44 +0,0 @@ -# -# This helper does the required steps to be able to build and install -# perl modules into the correct location. -# -# Required vars to be set by a template: -# -# build_style=perl-module -# -# Optionally if the module needs more directories to be configured other -# than $XBPS_BUILDDIR/$wrksrc, one can use (relative to $wrksrc): -# -# perl_configure_dirs="blob/bob foo/blah" -# -do_configure() { - local perlmkf - - if [ -z "$perl_configure_dirs" ]; then - perlmkf="$wrksrc/Makefile.PL" - if [ ! -f $perlmkf ]; then - echo "*** ERROR couldn't find $perlmkf, aborting" - exit 1 - fi - - cd $wrksrc && \ - PERL_MM_USE_DEFAULT=1 perl Makefile.PL \ - ${make_build_args} INSTALLDIRS=vendor - fi - - for i in "$perl_configure_dirs"; do - perlmkf="$wrksrc/$i/Makefile.PL" - if [ -f $perlmkf ]; then - cd $wrksrc/$i && PERL_MM_USE_DEFAULT=1 \ - perl Makefile.PL ${make_build_args} \ - INSTALLDIRS=vendor - else - echo -n "*** ERROR: couldn't find $perlmkf" - echo ", aborting ***" - exit 1 - fi - done -} - -# Perl modules use standard make(1) to install. -. ${XBPS_HELPERSDIR}/gnu-makefile.sh diff --git a/xbps-src/helpers/python-module.sh b/xbps-src/helpers/python-module.sh deleted file mode 100644 index 1ede86ba957b78..00000000000000 --- a/xbps-src/helpers/python-module.sh +++ /dev/null @@ -1,13 +0,0 @@ -# -# This helper is for templates installing python modules. -# -do_build() { - python setup.py build ${make_build_args} -} - -do_install() { - if [ -z "$make_install_args" ]; then - make_install_args="--prefix=/usr --root=$DESTDIR" - fi - python setup.py install ${make_install_args} -} diff --git a/xbps-src/helpers/replace-interpreter.sh b/xbps-src/helpers/replace-interpreter.sh deleted file mode 100644 index 2026ac38a75d5d..00000000000000 --- a/xbps-src/helpers/replace-interpreter.sh +++ /dev/null @@ -1,46 +0,0 @@ -# -# This helper replaces shebang paths pointing to the correct ones -# as used by xbps. Multiple languages are supported: -# -# - GNU Bash -# - Perl -# - Python -# - -bash_regexp=".*sh" -perl_regexp=".*perl[^[:space:]]*" -python_regexp=".*python[^[:space:]]*" - -replace_interpreter() -{ - local lang="$1" - local file="$2" - local trsb= - local orsb= - - [ -z $lang -o -z $file ] && return 1 - - case $lang in - bash) - orsb=$bash_regexp - trpath="/bin/bash" - ;; - perl) - orsb=$perl_regexp - trpath="/usr/bin/perl" - ;; - python) - orsb=$python_regexp - trpath="/usr/bin/python" - ;; - *) - ;; - esac - - if [ -f $file ]; then - sed -i -e "1s|^#![[:space:]]*${orsb}|#!${trpath}|" $file && \ - msg_normal "Transformed $lang script: ${file##$wrksrc}.\n" - else - msg_warn "Ignoring unexistent $lang script: ${file##$wrksrc}.\n" - fi -} diff --git a/xbps-src/helpers/waf.sh b/xbps-src/helpers/waf.sh deleted file mode 100644 index 57a2e5c1d92232..00000000000000 --- a/xbps-src/helpers/waf.sh +++ /dev/null @@ -1,17 +0,0 @@ -# -# This helper is for templates using WAF to build/install. -# -do_configure() { - python waf configure --prefix=/usr ${configure_args} -} - -do_build() { - python waf build ${make_build_args} -} - -do_install() { - if [ -z "$make_install_args" ]; then - make_install_args="--destdir=$DESTDIR" - fi - python waf install ${make_install_args} -} diff --git a/xbps-src/libexec/Makefile b/xbps-src/libexec/Makefile deleted file mode 100644 index aad856f8fb2ee4..00000000000000 --- a/xbps-src/libexec/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -include ../vars.mk - -SCRIPTS = chroot-helper.sh doinst-helper.sh -MOUNT_BIN = capmount -UMOUNT_BIN = capumount -CHROOT_BIN = capchroot -BINS = $(CHROOT_BIN) $(MOUNT_BIN) $(UMOUNT_BIN) -WFLAGS = -Wall -Werror -LDFLAGS = -lcap - -ifdef IN_CHROOT -BINS = -SCRIPTS = doinst-helper.sh -endif - -.PHONY: all -all: $(BINS) - -.PHONY: clean -clean: - -rm -f $(BINS) - -.PHONY: install -install: - install -d $(DESTDIR)$(LIBEXECDIR) - for bin in $(SCRIPTS); do \ - install -m755 $$bin $(DESTDIR)$(LIBEXECDIR); \ - done -ifdef BINS - install -m755 $(MOUNT_BIN) $(DESTDIR)$(LIBEXECDIR) - setcap cap_sys_admin=ep $(DESTDIR)$(LIBEXECDIR)/$(MOUNT_BIN) - install -m755 $(UMOUNT_BIN) $(DESTDIR)$(LIBEXECDIR) - setcap cap_sys_admin=ep $(DESTDIR)$(LIBEXECDIR)/$(UMOUNT_BIN) - install -m755 $(CHROOT_BIN) $(DESTDIR)$(LIBEXECDIR) - setcap cap_sys_chroot=ep $(DESTDIR)$(LIBEXECDIR)/$(CHROOT_BIN) -endif - -.PHONY: uninstall -uninstall: - for bin in $(BINS) $(SCRIPTS); do \ - rm -f $(DESTDIR)$(LIBEXECDIR)/$$bin; \ - done - -$(MOUNT_BIN): - $(CC) $(WFLAGS) mount.c $(LDFLAGS) -o $@ - -$(UMOUNT_BIN): - $(CC) $(WFLAGS) umount.c $(LDFLAGS) -o $@ - -$(CHROOT_BIN): - $(CC) $(WFLAGS) chroot.c $(LDFLAGS) -o $@ diff --git a/xbps-src/libexec/chroot-helper.sh b/xbps-src/libexec/chroot-helper.sh deleted file mode 100644 index a3b2f3551d0d81..00000000000000 --- a/xbps-src/libexec/chroot-helper.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/sh -#- -# Copyright (c) 2010-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -HANDLER="$1" - -REQFS="sys proc dev xbps host" - -mount_chroot_fs() -{ - local cnt f blah dowrite - - for f in ${REQFS}; do - if [ ! -f ${MASTERDIR}/.${f}_mount_bind_done ]; then - unset dowrite - echo -n "=> Mounting /${f} in chroot... " - if [ ! -d ${MASTERDIR}/${f} ]; then - mkdir -p ${MASTERDIR}/${f} - fi - case ${f} in - xbps) - blah=${DISTRIBUTIONDIR} - dowrite="-w" - ;; - host) - blah=${HOSTDIR} - dowrite="-w" - ;; - *) blah=/${f};; - esac - if [ -z "$HOSTDIR" -a "$f" = "host" ]; then - echo "unset, ignoring." - continue - fi - [ ! -d ${blah} ] && echo "failed." && continue - ${XBPS_LIBEXECDIR}/capmount \ - ${dowrite} ${blah} ${MASTERDIR}/${f} \ - 2>/dev/null - if [ $? -eq 0 ]; then - echo 1 > ${MASTERDIR}/.${f}_mount_bind_done - echo "done." - else - echo "FAILED!" - exit 1 - fi - else - cnt=$(cat ${MASTERDIR}/.${f}_mount_bind_done) - cnt=$((${cnt} + 1)) - echo ${cnt} > ${MASTERDIR}/.${f}_mount_bind_done - fi - done -} - -umount_chroot_fs() -{ - local fs dir cnt - - for fs in ${REQFS}; do - [ ! -f ${MASTERDIR}/.${fs}_mount_bind_done ] && continue - cnt=$(cat ${MASTERDIR}/.${fs}_mount_bind_done) - if [ ${cnt} -gt 1 ]; then - cnt=$((${cnt} - 1)) - echo ${cnt} > ${MASTERDIR}/.${fs}_mount_bind_done - else - echo -n "=> Unmounting ${fs} from chroot... " - ${XBPS_LIBEXECDIR}/capumount \ - ${MASTERDIR} ${fs} 2>/dev/null - if [ $? -eq 0 ]; then - rm -f ${MASTERDIR}/.${fs}_mount_bind_done - echo "done." - else - echo "FAILED!!!" - fi - fi - unset fs - done -} - -if [ $# -ne 1 ]; then - echo "$0: mount || umount" - exit 1 -fi - -if [ -z "$MASTERDIR" -o -z "$DISTRIBUTIONDIR" ]; then - echo "$0: MASTERDIR or DISTRIBUTIONDIR unset, can't continue." - exit 1 -fi - -case "${HANDLER}" in - mount) mount_chroot_fs;; - umount) umount_chroot_fs;; - *) echo "$0: invalid target." && exit 1;; -esac - -exit 0 diff --git a/xbps-src/libexec/chroot.c b/xbps-src/libexec/chroot.c deleted file mode 100644 index b580366010a9fc..00000000000000 --- a/xbps-src/libexec/chroot.c +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * Copyright (c) 2010-2011 Juan Romero Pardines. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * chroot() to target directory by using the CAP_CHROOT - * capability set on the file. - * - * As security measure it only allows to chroot when the target directory - * is owned by the same user executing the process and it has read/write - * permission on it. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define _PROGNAME "xbps-src-capchroot" - -void -usage(void) -{ - fprintf(stderr, "Usage: %s \n", _PROGNAME); - exit(EXIT_FAILURE); -} - -int -main(int argc, char **argv) -{ - cap_t cap; - cap_flag_value_t effective, permitted; - struct stat st; - char *path; - - if (argc < 3) - usage(); - - cap = cap_get_proc(); - if (cap == NULL) { - fprintf(stderr, "cap_get_proc() returned %s!\n", - strerror(errno)); - exit(EXIT_FAILURE); - } - - cap_get_flag(cap, CAP_SYS_CHROOT, CAP_EFFECTIVE, &effective); - cap_get_flag(cap, CAP_SYS_CHROOT, CAP_PERMITTED, &permitted); - if ((effective != CAP_SET) && (permitted != CAP_SET)) { - fprintf(stderr, "ERROR: missing 'cap_sys_chroot' capability!\n" - "Please set it with: setcap cap_sys_chroot=ep %s'\n", - argv[0]); - cap_free(cap); - exit(EXIT_FAILURE); - } - cap_free(cap); - - if ((path = realpath(argv[1], NULL)) == NULL) { - fprintf(stderr, "ERROR: realpath() %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - - /* Disallow chroot to '/' */ - if (strcmp(path, "/") == 0) { - fprintf(stderr, "ERROR: chroot to / is not allowed!\n"); - exit(EXIT_FAILURE); - } - - /* - * Check that uid/gid owns the dir and has rx perms on the - * new target root and it is a directory. - */ - if (stat(path, &st) == -1) { - fprintf(stderr, "ERROR: stat() on %s: %s\n", - path, strerror(errno)); - exit(EXIT_FAILURE); - } - if (S_ISDIR(st.st_mode) == 0) { - fprintf(stderr, "ERROR: '%s' not a directory!\n", path); - exit(EXIT_FAILURE); - } - if ((st.st_uid != getuid()) && (st.st_gid != getgid()) && - (st.st_mode & (S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP))) { - fprintf(stderr, "ERROR: wrong permissions on %s!\n", path); - exit(EXIT_FAILURE); - } - /* All ok, change root and process argv on the target root dir. */ - if (chroot(path) == -1) { - fprintf(stderr, "ERROR: chroot() on %s: %s\n", argv[1], - strerror(errno)); - exit(EXIT_FAILURE); - } - if (chdir("/") == -1) { - fprintf(stderr, "ERROR: chdir(): %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - argv += 2; - (void)execvp(argv[0], argv); - - exit(EXIT_FAILURE); -} diff --git a/xbps-src/libexec/doinst-helper.sh b/xbps-src/libexec/doinst-helper.sh deleted file mode 100644 index 742b5f930e4ed3..00000000000000 --- a/xbps-src/libexec/doinst-helper.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/bin/sh -#- -# Copyright (c) 2010-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -PKG_TMPLNAME="$1" - -if [ -n "${CONFIG_FILE}" -a -r "${CONFIG_FILE}" ]; then - . ${CONFIG_FILE} -fi - -if [ -n "${MASTERDIR}" ]; then - export XBPS_MASTERDIR="${MASTERDIR}" -fi - -. ${XBPS_SHAREDIR}/shutils/init_funcs.sh - -set_defvars - -for f in $XBPS_SHUTILSDIR/*.sh; do - [ -r "$f" ] && . $f -done - -install_src_phase() -{ - local f i subpkg spkgrev - - [ -z $pkgname ] && return 2 - # - # There's nothing we can do if we are a meta template. - # Just creating the dir is enough to write the package metadata. - # - if [ "$build_style" = "meta-template" ]; then - mkdir -p $XBPS_DESTDIR/$pkgname-$version - return 0 - fi - - cd $wrksrc || msg_error "can't change cwd to wrksrc!\n" - if [ -n "$build_wrksrc" ]; then - cd $build_wrksrc \ - || msg_error "can't change cwd to build_wrksrc!\n" - fi - - # Run pre_install func. - if [ ! -f $XBPS_PRE_INSTALL_DONE ]; then - run_func pre_install - [ $? -eq 0 ] && touch -f $XBPS_PRE_INSTALL_DONE - fi - - # do_install() - if [ -r $XBPS_HELPERSDIR/${build_style}.sh ]; then - . $XBPS_HELPERSDIR/${build_style}.sh - fi - run_func do_install - - cd ${wrksrc} || msg_error "can't change cwd to wrksrc!\n" - - # Run post_install func. - if [ ! -f $XBPS_POST_INSTALL_DONE ]; then - run_func post_install - [ $? -eq 0 ] && touch -f $XBPS_POST_INSTALL_DONE - fi - - # Remove libtool archives by default. - if [ -z "$keep_libtool_archives" ]; then - msg_normal "$pkgver: removing libtool archives...\n" - find ${DESTDIR} -type f -name \*.la -delete - fi - # Remove bytecode python generated files. - msg_normal "$pkgver: removing python bytecode archives...\n" - find ${DESTDIR} -type f -name \*.py[co] -delete - - # Always remove perllocal.pod and .packlist files. - if [ "$pkgname" != "perl" ]; then - find ${DESTDIR} -type f -name perllocal.pod -delete - find ${DESTDIR} -type f -name .packlist -delete - fi - # Remove empty directories by default. - for f in $(find ${DESTDIR} -depth -type d); do - rmdir $f 2>/dev/null && msg_warn "removed empty dir: ${f##${DESTDIR}}\n" - done - # - # Build subpackages if found. - # - for subpkg in ${subpackages}; do - if [ -n "$revision" ]; then - spkgrev="${subpkg}-${version}_${revision}" - else - spkgrev="${subpkg}-${version}" - fi - check_installed_pkg ${spkgrev} - if [ $? -eq 0 -a -z "$BOOTSTRAP_PKG_REBUILD" ]; then - continue - fi - msg_normal "$pkgver: preparing subpackage '${subpkg}'...\n" - if [ ! -f $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template ]; then - msg_error "Cannot find '${subpkg}' subpkg build template!\n" - fi - . $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template - pkgname=${subpkg} - set_tmpl_common_vars - if [ ! -f ${wrksrc}/.xbps_do_install_${pkgname}_done ]; then - run_func do_install - if [ $? -eq 0 ]; then - touch -f ${wrksrc}/.xbps_do_install_${pkgname}_done - fi - else - msg_warn "$pkgver: skipping '$pkgname' subpkg, already installed into destdir.\n" - fi - done - touch -f $XBPS_INSTALL_DONE -} - -[ -z "$PKG_TMPLNAME" ] && exit 2 - -setup_tmpl $PKG_TMPLNAME -install_src_phase $pkgname - -exit 0 diff --git a/xbps-src/libexec/mount.c b/xbps-src/libexec/mount.c deleted file mode 100644 index 1c6d063963691e..00000000000000 --- a/xbps-src/libexec/mount.c +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * Copyright (c) 2010-2011 Juan Romero Pardines. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Bind mounts a filesystem mountpoint into the target directory, - * by using the CAP_SYS_ADMIN capability set on the program. - * - * Only mounts are possible when user running the process owns - * the target directory and has read/write permission on it. - * - * Mounts are also mounted with nosuid for security meassures. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define _PROGNAME "xbps-src-chroot-capmount" - -void -usage(void) -{ - fprintf(stderr, "Usage: %s [-w] \n", _PROGNAME); - exit(EXIT_FAILURE); -} - -int -main(int argc, char **argv) -{ - cap_t cap; - cap_flag_value_t effective, permitted; - struct stat st; - unsigned long flags; - int c, rv; - bool dowrite = false; - - while ((c = getopt(argc, argv, "w")) != -1) { - switch (c) { - case 'w': - dowrite = true; - break; - default: - usage(); - } - } - - argc -= optind; - argv += optind; - - if (argc != 2) - usage(); - - cap = cap_get_proc(); - if (cap == NULL) { - fprintf(stderr, "cap_get_proc() returned %s!\n", - strerror(errno)); - exit(EXIT_FAILURE); - } - - cap_get_flag(cap, CAP_SYS_ADMIN, CAP_EFFECTIVE, &effective); - cap_get_flag(cap, CAP_SYS_ADMIN, CAP_PERMITTED, &permitted); - if ((effective != CAP_SET) && (permitted != CAP_SET)) { - fprintf(stderr, "E: missing 'cap_sys_admin' capability!\n" - "Please set it with: setcap cap_sys_admin=ep %s'\n", - argv[0]); - cap_free(cap); - exit(EXIT_FAILURE); - } - cap_free(cap); - - /* - * Bind mount with nosuid. - */ - flags = MS_BIND | MS_NOSUID; - if (!dowrite) - flags |= MS_RDONLY; - - /* - * Check that uid/gid owns the dir and has rx perms on it. - */ - if (stat(argv[1], &st) == -1) { - fprintf(stderr, "ERROR: stat() on %s: %s\n", - argv[1], strerror(errno)); - exit(EXIT_FAILURE); - } - if ((st.st_uid != getuid()) && (st.st_gid != getgid()) && - (st.st_mode & (S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP))) { - fprintf(stderr, "ERROR: wrong permissions on %s!\n", argv[1]); - exit(EXIT_FAILURE); - } - - rv = mount(argv[0], argv[1], "none", flags, NULL); - if (rv != 0) { - fprintf(stderr, "E: cannot mount %s into %s: %s\n", argv[0], - argv[1], strerror(errno)); - exit(EXIT_FAILURE); - } - - exit(EXIT_SUCCESS); -} diff --git a/xbps-src/libexec/umount.c b/xbps-src/libexec/umount.c deleted file mode 100644 index 23314526d6092a..00000000000000 --- a/xbps-src/libexec/umount.c +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * Copyright (c) 2010-2011 Juan Romero Pardines. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Umounts a mounted filesystem mountpoint as regular user thanks to - * the CAP_SYS_ADMIN capability flag set on the file. The following - * arguments are expected: . - * - * As security measure it only accepts to unmount a mount point - * when the "status" file has been previously written in the masterdir. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define _PROGNAME "xbps-src-chroot-capumount" - -void -usage(void) -{ - fprintf(stderr, "Usage: %s \n", _PROGNAME); - exit(EXIT_FAILURE); -} - -int -main(int argc, char **argv) -{ - cap_t cap; - cap_flag_value_t effective, permitted; - char bindf[PATH_MAX - 1]; - int rv; - - if (argc != 3) - usage(); - - cap = cap_get_proc(); - if (cap == NULL) { - fprintf(stderr, "cap_get_proc() returned %s!\n", - strerror(errno)); - exit(EXIT_FAILURE); - } - - cap_get_flag(cap, CAP_SYS_ADMIN, CAP_EFFECTIVE, &effective); - cap_get_flag(cap, CAP_SYS_ADMIN, CAP_PERMITTED, &permitted); - if ((effective != CAP_SET) && (permitted != CAP_SET)) { - fprintf(stderr, "E: missing 'cap_sys_admin' capability!\n" - "Please set it with: setcap cap_sys_admin=ep %s'\n", - argv[0]); - cap_free(cap); - exit(EXIT_FAILURE); - } - cap_free(cap); - - /* Check that status file exists in masterdir */ - rv = snprintf(bindf, sizeof(bindf), "%s/.%s_mount_bind_done", - argv[1], argv[2]); - if (rv < 0 || rv >= sizeof(bindf)) - exit(EXIT_FAILURE); - - if (access(bindf, R_OK) == -1) { - fprintf(stderr, "E: cannot umount %s/%s, missing " - "status file\n", argv[1], argv[2]); - exit(EXIT_FAILURE); - } - - /* Security check passed, continue mounting */ - rv = snprintf(bindf, sizeof(bindf), "%s/%s", argv[1], argv[2]); - if (rv < 0 || rv >= sizeof(bindf)) - exit(EXIT_FAILURE); - - if ((rv = umount(bindf)) != 0) { - fprintf(stderr, "E: cannot umount %s: %s\n", argv[1], - strerror(errno)); - exit(EXIT_FAILURE); - } - - exit(EXIT_SUCCESS); -} diff --git a/xbps-src/shutils/Makefile b/xbps-src/shutils/Makefile deleted file mode 100644 index a86ea5321ba8d1..00000000000000 --- a/xbps-src/shutils/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -include ../vars.mk - -.PHONY: clean -clean: - -rm -f $(SCRIPTS) - -.PHONY: install -install: - install -d $(DESTDIR)$(SHAREDIR)/shutils - install -m 644 *.sh $(DESTDIR)$(SHAREDIR)/shutils - -.PHONY: uninstall -uninstall: - -rm -rf $(DESTDIR)$(SHAREDIR)/shutils diff --git a/xbps-src/shutils/build_funcs.sh b/xbps-src/shutils/build_funcs.sh deleted file mode 100644 index 97680e33de06aa..00000000000000 --- a/xbps-src/shutils/build_funcs.sh +++ /dev/null @@ -1,73 +0,0 @@ -#- -# Copyright (c) 2008-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -# -# Runs the "build" phase for a pkg. This builds the binaries and other -# related stuff. -# -build_src_phase() -{ - local rval - - [ -z $pkgname -o -z $version ] && return 1 - - # Skip this phase for meta-template style builds. - [ -n "$build_style" -a "$build_style" = "meta-template" ] && return 0 - - [ ! -d $wrksrc ] && msg_error "unexistent build directory [$wrksrc]\n" - - cd $wrksrc || return 1 - if [ -n "$build_wrksrc" ]; then - cd $build_wrksrc || return 1 - fi - - if [ -n "$XBPS_MAKEJOBS" -a -z "$disable_parallel_build" ]; then - makejobs="-j$XBPS_MAKEJOBS" - fi - - # Run pre_build func. - if [ ! -f $XBPS_PRE_BUILD_DONE ]; then - run_func pre_build - [ $? -eq 0 ] && touch -f $XBPS_PRE_BUILD_DONE - fi - - if [ -r $XBPS_HELPERSDIR/${build_style}.sh ]; then - . $XBPS_HELPERSDIR/${build_style}.sh - fi - - # do_build() - run_func do_build - rval=$? - - # Run post_build func. - if [ ! -f $XBPS_POST_BUILD_DONE ]; then - run_func post_build - [ $? -eq 0 ] && touch -f $XBPS_POST_BUILD_DONE - fi - - [ "$rval" -eq 0 ] && touch -f $XBPS_BUILD_DONE - - return 0 -} diff --git a/xbps-src/shutils/builddep_funcs.sh b/xbps-src/shutils/builddep_funcs.sh deleted file mode 100644 index f7f41d15ae3a99..00000000000000 --- a/xbps-src/shutils/builddep_funcs.sh +++ /dev/null @@ -1,319 +0,0 @@ -#- -# Copyright (c) 2008-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -# -# Install a required package dependency, like: -# -# xbps-bin -Ay install "pattern" -# -install_pkg_from_repos() -{ - local rval tmplogf tmpdepf - - msg_normal "$pkgver: installing '$1'... " - - case "${XBPS_VERSION}" in - 0.1[1-9].[0-9]*) - _pkgdepname=$($XBPS_PKGDB_CMD getpkgdepname "$1") - $XBPS_REPO_CMD -oversion show ${_pkgdepname} >/dev/null 2>&1 - if [ $? -ne 0 ]; then - msg_normal_append "not found, building from source...\n" - return 2 - fi - _pkgver=$($XBPS_REPO_CMD} -oversion show ${_pkgdepname}) - msg_normal_append "found ${_pkgver} " - $XBPS_PKGDB_CMD pkgmatch "${_pkgdepname}-${_pkgver}" "${1}" - if [ $? -eq 1 ]; then - _repoloc=$($XBPS_REPO_CMD} -orepository show ${_pkgdepname}) - msg_normal_append "(${_repoloc})\n" - else - msg_normal_append "not matched, building from source...\n" - return 2 - fi - ;; - *) msg_normal_append "\n";; - esac - - tmplogf=$(mktemp) - $FAKEROOT_CMD $FAKEROOT_CMD_ARGS $XBPS_BIN_CMD -Ay install ${_pkgdepname} >$tmplogf 2>&1 - rval=$? - if [ $rval -ne 0 -a $rval -ne 6 ]; then - # xbps-bin can return: - # - # SUCCESS (0): package installed successfully. - # ENOENT (2): package missing in repositories. - # EEXIST (6): package already installed. - # ENODEV (19): package depends on missing dependencies. - # - # Any other error returned is critical. - autoremove_pkg_dependencies $KEEP_AUTODEPS - msg_red "$pkgver: failed to install '$1' dependency! (error $rval)\n" - cat $tmplogf && rm -f $tmplogf - msg_error "Please see above for the real error, exiting...\n" - fi - rm -f $tmplogf - - return $rval -} - -autoremove_pkg_dependencies() -{ - local cmd curpkgname f - - [ -n "$1" ] && return 0 - - cmd="${FAKEROOT_CMD} ${FAKEROOT_CMD_ARGS} ${XBPS_BIN_CMD}" - - # If XBPS_PREFER_BINPKG_DEPS is set, we should remove those - # package dependencies installed by the target package, do it. - # - if [ -n "$XBPS_PREFER_BINPKG_DEPS" -a -z "$bootstrap" ]; then - msg_normal "$pkgver: removing automatically installed dependencies ...\n" - # Autoremove installed binary packages. - ${cmd} -y reconfigure all && ${cmd} -Rpyf autoremove - if [ $? -ne 0 ]; then - msg_red "$pkgver: failed to remove automatic dependencies!\n" - exit 1 - fi - fi -} - -# -# Recursive function that installs all direct and indirect -# dependencies of a package. -# -install_pkg_deps() -{ - local curpkg="$1" - local curpkgname=$(${XBPS_PKGDB_CMD} getpkgdepname "$1") - local saved_prevpkg=$(${XBPS_PKGDB_CMD} getpkgdepname "$2") - local j jver jname reqver - - [ -z "$curpkg" -o -z "$curpkgname" ] && return 2 - - if [ -n "$prev_pkg" ]; then - curpkg=$prev_pkg - curpkgname="$(${XBPS_PKGDB_CMD} getpkgdepname ${curpkg})" - fi - - check_pkgdep_matched "$curpkg" - [ $? -eq 0 ] && return 0 - - if [ -z "$saved_prevpkg" -a -n "${_ORIGINPKG}" ]; then - msg_normal "Installing ${_ORIGINPKG} dependency: '$curpkg'.\n" - else - msg_normal "Installing $saved_prevpkg dependency: '$curpkg'.\n" - fi - - setup_tmpl "$curpkgname" - check_build_depends_pkg - if [ $? -eq 0 ]; then - msg_normal "Package '$curpkgname' requires:\n" - for j in ${build_depends}; do - jname="$(${XBPS_PKGDB_CMD} getpkgdepname ${j})" - jver="$($XBPS_PKGDB_CMD version ${jname})" - check_pkgdep_matched "${j}" - if [ $? -eq 0 ]; then - echo " ${j}: found '$jname-$jver'." - else - echo " ${j}: not found." - fi - done - fi - - for j in ${build_depends}; do - prev_pkg="$j" - if [ -n "$XBPS_PREFER_BINPKG_DEPS" -a -z "$bootstrap" ]; then - install_pkg_from_repos "${j}" - if [ $? -eq 255 ]; then - # xbps-bin returned unexpected error - msg_red "$saved_prevpkg: failed to install '$j'\n" - elif [ $? -eq 0 ]; then - # package installed successfully. - : - continue - fi - else - # - # Iterate again, this will check if there are more - # required deps for current pkg. - # - install_pkg_deps "${j}" "${curpkg}" - if [ $? -eq 1 ]; then - if [ -n "$saved_prevpkg" ]; then - msg_red "$saved_prevpkg: failed to install '$curpkg'\n" - else - msg_red "${_ORIGINPKG}: failed to install '$curpkg'\n" - fi - return 1 - fi - fi - done - - if [ -n "$XBPS_PREFER_BINPKG_DEPS" -a -z "$bootstrap" ]; then - install_pkg_from_repos "${curpkg}" - if [ $? -eq 255 ]; then - # xbps-bin returned unexpected error - return $? - elif [ $? -eq 2 ]; then - # Package not found, build from source. - install_pkg "${curpkgname}" - if [ $? -eq 1 ]; then - msg_red "$saved_prevpkg: failed to install '$curpkg'\n" - return 1 - fi - fi - else - if [ -n "$saved_prevpkg" ]; then - msg_normal "$saved_prevpkg: installing '$curpkg'...\n" - else - msg_normal "${_ORIGINPKG}: installing '$curpkg'...\n" - fi - install_pkg "${curpkgname}" - if [ $? -eq 1 ]; then - msg_red "$saved_prevpkg: failed to install '$curpkg'\n" - return 1 - fi - fi - unset prev_pkg -} - -# -# Installs all dependencies required by a package. -# -install_dependencies_pkg() -{ - local pkg="$1" - local i pkgn iver missing_deps - trap "msg_error 'interrupted\n'" INT - - [ -z "$pkg" ] && return 2 - [ -z "$build_depends" ] && return 0 - - INSTALLING_DEPS=1 - - msg_normal "$pkgver: required build dependencies...\n" - - for i in ${build_depends}; do - pkgn=$($XBPS_PKGDB_CMD getpkgdepname "${i}") - iver=$($XBPS_PKGDB_CMD version "${pkgn}") - check_pkgdep_matched "${i}" - if [ $? -eq 0 ]; then - echo " ${i}: found '$pkgn-$iver'." - else - echo " ${i}: not found." - if [ -z "$missing_deps" ]; then - missing_deps="${i}" - else - missing_deps="${missing_deps} ${i}" - fi - fi - done - - [ -z "$missing_deps" ] && return 0 - - # Install direct build dependencies from binary packages. - if [ -n "$XBPS_PREFER_BINPKG_DEPS" -a -z "$bootstrap" ]; then - msg_normal "$pkgver: installing dependencies from repositories ...\n" - for i in ${missing_deps}; do - install_pkg_from_repos "${i}" - if [ $? -eq 2 ]; then - # ENOENT; install from source - install_pkg_deps "${i}" "${pkg}" || return 1 - curpkgdepname="$($XBPS_PKGDB_CMD getpkgdepname ${i})" - setup_tmpl $curpkgdepname - install_pkg $curpkgdepname - setup_tmpl $($XBPS_PKGDB_CMD getpkgname ${pkg}) - install_dependencies_pkg "${pkg}" - fi - done - else - # Install direct and indirect build dependencies from source. - for i in ${missing_deps}; do - install_pkg_deps "${i}" "${pkg}" || return 1 - done - fi - - # unregister sighandler. - trap - INT -} - -# -# Returns 0 if pkgpattern in $1 is matched against current installed -# package, 1 otherwise. -# -check_pkgdep_matched() -{ - local pkg="$1" pkgn iver - - [ -z "$pkg" ] && return 2 - - pkgn="$($XBPS_PKGDB_CMD getpkgdepname ${pkg})" - [ -z "$pkgn" ] && return 2 - - iver="$($XBPS_PKGDB_CMD version $pkgn)" - if [ -n "$iver" ]; then - ${XBPS_PKGDB_CMD} pkgmatch "${pkgn}-${iver}" "${pkg}" - [ $? -eq 1 ] && return 0 - fi - - return 1 -} - -# -# Returns 0 if pkgpattern in $1 is installed and greater than current -# installed package, otherwise 1. -# -check_installed_pkg() -{ - local pkg="$1" pkgn iver - - [ -z "$pkg" ] && return 2 - - pkgn="$($XBPS_PKGDB_CMD getpkgname ${pkg})" - [ -z "$pkgn" ] && return 2 - - iver="$($XBPS_PKGDB_CMD version $pkgn)" - if [ -n "$iver" ]; then - ${XBPS_CMPVER_CMD} "${pkgn}-${iver}" "${pkg}" - [ $? -eq 0 -o $? -eq 1 ] && return 0 - fi - - return 1 -} - -# -# Returns 0 if pkg has build deps, 1 otherwise. -# -check_build_depends_pkg() -{ - [ -z "$pkgname" ] && return 2 - - if [ -n "$build_depends" ]; then - return 0 - else - return 1 - fi -} diff --git a/xbps-src/shutils/check_installed_packages.sh b/xbps-src/shutils/check_installed_packages.sh deleted file mode 100644 index eb9c2436311e62..00000000000000 --- a/xbps-src/shutils/check_installed_packages.sh +++ /dev/null @@ -1,67 +0,0 @@ -#- -# Copyright (c) 2010 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- -# -# Check installed package versions against the source packages repository. -# - -# A simple wrapper to speed it up a bit. -Add_dependency() { - : -} - -check_installed_packages() -{ - local f lpkgn lpkgver rv srcpkgver srcver - - for f in $(${XBPS_BIN_CMD} list|awk '{print $1}'); do - lpkgn=$(${XBPS_PKGDB_CMD} getpkgname ${f}) - lpkgver=$(${XBPS_PKGDB_CMD} getpkgversion ${f}) - - if [ -r ${XBPS_SRCPKGDIR}/${lpkgn}/${lpkgn}.template ]; then - . ${XBPS_SRCPKGDIR}/${lpkgn}/template - unset revision - sourcepkg=$pkgname - . ${XBPS_SRCPKGDIR}/${lpkgn}/${lpkgn}.template - else - if [ ! -r ${XBPS_SRCPKGDIR}/${lpkgn}/template ]; then - continue - fi - . ${XBPS_SRCPKGDIR}/${lpkgn}/template - fi - if [ -n "$revision" ]; then - srcver="${version}_${revision}" - srcpkgver="${lpkgn}-${version}_${revision}" - else - srcver="${version}" - srcpkgver="${lpkgn}-${version}" - fi - ${XBPS_CMPVER_CMD} ${f} ${srcpkgver} - rv=$? - if [ $rv -eq 255 ]; then - echo "${lpkgn} ${lpkgver} ${srcver}" - fi - unset pkgname version revision - done -} diff --git a/xbps-src/shutils/chroot.sh b/xbps-src/shutils/chroot.sh deleted file mode 100644 index 96b8847f6d595b..00000000000000 --- a/xbps-src/shutils/chroot.sh +++ /dev/null @@ -1,354 +0,0 @@ -#- -# Copyright (c) 2008-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -_mount() -{ - MASTERDIR="${XBPS_MASTERDIR}" DISTRIBUTIONDIR="${XBPS_DISTRIBUTIONDIR}" \ - HOSTDIR="${XBPS_HOSTDIR}" XBPS_ETCDIR="${XBPS_ETCDIR}" \ - XBPS_SHAREDIR="${XBPS_SHAREDIR}" ${SUDO_CMD} \ - ${XBPS_LIBEXECDIR}/chroot-helper.sh mount - return $? -} - -_umount() -{ - MASTERDIR="${XBPS_MASTERDIR}" DISTRIBUTIONDIR="${XBPS_DISTRIBUTIONDIR}" \ - HOSTDIR="${XBPS_HOSTDIR}" XBPS_ETCDIR="${XBPS_ETCDIR}" \ - XBPS_SHAREDIR="${XBPS_SHAREDIR}" ${SUDO_CMD} \ - ${XBPS_LIBEXECDIR}/chroot-helper.sh umount - return $? -} - -chroot_init() -{ - trap "_umount && return $?" 0 INT QUIT TERM - - [ -n "$bootstrap" ] && return 0 - - if [ "${CHROOT_CMD}" = "chroot" ]; then - if [ "$(id -u)" -ne 0 ]; then - msg_error "Root permissions are required for the chroot, try again." - fi - fi - - check_installed_pkg base-chroot-0.11 - if [ $? -ne 0 ]; then - echo "${XBPS_MASTERDIR} has not been prepared for chroot operations." - echo "Please install 'base-chroot>=0.11' and try again." - exit 1 - fi - - msg_normal "Entering into the chroot on $XBPS_MASTERDIR.\n" - - if [ ! -d $XBPS_MASTERDIR/usr/local/etc ]; then - mkdir -p $XBPS_MASTERDIR/usr/local/etc - fi - - XBPSSRC_CF=$XBPS_MASTERDIR/usr/local/etc/xbps/xbps-src.conf - - cat > $XBPSSRC_CF <<_EOF -# Generated configuration file by xbps-src, DO NOT EDIT! -XBPS_DISTRIBUTIONDIR=/xbps -XBPS_MASTERDIR=/ -XBPS_CFLAGS="$XBPS_CFLAGS" -XBPS_CXXFLAGS="$XBPS_CFLAGS" -XBPS_LDFLAGS="$XBPS_LDFLAGS" -XBPS_FETCH_CMD="xbps-uhelper.static fetch" -XBPS_COMPRESS_CMD="$XBPS_COMPRESS_CMD" -_EOF - - if [ -n "$XBPS_MAKEJOBS" ]; then - echo "XBPS_MAKEJOBS=$XBPS_MAKEJOBS" >> $XBPSSRC_CF - fi - if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then - echo "XBPS_PREFER_BINPKG_DEPS=$XBPS_PREFER_BINPKG_DEPS" >> $XBPSSRC_CF - fi - if [ -n "$XBPS_COMPRESS_LEVEL" ]; then - echo "XBPS_COMPRESS_LEVEL=$XBPS_COMPRESS_LEVEL" >> $XBPSSRC_CF - fi - if [ -n "$XBPS_HOSTDIR" ]; then - echo "XBPS_HOSTDIR=/host" >> $XBPSSRC_CF - fi - if [ -n "$XBPS_CCACHE" ]; then - echo "XBPS_CCACHE=$XBPS_CCACHE" >> $XBPSSRC_CF - fi - echo "# End of configuration file." >> $XBPSSRC_CF - - if [ -d $XBPS_MASTERDIR/tmp ]; then - if [ ! -f $XBPS_MASTERDIR/.xbps_mount_bind_done ]; then - msg_normal "Cleaning up /tmp...\n" - [ -h ${XBPS_MASTERDIR}/tmp ] || rm -rf $XBPS_MASTERDIR/tmp/* - fi - fi - - # Create custom script to start the chroot bash shell. - cat > $XBPS_MASTERDIR/bin/xbps-shell <<_EOF -#!/bin/sh - -. /usr/local/etc/xbps/xbps-src.conf -. /usr/local/share/xbps-src/shutils/init_funcs.sh -set_defvars - -PATH=/tools/bin:/usr/local/sbin:/bin:/usr/bin:/sbin -PATH=\$PATH:/usr/local/bin:/usr/lib/perl5/core_perl/bin -export PATH - -exec env PS1="[\u@masterdir-chroot \W]$ " /bin/bash -_EOF - chmod 755 $XBPS_MASTERDIR/bin/xbps-shell -} - -prepare_chroot() -{ - local f - - # Create some required files. - cp -f /etc/mtab $XBPS_MASTERDIR/etc - cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc - [ -f /etc/localtime ] && cp -f /etc/localtime $XBPS_MASTERDIR/etc - - for f in run/utmp log/btmp log/lastlog log/wtmp; do - touch -f $XBPS_MASTERDIR/var/$f - done - for f in run/utmp log/lastlog; do - chmod 644 $XBPS_MASTERDIR/var/$f - done - [ ! -d $XBPS_MASTERDIR/boot ] && mkdir -p $XBPS_MASTERDIR/boot - - cat > $XBPS_MASTERDIR/etc/passwd <<_EOF -root:x:0:0:root:/root:/bin/bash -nobody:x:99:99:Unprivileged User:/dev/null:/bin/false -$(whoami):x:$(id -u):$(id -g):$(whoami) user:/dev/null:/bin/bash -_EOF - - # Default group list as specified by LFS. - cat > $XBPS_MASTERDIR/etc/group <<_EOF -root:x:0: -bin:x:1: -sys:x:2: -kmem:x:3: -wheel:x:4: -tty:x:5: -tape:x:6: -daemon:x:7: -floppy:x:8: -disk:x:9: -lp:x:10: -dialout:x:11: -audio:x:12: -video:x:13: -utmp:x:14: -usb:x:15: -cdrom:x:16: -optical:x:17: -mail:x:18: -storage:x:19: -scanner:x:20: -nogroup:x:99: -users:x:1000: -$(whoami):x:$(id -g): -_EOF - - # Default file as in Ubuntu. - cat > $XBPS_MASTERDIR/etc/hosts <<_EOF -127.0.0.1 xbps localhost.localdomain localhost -127.0.1.1 xbps - -# The following lines are desirable for IPv6 capable hosts -::1 ip6-localhost ip6-loopback -fe00::0 ip6-localnet -ff00::0 ip6-mcastprefix -ff02::1 ip6-allnodes -ff02::2 ip6-allrouters -ff02::3 ip6-allhosts -_EOF - - create_binsh_symlink - - touch $XBPS_MASTERDIR/.xbps_perms_done -} - -create_binsh_symlink() -{ - if [ ! -h $XBPS_MASTERDIR/bin/sh ]; then - cd $XBPS_MASTERDIR/bin - if [ -x bash ]; then - ln -sf bash sh - elif [ -x dash ]; then - ln -sf dash sh - elif [ -x busybox ]; then - ln -sf busybox sh - else - msg_error "cannot find a suitable shell for chroot!\n" - fi - - fi -} - -prepare_binpkg_repos() -{ - local repo CONF_FILE - - case "${XBPS_VERSION}" in - 0.1[0-9].[0-9]*) - mkdir -p ${XBPS_MASTERDIR}/usr/local/etc/xbps - for f in /etc /usr/local/etc; do - for conf in conf repositories; do - if [ ! -f $XBPS_MASTERDIR/usr/local/etc/xbps/${conf}.plist ]; then - [ -d $f ] && cp -f $f/xbps/${conf}.plist \ - ${XBPS_MASTERDIR}/usr/local/etc/xbps - fi - done - done - msg_normal "Synchronizing index for remote repositories...\n" - ${XBPS_REPO_CMD} sync 2>/dev/null - ;; - 0.[89].[0-9]*) - CONF_FILE=$XBPS_MASTERDIR/usr/local/etc/xbps-conf.plist - for f in /etc /usr/local/etc; do - if [ -f $f/xbps-conf.plist -a \ - ! -f $CONF_FILE ]; then - cp -f $f/xbps-conf.plist \ - ${XBPS_MASTERDIR}/usr/local/etc - fi - done - # XBPS utils >= 0.9.0. - msg_normal "Synchronizing index for remote repositories...\n" - ${XBPS_REPO_CMD} sync - ;; - *) - for repo in ${XBPS_REPO_LIST}; do - ${XBPS_REPO_CMD} add ${repo} 2>/dev/null - [ $? -ne 0 ] && \ - msg_warn "Failed to sync pkg-index from ${repo}\n" - done - ;; - esac -} - -create_busybox_links() -{ - local lbindir=$XBPS_MASTERDIR/usr/local/bin - - [ ! -d ${lbindir} ] && mkdir -p ${lbindir} - - # Create other symlinks in /usr/local/bin - cd ${lbindir} || return 1 - - for f in $(${XBPS_MASTERDIR}/bin/busybox --list); do - if [ "$f" = "tar" -o "$f" = "sh" -o "$f" = "xz" ]; then - continue - fi - ln -sf ../../../bin/busybox $f - done -} - -install_xbps_utils() -{ - local needed _cmd - local xbps_prefix=$XBPS_MASTERDIR/usr/local - - if [ ! -f ${XBPS_MASTERDIR}/.xbps_utils_done ]; then - echo "=> Installing static XBPS utils into masterdir." - for f in bin repo uhelper; do - _cmd=$(which xbps-${f}.static 2>/dev/null) - if [ -z "${_cmd}" ]; then - echo "Unexistent xbps-uhelper.static file!" - exit 1 - fi - cp -f ${_cmd} $xbps_prefix/sbin - done - touch ${XBPS_MASTERDIR}/.xbps_utils_done - fi -} - -install_xbps_src() -{ - set -e - install -Dm755 ${XBPS_SBINDIR}/xbps-src \ - ${XBPS_MASTERDIR}/usr/local/sbin/xbps-src - install -Dm755 ${XBPS_LIBEXECDIR}/doinst-helper.sh \ - ${XBPS_MASTERDIR}/usr/local/libexec/xbps-src/doinst-helper.sh - install -d ${XBPS_MASTERDIR}/usr/local/share/xbps-src/shutils - install -m644 ${XBPS_SHAREDIR}/shutils/*.sh \ - ${XBPS_MASTERDIR}/usr/local/share/xbps-src/shutils - install -d ${XBPS_MASTERDIR}/usr/local/share/xbps-src/common - install -m644 ${XBPS_SHAREDIR}/common/* \ - ${XBPS_MASTERDIR}/usr/local/share/xbps-src/common - install -d ${XBPS_MASTERDIR}/usr/local/share/xbps-src/helpers - install -m644 ${XBPS_SHAREDIR}/helpers/*.sh \ - ${XBPS_MASTERDIR}/usr/local/share/xbps-src/helpers - set +e -} - -xbps_chroot_handler() -{ - local action="$1" pkg="$2" rv=0 arg - - [ -z "$action" -a -z "$pkg" ] && return 1 - - if [ ! -f $XBPS_MASTERDIR/.xbps_perms_done ]; then - echo -n "==> Preparing chroot on $XBPS_MASTERDIR... " - prepare_chroot - echo "done." - fi - - [ ! -d "$XBPS_MASTERDIR/tmp" ] && mkdir -p "$XBPS_MASTERDIR/tmp" - - chroot_init - create_binsh_symlink - create_busybox_links - install_xbps_utils - install_xbps_src - - _mount || return $? - - if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then - prepare_binpkg_repos - fi - - # Update ld.so(8) cache - msg_normal "Updating ld.so(8) cache...\n" - ${CHROOT_CMD} $XBPS_MASTERDIR sh -c "ldconfig" || return $? - - if [ "$action" = "chroot" ]; then - env IN_CHROOT=1 LANG=C \ - ${CHROOT_CMD} $XBPS_MASTERDIR /bin/xbps-shell || rv=$? - else - [ -n "$KEEP_WRKSRC" ] && arg="$arg -C" - [ -n "$KEEP_AUTODEPS" ] && arg="$arg -K" - [ -n "$DESTDIR_ONLY_INSTALL" ] && arg="$arg -D" - [ -n "$BUILD_BINPKG" ] && arg="$arg -B" - - action="$arg $action" - env in_chroot=1 IN_CHROOT=1 LANG=C _ORIGINPKG="$pkg" \ - ${CHROOT_CMD} $XBPS_MASTERDIR sh -c \ - "xbps-src $action $pkg" || rv=$? - fi - - msg_normal "Exiting from the chroot on $XBPS_MASTERDIR.\n" - - return $rv -} diff --git a/xbps-src/shutils/common_funcs.sh b/xbps-src/shutils/common_funcs.sh deleted file mode 100644 index 3d540c9376595a..00000000000000 --- a/xbps-src/shutils/common_funcs.sh +++ /dev/null @@ -1,159 +0,0 @@ -#- -# Copyright (c) 2008-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -# -# Common functions for xbps. -# -run_func_error() -{ - local func="$1" - - remove_pkgdestdir_sighandler ${pkgname} $KEEP_AUTODEPS - echo - msg_error "$pkgver: '$func' interrupted!\n" -} - -remove_pkgdestdir_sighandler() -{ - local subpkg _pkgname="$1" _kwrksrc="$2" - - setup_tmpl ${_pkgname} - [ -z "$sourcepkg" ] && return 0 - - # If there is any problem in the middle of writting the metadata, - # just remove all files from destdir of pkg. - - for subpkg in ${subpackages}; do - if [ -d "$XBPS_DESTDIR/${subpkg}-${version%_*}" ]; then - rm -rf "$XBPS_DESTDIR/${subpkg}-${version%_*}" - fi - if [ -f ${wrksrc}/.xbps_do_install_${subpkg}_done ]; then - rm -f ${wrksrc}/.xbps_do_install_${subpkg}_done - fi - done - - if [ -d "$XBPS_DESTDIR/${sourcepkg}-${version%_*}" ]; then - rm -rf "$XBPS_DESTDIR/${sourcepkg}-${version%_*}" - msg_red "$pkgver: removed files from DESTDIR...\n" - fi - - autoremove_pkg_dependencies ${_kwrksrc} -} - -run_func() -{ - local rval logpipe logfile - - [ -z "$1" ] && return 1 - - if type ${1} >/dev/null 2>&1; then - logpipe=/tmp/xbps_src_logpipe.$$ - if [ -d "${wrksrc}" ]; then - logfile=${wrksrc}/.xbps_${1}.log - else - logfile=$(mktemp -t xbps_${1}_${pkgname}.log.XXXXXXXX) - fi - mkfifo "$logpipe" - exec 3>&1 - tee "$logfile" < "$logpipe" & - exec 1>"$logpipe" 2>"$logpipe" - set -e - trap "run_func_error $1 && return $?" INT - msg_normal "$pkgver: running $1 phase...\n" - $1 2>&1 - rval=$? - set +e - trap - INT - exec 1>&3 2>&3 3>&- - rm -f "$logpipe" - if [ $rval -ne 0 ]; then - msg_error "$pkgver: $1 failed!\n" - else - msg_normal "$pkgver: $1 phase done.\n" - return 0 - fi - fi - return 255 # function not found. -} - -msg_red() -{ - # error messages in bold/red - printf >&2 "\033[1m\033[31m" - if [ -n "$IN_CHROOT" ]; then - printf >&2 "[chroot] => ERROR: $@" - else - printf >&2 "=> ERROR: $@" - fi - printf >&2 "\033[m" -} - -msg_error() -{ - msg_red "$@" - - exit 1 -} - -msg_error_nochroot() -{ - printf >&2 "\033[1m\033[31m>= ERROR: $@\033[m" - - exit 1 -} - -msg_warn() -{ - # warn messages in bold/yellow - printf >&2 "\033[1m\033[33m" - if [ -n "$IN_CHROOT" ]; then - printf >&2 "[chroot] => WARNING: $@" - else - printf >&2 "=> WARNING: $@" - fi - printf >&2 "\033[m" -} - -msg_warn_nochroot() -{ - printf >&2 "\033[1m\033[33m=> WARNING: $@\033[m" -} - -msg_normal() -{ - # normal messages in bold - printf "\033[1m" - if [ -n "$IN_CHROOT" ]; then - printf "[chroot] => $@" - else - printf "=> $@" - fi - printf "\033[m" -} - -msg_normal_append() -{ - printf "\033[1m$@\033[m" -} diff --git a/xbps-src/shutils/configure_funcs.sh b/xbps-src/shutils/configure_funcs.sh deleted file mode 100644 index fb4e26cd2f367d..00000000000000 --- a/xbps-src/shutils/configure_funcs.sh +++ /dev/null @@ -1,72 +0,0 @@ -#- -# Copyright (c) 2008-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -# -# Runs the "configure" phase for a pkg. This setups the Makefiles or any -# other stuff required to be able to build binaries or such. -# -export CONFIGURE_SHARED_ARGS="--prefix=/usr --sysconfdir=/etc \ - --infodir=/usr/share/info --mandir=/usr/share/man \ - --localstatedir=/var" - -configure_src_phase() -{ - local f rval - - [ -z $pkgname ] && return 1 - - # Skip this phase for meta-template style builds. - [ -n "$build_style" -a "$build_style" = "meta-template" ] && return 0 - - cd $wrksrc || msg_error "unexistent build directory [$wrksrc].\n" - - # Run pre_configure func. - if [ ! -f $XBPS_PRECONFIGURE_DONE ]; then - run_func pre_configure - [ $? -eq 0 ] && touch -f $XBPS_PRECONFIGURE_DONE - fi - - cd $wrksrc || return 1 - if [ -n "$build_wrksrc" ]; then - cd $build_wrksrc || return 1 - fi - - if [ -r $XBPS_HELPERSDIR/${build_style}.sh ]; then - . $XBPS_HELPERSDIR/${build_style}.sh - fi - # run do_configure() - run_func do_configure - rval=$? - - # Run post_configure func. - if [ ! -f $XBPS_POSTCONFIGURE_DONE ]; then - run_func post_configure - [ $? -eq 0 ] && touch -f $XBPS_POSTCONFIGURE_DONE - fi - - [ "$rval" -eq 0 ] && touch -f $XBPS_CONFIGURE_DONE - - return 0 -} diff --git a/xbps-src/shutils/extract_funcs.sh b/xbps-src/shutils/extract_funcs.sh deleted file mode 100644 index 42910cd2994341..00000000000000 --- a/xbps-src/shutils/extract_funcs.sh +++ /dev/null @@ -1,159 +0,0 @@ -#- -# Copyright (c) 2008-2010 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -# -# Extracts contents of distfiles specified in a template into -# the $wrksrc directory. -# -extract_distfiles() -{ - local pkg="$1" curfile cursufx f - - [ -f $XBPS_EXTRACT_DONE ] && return 0 - [ -z "$IN_CHROOT" -a ! -w $XBPS_BUILDDIR ] && \ - msg_error "can't extract distfile(s) (permission denied)\n" - - # - # If we are being called via the target, just extract and return. - # - [ -n "$pkg" -a -z "$pkgname" ] && return 1 - - # - # If noextract is set, do a "fake extraction". - # - if [ -z "$distfiles" -o -n "$noextract" ]; then - [ ! -d "$wrksrc" ] && mkdir -p $wrksrc - run_func do_extract - touch -f $XBPS_EXTRACT_DONE - return 0 - fi - - # Check that distfiles are there before anything else. - for f in ${distfiles}; do - curfile=$(basename $f) - if [ ! -f ${XBPS_SRCDISTDIR}/${curfile} ]; then - msg_error "cannot find ${curfile}, use 'xbps-src fetch' first.\n" - fi - done - - if [ -n "$create_wrksrc" ]; then - mkdir -p ${wrksrc} || return 1 - fi - - msg_normal "$pkgver: extracting distfile(s), please wait...\n" - - for f in ${distfiles}; do - curfile=$(basename $f) - - if $(echo $f|grep -q '.tar.lzma'); then - cursufx="txz" - elif $(echo $f|grep -q '.tar.xz'); then - cursufx="txz" - elif $(echo $f|grep -q '.txz'); then - cursufx="txz" - elif $(echo $f|grep -q '.tar.bz2'); then - cursufx="tbz" - elif $(echo $f|grep -q '.tbz'); then - cursufx="tbz" - elif $(echo $f|grep -q '.tar.gz'); then - cursufx="tgz" - elif $(echo $f|grep -q '.tgz'); then - cursufx="tgz" - elif $(echo $f|grep -q '.gz'); then - cursufx="gz" - elif $(echo $f|grep -q '.bz2'); then - cursufx="bz2" - elif $(echo $f|grep -q '.tar'); then - cursufx="tar" - elif $(echo $f|grep -q '.zip'); then - cursufx="zip" - else - msg_error "unknown distfile suffix for $curfile.\n" - fi - - if [ -n "$create_wrksrc" ]; then - extractdir="$wrksrc" - else - extractdir="$XBPS_BUILDDIR" - fi - - case ${cursufx} in - txz) - if ! command -v unxz 2>&1 >/dev/null; then - msg_error "cannot find xz for extraction.\n" - fi - unxz -cf $XBPS_SRCDISTDIR/$curfile | tar xf - -C $extractdir - if [ $? -ne 0 ]; then - msg_error "extracting $curfile into $XBPS_BUILDDIR.\n" - fi - ;; - tbz) - bunzip2 -cf $XBPS_SRCDISTDIR/$curfile | tar xf - -C $extractdir - if [ $? -ne 0 ]; then - msg_error "extracting $curfile into $XBPS_BUILDDIR.\n" - fi - ;; - tgz) - gunzip -cf $XBPS_SRCDISTDIR/$curfile | tar xf - -C $extractdir - if [ $? -ne 0 ]; then - msg_error "extracting $curfile into $XBPS_BUILDDIR.\n" - fi - ;; - gz|bz2) - cp -f $XBPS_SRCDISTDIR/$curfile $extractdir - if [ "$cursufx" = ".gz" ]; then - cd $XBPS_BUILDDIR && gunzip $curfile - else - cd $XBPS_BUILDDIR && bunzip2 $curfile - fi - ;; - tar) - tar xf $XBPS_SRCDISTDIR/$curfile -C $extractdir - if [ $? -ne 0 ]; then - msg_error "extracting $curfile into $XBPS_BUILDDIR.\n" - fi - ;; - zip) - if command -v unzip 2>&1 >/dev/null; then - unzip -q $XBPS_SRCDISTDIR/$curfile -d $extractdir - if [ $? -ne 0 ]; then - msg_error "extracting $curfile into $XBPS_BUILDDIR.\n" - fi - else - msg_error "cannot find unzip bin for extraction.\n" - fi - ;; - *) - msg_error "cannot guess $curfile extract suffix. ($cursufx)\n" - ;; - esac - done - - touch -f $XBPS_FETCH_DONE - touch -f $XBPS_EXTRACT_DONE - - run_func post_extract - return 0 -} diff --git a/xbps-src/shutils/fetch_funcs.sh b/xbps-src/shutils/fetch_funcs.sh deleted file mode 100644 index d9daac38dba52a..00000000000000 --- a/xbps-src/shutils/fetch_funcs.sh +++ /dev/null @@ -1,147 +0,0 @@ -#- -# Copyright (c) 2008-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -# -# Verifies that file's checksum downloaded matches what it's specified -# in template file. -# -verify_sha256_cksum() -{ - local file="$1" - local origsum="$2" - - [ -z "$file" -o -z "$cksum" ] && return 1 - - msg_normal "$pkgver: verifying checksum for distfile '$file'... " - filesum=$(${XBPS_DIGEST_CMD} $XBPS_SRCDISTDIR/$file) - if [ "$origsum" != "$filesum" ]; then - echo - msg_error "SHA256 mismatch for '$file:'\n$filesum\n" - fi - msg_normal_append "OK.\n" -} - -# -# Downloads the distfiles and verifies checksum for all them. -# -fetch_distfiles() -{ - local pkg="$1" upcksum="$2" dfiles localurl dfcount=0 ckcount=0 f - - [ -z $pkgname ] && return 1 - - # - # There's nothing of interest if we are a meta template. - # - [ -n "$build_style" -a "$build_style" = "meta-template" ] && return 0 - - [ -f "$XBPS_FETCH_DONE" ] && return 0 - - # - # If nofetch is set in a build template, skip this phase - # entirely and run the do_fetch() function. - # - if [ -n "$nofetch" ]; then - cd ${XBPS_BUILDDIR} - [ -n "$build_wrksrc" ] && mkdir -p "$wrksrc" - run_func do_fetch - touch -f $XBPS_FETCH_DONE - return 0 - fi - - cd $XBPS_SRCDISTDIR || return 1 - for f in ${distfiles}; do - curfile=$(basename $f) - if [ -f "$XBPS_SRCDISTDIR/$curfile" ]; then - for i in ${checksum}; do - if [ $dfcount -eq $ckcount -a -n $i ]; then - cksum=$i - found=yes - break - fi - - ckcount=$(($ckcount + 1)) - done - - if [ -z $found ]; then - msg_error "cannot find checksum for $curfile.\n" - fi - - verify_sha256_cksum $curfile $cksum - if [ $? -eq 0 ]; then - unset cksum found - ckcount=0 - dfcount=$(($dfcount + 1)) - continue - fi - fi - - msg_normal "$pkgver: fetching distfile '$curfile'...\n" - - if [ -n "$distfiles" ]; then - localurl="$f" - else - localurl="$url/$curfile" - fi - - $XBPS_FETCH_CMD $localurl - if [ $? -ne 0 ]; then - unset localurl - if [ ! -f $XBPS_SRCDISTDIR/$curfile ]; then - msg_error "couldn't fetch $curfile.\n" - else - msg_error "there was an error fetching $curfile.\n" - fi - else - unset localurl - # - # XXX duplicate code. - # - for i in ${checksum}; do - if [ $dfcount -eq $ckcount -a -n $i ]; then - cksum=$i - found=yes - break - fi - - ckcount=$(($ckcount + 1)) - done - - if [ -z $found ]; then - msg_error "cannot find checksum for $curfile.\n" - fi - - verify_sha256_cksum $curfile $cksum - if [ $? -eq 0 ]; then - unset cksum found - ckcount=0 - fi - fi - - dfcount=$(($dfcount + 1)) - done - - unset cksum found -} diff --git a/xbps-src/shutils/init_funcs.sh b/xbps-src/shutils/init_funcs.sh deleted file mode 100644 index 5d14960c0aea57..00000000000000 --- a/xbps-src/shutils/init_funcs.sh +++ /dev/null @@ -1,89 +0,0 @@ -#- -# Copyright (c) 2008-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -set_defvars() -{ - local DDIRS i - - XBPS_HELPERSDIR=${XBPS_SHAREDIR}/helpers - XBPS_SHUTILSDIR=${XBPS_SHAREDIR}/shutils - XBPS_META_PATH=$XBPS_MASTERDIR/var/db/xbps - XBPS_PKGMETADIR=$XBPS_META_PATH/metadata - XBPS_SRCPKGDIR=$XBPS_DISTRIBUTIONDIR/srcpkgs - XBPS_COMMONDIR=${XBPS_DISTRIBUTIONDIR}/common - - if [ -n "$IN_CHROOT" ]; then - XBPS_DESTDIR=/destdir - XBPS_BUILDDIR=/builddir - else - XBPS_DESTDIR=$XBPS_MASTERDIR/destdir - XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir - fi - if [ -n "$XBPS_HOSTDIR" ]; then - XBPS_PACKAGESDIR=$XBPS_HOSTDIR/binpkgs - XBPS_SRCDISTDIR=$XBPS_HOSTDIR/sources - else - XBPS_SRCDISTDIR=$XBPS_MASTERDIR/host/sources - XBPS_PACKAGESDIR=$XBPS_MASTERDIR/host/binpkgs - fi - XBPS_TRIGGERSDIR=$XBPS_SRCPKGDIR/xbps-triggers/files - - DDIRS="DISTRIBUTIONDIR TRIGGERSDIR HELPERSDIR SRCPKGDIR SHUTILSDIR COMMONDIR" - for i in ${DDIRS}; do - eval val="\$XBPS_$i" - if [ ! -d "$val" ]; then - echo "ERROR: cannot find $i at $val aborting." - exit 1 - fi - done - - for i in DESTDIR PACKAGESDIR BUILDDIR SRCDISTDIR; do - eval val="\$XBPS_$i" - if [ ! -d "$val" ]; then - mdir=$(dirname $XBPS_MASTERDIR) - [ -z "$IN_CHROOT" -a "$mdir" = "/" ] && continue - mkdir -p $val - fi - done - - export XBPS_VERSION=$(xbps-bin.static -V|awk '{print $2}') - case "${XBPS_VERSION}" in - 0.1[0-9].[0-9]*) - xbps_conf="-C $XBPS_MASTERDIR/usr/local/etc/xbps" - ;; - 0.[89].[0-9]*) - # XBPS < 0.10.0 - xbps_conf="-C $XBPS_MASTERDIR/usr/local/etc/xbps-conf.plist" - ;; - esac - xbps_conf="$xbps_conf -c $XBPS_MASTERDIR/host/repocache" - - export XBPS_PKGDB_CMD="xbps-uhelper.static -r $XBPS_MASTERDIR" - export XBPS_BIN_CMD="xbps-bin.static $xbps_conf -r $XBPS_MASTERDIR" - export XBPS_REPO_CMD="xbps-repo.static $xbps_conf -r $XBPS_MASTERDIR" - export XBPS_DIGEST_CMD="xbps-uhelper.static digest" - export XBPS_CMPVER_CMD="xbps-uhelper.static cmpver" - export XBPS_FETCH_CMD="xbps-uhelper.static fetch" -} diff --git a/xbps-src/shutils/install_files.sh b/xbps-src/shutils/install_files.sh deleted file mode 100644 index a187c575db3d15..00000000000000 --- a/xbps-src/shutils/install_files.sh +++ /dev/null @@ -1,117 +0,0 @@ -#- -# Copyright (c) 2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -vinstall() -{ - local file="$1" - local mode="$2" - local targetdir="$3" - local targetfile="$4" - - if [ -z "$DESTDIR" ]; then - msg_red "vinstall: DESTDIR unset, can't continue...\n" - return 1 - fi - - if [ $# -lt 3 ]; then - msg_red "vinstall: 3 arguments expected: \n" - return 1 - fi - - if [ ! -r "$file" ]; then - msg_red "vinstall: cannot find '$file'...\n" - return 1 - fi - - if [ -z "$targetfile" ]; then - install -Dm${mode} ${file} "${DESTDIR}/${targetdir}/$(basename ${file})" - else - install -Dm${mode} ${file} "${DESTDIR}/${targetdir}/$(basename ${targetfile})" - fi -} - -vcopy() -{ - local files=$1 - local targetdir="$2" - - if [ -z "$DESTDIR" ]; then - msg_red "vcopy: DESTDIR unset, can't continue...\n" - return 1 - fi - if [ $# -ne 2 ]; then - msg_red "vcopy: 2 arguments expected: \n" - return 1 - fi - - cp -a $files ${DESTDIR}/${targetdir} -} - -vmove() -{ - local files=$1 - local targetdir="$2" - - if [ -z "$DESTDIR" ]; then - msg_red "vmove: DESTDIR unset, can't continue...\n" - return 1 - elif [ -z "$SRCPKGDESTDIR" ]; then - msg_red "vmove: SRCPKGDESTDIR unset, can't continue...\n" - return 1 - fi - if [ $# -lt 1 ]; then - msg_red "vmove: 1 argument expected: \n" - return 1 - fi - if [ -z "${targetdir}" ]; then - [ ! -d ${DESTDIR} ] && install -d ${DESTDIR} - mv ${SRCPKGDESTDIR}/$files ${DESTDIR} - else - [ ! -d ${DESTDIR}/${targetdir} ] && vmkdir ${targetdir} - mv ${SRCPKGDESTDIR}/$files ${DESTDIR}/${targetdir} - fi -} - -vmkdir() -{ - local dir="$1" - local mode="$2" - - if [ -z "$DESTDIR" ]; then - msg_red "vmkdir: DESTDIR unset, can't continue...\n" - return 1 - fi - - if [ -z "$dir" ]; then - msg_red "vmkdir: directory argument unset.\n" - return 1 - fi - - if [ -z "$mode" ]; then - install -d ${DESTDIR}/${dir} - else - install -dm${mode} ${DESTDIR}/${dir} - fi -} diff --git a/xbps-src/shutils/make-binpkg.sh b/xbps-src/shutils/make-binpkg.sh deleted file mode 100644 index d8eb883398049a..00000000000000 --- a/xbps-src/shutils/make-binpkg.sh +++ /dev/null @@ -1,129 +0,0 @@ -#- -# Copyright (c) 2008-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -xbps_make_binpkg() -{ - local subpkg - - [ -z "$pkgname" ] && return 1 - - for subpkg in ${subpackages}; do - unset revision noarch nonfree - . $XBPS_SRCPKGDIR/$pkgname/$subpkg.template - pkgname=${subpkg} - set_tmpl_common_vars - xbps_make_binpkg_real - setup_tmpl ${sourcepkg} - done - - [ -n "${subpackages}" ] && set_tmpl_common_vars - xbps_make_binpkg_real - return $? -} - -binpkg_cleanup() -{ - local pkgdir="$1" binpkg="$2" - - [ -z "$pkgdir" -o -z "$binpkg" ] && return 1 - msg_red "Interrupted! removing $binpkg file!\n" - rm -f $pkgdir/$binpkg - exit 1 -} - -# -# This function builds a binary package from an installed xbps -# package in destdir. -# -xbps_make_binpkg_real() -{ - local mfiles binpkg pkgdir arch dirs _dirs d clevel - - if [ ! -d "${DESTDIR}" ]; then - msg_warn "cannot find destdir for $pkgname... skipping!\n" - return 0 - fi - cd ${DESTDIR} - - if [ -n "$noarch" ]; then - arch=noarch - else - arch=$XBPS_MACHINE - fi - binpkg=$pkgver.$arch.xbps - if [ -n "$nonfree" ]; then - pkgdir=$XBPS_PACKAGESDIR/nonfree/$arch - else - pkgdir=$XBPS_PACKAGESDIR/$arch - fi - # - # Don't overwrite existing binpkgs by default, skip them. - # - if [ -f $pkgdir/$binpkg ]; then - msg_normal "Skipping existing $binpkg pkg...\n" - return 6 # EEXIST - fi - - # - # Make sure that INSTALL is the first file on the archive, - # this is to ensure that it's run before any other file is - # unpacked. - # - if [ -x ./INSTALL -a -x ./REMOVE ]; then - mfiles="./INSTALL ./REMOVE" - elif [ -x ./INSTALL ]; then - mfiles="./INSTALL" - elif [ -x ./REMOVE ]; then - mfiles="./REMOVE" - fi - mfiles="$mfiles ./files.plist ./props.plist" - _dirs=$(find . -maxdepth 1 -type d -o -type l) - for d in ${_dirs}; do - [ "$d" = "." ] && continue - dirs="$d $dirs" - done - - [ -n "$XBPS_COMPRESS_LEVEL" ] && clevel="-$XBPS_COMPRESS_LEVEL" - [ ! -d $pkgdir ] && mkdir -p $pkgdir - - # Remove binpkg if interrupted... - trap "binpkg_cleanup $pkgdir $binpkg" INT - msg_normal "Building $binpkg... " - ${FAKEROOT_CMD} ${FAKEROOT_CMD_ARGS} \ - tar --exclude "var/db/xbps/metadata/*/flist" \ - -cpf - ${mfiles} ${dirs} | \ - $XBPS_COMPRESS_CMD ${clevel} -qf > $pkgdir/$binpkg - rval=$? - trap - INT - - if [ $rval -eq 0 ]; then - msg_normal_append "done.\n" - else - rm -f $pkgdir/$binpkg - msg_normal_append "failed!\n" - fi - - return $rval -} diff --git a/xbps-src/shutils/metadata.sh b/xbps-src/shutils/metadata.sh deleted file mode 100644 index 8508a3f9f5b6ef..00000000000000 --- a/xbps-src/shutils/metadata.sh +++ /dev/null @@ -1,454 +0,0 @@ -#- -# Copyright (c) 2008-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -xbps_write_metadata_pkg() -{ - local subpkg spkgrev - - for subpkg in ${subpackages}; do - if [ -n "${revision}" ]; then - spkgrev="${subpkg}-${version}_${revision}" - else - spkgrev="${subpkg}-${version}" - fi - check_installed_pkg ${spkgrev} - if [ $? -eq 0 -a -z "$DESTDIR_ONLY_INSTALL" ]; then - continue - fi - - if [ ! -f $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template ]; then - msg_error "Cannot find subpkg '${subpkg}' build template!\n" - fi - setup_tmpl ${sourcepkg} - unset run_depends conf_files noarch triggers replaces \ - revision system_accounts system_groups \ - preserve xml_entries sgml_entries \ - xml_catalogs sgml_catalogs gconf_entries gconf_schemas \ - gtk_iconcache_dirs font_dirs dkms_modules provides \ - kernel_hooks_version conflicts pycompile_dirs \ - pycompile_module systemd_services make_dirs - . $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template - pkgname=${subpkg} - set_tmpl_common_vars - verify_rundeps ${DESTDIR} - xbps_write_metadata_pkg_real - done - - if [ -n "$build_style" -a "$build_style" = "meta-template" -a -z "${run_depends}" ]; then - for spkg in ${subpackages}; do - if [ -n "${revision}" ]; then - spkgrev="${spkg}-${version}_$revision" - else - spkgrev="${spkg}-${version}" - fi - run_depends="${run_depends} ${spkgrev}" - done - fi - setup_tmpl ${sourcepkg} - # Verify pkg deps. - verify_rundeps ${DESTDIR} - xbps_write_metadata_pkg_real -} - -# -# This function writes the metadata files into package's destdir, -# these will be used for binary packages. -# -xbps_write_metadata_pkg_real() -{ - local metadir=${DESTDIR}/var/db/xbps/metadata/$pkgname - local f i j found arch dirat lnkat newlnk lver TMPFLIST TMPFPLIST - local fpattern="s|${DESTDIR}||g;s|^\./$||g;/^$/d" - - if [ ! -d "${DESTDIR}" ]; then - msg_error "$pkgname not installed into destdir.\n" - fi - - if [ -n "$noarch" ]; then - arch=noarch - else - arch=$XBPS_MACHINE - fi - - if [ -n "$revision" ]; then - lver="${version}_${revision}" - else - lver="${version}" - fi - - # - # If package provides virtual packages, create dynamically the - # required virtualpkg.d files. - # - if [ -n "$provides" -a -n "$replaces" ]; then - _tmpf=$(mktemp) || msg_error "$pkgver: failed to create tempfile.\n" - cat > ${_tmpf} <<_EOF - - - - - virtual-pkgver - $provides - target-pkgpattern - $(echo $replaces|sed "s|<|\<|g;s|>|\>|g") - - -_EOF - install -Dm644 ${_tmpf} \ - ${DESTDIR}/etc/xbps/virtualpkg.d/${pkgname}.plist - vmkdir etc/xbps/virtualpkg.d.wants && curcwd=$(pwd) && \ - cd ${DESTDIR}/etc/xbps/virtualpkg.d.wants && \ - ln -sf ../virtualpkg.d/${pkgname}.plist . && \ - cd ${curcwd} && rm -f ${_tmpf} || \ - msg_error "$pkgver: failed to create virtualpkg.d file in DESTDIR!\n" - fi - - # - # Find out if this package contains info files and compress - # all them with gzip. - # - if [ -f ${DESTDIR}/usr/share/info/dir ]; then - # Always remove this file if curpkg is not texinfo. - if [ "$pkgname" != "texinfo" ]; then - [ -f ${DESTDIR}/usr/share/info/dir ] && \ - rm -f ${DESTDIR}/usr/share/info/dir - fi - # Add info-files trigger. - triggers="info-files $triggers" - msg_normal "$pkgver: processing info(1) files...\n" - - find ${DESTDIR}/usr/share/info -type f -follow | while read f - do - j=$(echo "$f"|sed -e "$fpattern") - [ "$j" = "" ] && continue - [ "$j" = "/usr/share/info/dir" ] && continue - # Ignore compressed files. - if $(echo "$j"|grep -q '.*.gz$'); then - continue - fi - # Ignore non info files. - if ! $(echo "$j"|grep -q '.*.info$') && \ - ! $(echo "$j"|grep -q '.*.info-[0-9]*$'); then - continue - fi - if [ -h ${DESTDIR}/"$j" ]; then - dirat=$(dirname "$j") - lnkat=$(readlink ${DESTDIR}/"$j") - newlnk=$(basename "$j") - rm -f ${DESTDIR}/"$j" - cd ${DESTDIR}/"$dirat" - ln -s "${lnkat}".gz "${newlnk}".gz - continue - fi - echo " Compressing info file: $j..." - gzip -q9 ${DESTDIR}/"$j" - done - fi - - # - # Find out if this package contains manual pages and - # compress all them with gzip. - # - if [ -d "${DESTDIR}/usr/share/man" ]; then - msg_normal "$pkgver: processing manual pages...\n" - find ${DESTDIR}/usr/share/man -type f -follow | while read f - do - j=$(echo "$f"|sed -e "$fpattern") - [ "$j" = "" ] && continue - if $(echo "$j"|grep -q '.*.gz$'); then - continue - fi - if [ -h ${DESTDIR}/"$j" ]; then - dirat=$(dirname "$j") - lnkat=$(readlink ${DESTDIR}/"$j") - newlnk=$(basename "$j") - rm -f ${DESTDIR}/"$j" - cd ${DESTDIR}/"$dirat" - ln -s "${lnkat}".gz "${newlnk}".gz - continue - fi - echo " Compressing manpage: $j..." - gzip -q9 ${DESTDIR}/"$j" - done - fi - - # Write the files.plist file. - TMPFLIST=$(mktemp -t flist.XXXXXXXXXX) || exit 1 - TMPFPLIST=$(mktemp -t fplist.XXXXXXXXXX) || exit 1 - - msg_normal "$pkgver: creating package metadata...\n" - - cat > "$TMPFPLIST" <<_EOF - - - - -_EOF - # Pass 1: add links. - echo "links" >> $TMPFPLIST - echo "" >> $TMPFPLIST - find ${DESTDIR} -type l | while read f - do - j=$(echo "$f"|sed -e "$fpattern") - [ "$j" = "" ] && continue - echo "$j" >> $TMPFLIST - echo "" >> $TMPFPLIST - echo "file" >> $TMPFPLIST - echo "$j" >> $TMPFPLIST - echo "target" >> $TMPFPLIST - lnk=$(readlink -f "$f"|sed -e "s|${DESTDIR}||") - if [ -z "$lnk" -o "$lnk" = "" ]; then - lnk=$(readlink "$f"|sed -e "s|${DESTDIR}||") - fi - echo "$lnk" >> $TMPFPLIST - echo "" >> $TMPFPLIST - done - echo "" >> $TMPFPLIST - - # Pass 2: add regular files. - echo "files" >> $TMPFPLIST - echo "" >> $TMPFPLIST - find ${DESTDIR} -type f | while read f - do - j=$(echo "$f"|sed -e "$fpattern") - [ "$j" = "" ] && continue - echo "$j" >> $TMPFLIST - # Skip configuration files. - for i in ${conf_files}; do - [ "$j" = "$i" ] && found=1 && break - done - [ -n "$found" ] && unset found && continue - echo "" >> $TMPFPLIST - echo "file" >> $TMPFPLIST - echo "$j" >> $TMPFPLIST - echo "sha256" >> $TMPFPLIST - echo "$(${XBPS_DIGEST_CMD} "$f")" \ - >> $TMPFPLIST - echo "" >> $TMPFPLIST - done - echo "" >> $TMPFPLIST - - # Pass 3: add directories. - echo "dirs" >> $TMPFPLIST - echo "" >> $TMPFPLIST - find ${DESTDIR} -type d|sort -ur | while read f - do - j=$(echo "$f"|sed -e "$fpattern") - [ "$j" = "" ] && continue - echo "$j" >> $TMPFLIST - echo "" >> $TMPFPLIST - echo "file" >> $TMPFPLIST - echo "$j" >> $TMPFPLIST - echo "" >> $TMPFPLIST - done - echo "" >> $TMPFPLIST - - # Add configuration files into its own array. - if [ -n "${conf_files}" ]; then - echo "conf_files" >> $TMPFPLIST - echo "" >> $TMPFPLIST - for f in ${conf_files}; do - i=${DESTDIR}/"${f}" - [ ! -f "${i}" ] && continue - echo "" >> $TMPFPLIST - echo "file" >> $TMPFPLIST - echo "$f" >> $TMPFPLIST - echo "sha256" >> $TMPFPLIST - echo "$(${XBPS_DIGEST_CMD} "${i}")" \ - >> $TMPFPLIST - echo "" >> $TMPFPLIST - done - echo "" >> $TMPFPLIST - fi - - echo "" >> $TMPFPLIST - echo "" >> $TMPFPLIST - sed -i -e /^$/d $TMPFLIST - - # Write the props.plist file. - local TMPFPROPS=$(mktemp -t fprops.XXXXXXXXXX) || exit 1 - - local instsize=$(du -sk ${DESTDIR}|awk '{print $1}') - - cat > $TMPFPROPS <<_EOF - - - - -pkgname -$pkgname -version -$lver -pkgver -$pkgver -architecture -$arch -installed_size -$(($instsize * 1024)) -maintainer -$(echo $maintainer|sed -e 's|<|\<|g;s|>|\>|g') -short_desc -$short_desc -long_desc -$long_desc -packaged-with -xbps-src $XBPS_SRC_BUILD_VERSION -_EOF - # - # If package sets $dkms_modules, add dkms rundep. - # - if [ -n "$dkms_modules" ]; then - Add_dependency run dkms - fi - - # - # If package sets $system_accounts or $system_groups, add shadow rundep. - # - if [ -n "$system_accounts" -o -n "$system_groups" ]; then - Add_dependency run shadow - fi - - # pkg needs to preserve its files after removal/upgrade? - if [ -n "$preserve" ]; then - echo "preserve" >> $TMPFPROPS - echo "" >> $TMPFPROPS - fi - - # Dependencies - if [ -n "$run_depends" ]; then - echo "run_depends" >> $TMPFPROPS - echo "" >> $TMPFPROPS - for f in ${run_depends}; do - echo "$(echo $f|sed "s|<|\<|g;s|>|\>|g")" >> $TMPFPROPS - done - echo "" >> $TMPFPROPS - fi - - # Configuration files - if [ -n "$conf_files" ]; then - echo "conf_files" >> $TMPFPROPS - echo "" >> $TMPFPROPS - for f in ${conf_files}; do - echo "$f" >> $TMPFPROPS - done - echo "" >> $TMPFPROPS - fi - - # Replace package(s). - if [ -n "$replaces" ]; then - echo "replaces" >> $TMPFPROPS - echo "" >> $TMPFPROPS - for f in ${replaces}; do - echo "$(echo $f|sed "s|<|\<|g;s|>|\>|g")" >> $TMPFPROPS - done - echo "" >> $TMPFPROPS - fi - - # Conflicting package(s). - if [ -n "$conflicts" ]; then - echo "conflicts" >> $TMPFPROPS - echo "" >> $TMPFPROPS - for f in ${conflicts}; do - echo "$(echo $f|sed "s|<|\<|g;s|>|\>|g")" >> $TMPFPROPS - done - echo "" >> $TMPFPROPS - fi - - # Provides virtual package(s). - if [ -n "$provides" ]; then - echo "provides" >> $TMPFPROPS - echo "" >> $TMPFPROPS - for f in ${provides}; do - echo "$(echo $f|sed "s|<|\<|g;s|>|\>|g")" >> $TMPFPROPS - done - echo "" >> $TMPFPROPS - fi - - # Build date. - echo "build_date" >> $TMPFPROPS - echo "$(LANG=C date -u "+%A %d %B, %Y, %T UTC")" >> $TMPFPROPS - - # Homepage - if [ -n "$homepage" ]; then - echo "homepage" >> $TMPFPROPS - echo "$homepage" >> $TMPFPROPS - fi - - # License - if [ -n "$license" ]; then - echo "license" >> $TMPFPROPS - echo "$license" >> $TMPFPROPS - fi - - # Terminate the property list file. - echo "" >> $TMPFPROPS - echo "" >> $TMPFPROPS - - if [ ! -d $metadir ]; then - mkdir -m0755 -p $metadir >/dev/null 2>&1 - if [ $? -ne 0 ]; then - msg_red "you don't have enough perms for this!\n" - rm -f $TMPFLIST $TMPFPROPS - exit 1 - fi - fi - - # Write metadata files and cleanup. - if [ -s $TMPFLIST ]; then - mv -f $TMPFLIST $metadir/flist - else - rm -f $TMPFLIST - fi - mv -f $TMPFPLIST ${DESTDIR}/files.plist - mv -f $TMPFPROPS ${DESTDIR}/props.plist - - $XBPS_PKGDB_CMD sanitize-plist ${DESTDIR}/files.plist || \ - msg_error "$pkgname: failed to externalize files.plist!\n" - $XBPS_PKGDB_CMD sanitize-plist ${DESTDIR}/props.plist || \ - msg_error "$pkgname: failed to externalize props.plist!\n" - - chmod 644 ${DESTDIR}/files.plist ${DESTDIR}/props.plist - [ -f $metadir/flist ] && chmod 644 $metadir/flist - - # - # Create the INSTALL/REMOVE scripts if package uses them - # or uses any available trigger. - # - local meta_install meta_remove - if [ -n "${sourcepkg}" -a "${sourcepkg}" != "${pkgname}" ]; then - meta_install=${XBPS_SRCPKGDIR}/${pkgname}/${pkgname}.INSTALL - meta_remove=${XBPS_SRCPKGDIR}/${pkgname}/${pkgname}.REMOVE - else - meta_install=${XBPS_SRCPKGDIR}/${pkgname}/INSTALL - meta_remove=${XBPS_SRCPKGDIR}/${pkgname}/REMOVE - fi - xbps_write_metadata_scripts_pkg install ${meta_install} || \ - msg_error "$pkgname: failed to write INSTALL metadata file!\n" - - xbps_write_metadata_scripts_pkg remove ${meta_remove} || \ - msg_error "$pkgname: failed to write REMOVE metadata file!\n" - - msg_normal "$pkgver: successfully created package metadata.\n" -} diff --git a/xbps-src/shutils/metadata_scripts.sh b/xbps-src/shutils/metadata_scripts.sh deleted file mode 100644 index d4f5b7aa7efd09..00000000000000 --- a/xbps-src/shutils/metadata_scripts.sh +++ /dev/null @@ -1,330 +0,0 @@ -#- -# Copyright (c) 2009-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -_add_trigger() -{ - local f found name="$1" - - for f in ${triggers}; do - [ "$f" = "$name" ] && found=1 - done - [ -z "$found" ] && triggers="$triggers $name" -} - -xbps_write_metadata_scripts_pkg() -{ - local action="$1" - local action_file="$2" - local tmpf=$(mktemp -t xbps-install.XXXXXXXXXX) || exit 1 - local fpattern="s|${DESTDIR}||g;s|^\./$||g;/^$/d" - local targets f info_files home shell descr groups - local found triggers_found - - case "$action" in - install) ;; - remove) ;; - *) return 1;; - esac - - cd ${DESTDIR} - cat >> $tmpf <<_EOF -#!/bin/sh -e -# -# Generic INSTALL/REMOVE script. Arguments passed to this script: -# -# \$1 = ACTION [pre/post] -# \$2 = PKGNAME -# \$3 = VERSION -# \$4 = UPDATE [yes/no] -# -# Note that paths must be relative to CWD, to avoid calling -# host commands if /bin/sh (dash) is not installed and it's -# not possible to chroot(3). -# - -export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" - -TRIGGERSDIR="./var/db/xbps/triggers" -ACTION="\$1" -PKGNAME="\$2" -VERSION="\$3" -UPDATE="\$4" - -# -# The following code will run the triggers. -# -_EOF - # - # Handle kernel hooks. - # - if [ -n "${kernel_hooks_version}" ]; then - _add_trigger kernel-hooks - echo "export kernel_hooks_version=\"${kernel_hooks_version}\"" >> $tmpf - fi - # - # Handle DKMS modules. - # - if [ -n "${dkms_modules}" ]; then - _add_trigger dkms - echo "export dkms_modules=\"${dkms_modules}\"" >> $tmpf - fi - # - # Handle system groups. - # - if [ -n "${system_groups}" ]; then - _add_trigger system-accounts - echo "export system_groups=\"${system_groups}\"" >> $tmpf - fi - # - # Handle system accounts. - # - if [ -n "${system_accounts}" ]; then - _add_trigger system-accounts - echo "export system_accounts=\"${system_accounts}\"" >> $tmpf - for f in ${system_accounts}; do - eval homedir="\$${f}_homedir" - eval shell="\$${f}_shell" - eval descr="\$${f}_descr" - eval groups="\$${f}_groups" - if [ -n "$homedir" ]; then - echo "export ${f}_homedir=\"$homedir\"" >> $tmpf - fi - if [ -n "$shell" ]; then - echo "export ${f}_shell=\"$shell\"" >> $tmpf - fi - if [ -n "$descr" ]; then - echo "export ${f}_descr=\"$descr\"" >> $tmpf - fi - if [ -n "$groups" ]; then - echo "export ${f}_groups=\"${groups}\"" >> $tmpf - fi - unset homedir shell descr groups - done - fi - # - # Handle mkdirs trigger. - # - if [ -n "${make_dirs}" ]; then - _add_trigger mkdirs - echo "export make_dirs=\"${make_dirs}\"" >> $tmpf - fi - # - # Handle systemd services. - # - if [ -n "${systemd_services}" ]; then - _add_trigger systemd-service - echo "export systemd_services=\"${systemd_services}\"" >> $tmpf - fi - # - # Handle GNU Info files. - # - if [ -d "${DESTDIR}/usr/share/info" ]; then - unset info_files - for f in $(find ${DESTDIR}/usr/share/info -type f); do - j=$(echo $f|sed -e "$fpattern") - [ "$j" = "" ] && continue - [ "$j" = "/usr/share/info/dir" ] && continue - if [ -z "$info_files" ]; then - info_files="$j" - else - info_files="$info_files $j" - fi - done - if [ -n "${info_files}" ]; then - _add_trigger info-files - echo "export info_files=\"${info_files}\"" >> $tmpf - fi - fi - # - # (Un)Register a shell in /etc/shells. - # - if [ -n "${register_shell}" ]; then - _add_trigger register-shell - echo "export register_shell=\"${register_shell}\"" >> $tmpf - fi - # - # Handle SGML/XML catalog entries via xmlcatmgr. - # - if [ -n "${sgml_catalogs}" ]; then - for catalog in ${sgml_catalogs}; do - sgml_entries="${sgml_entries} CATALOG ${catalog} --" - done - fi - if [ -n "${sgml_entries}" ]; then - echo "export sgml_entries=\"${sgml_entries}\"" >> $tmpf - fi - if [ -n "${xml_catalogs}" ]; then - for catalog in ${xml_catalogs}; do - xml_entries="${xml_entries} nextCatalog ${catalog} --" - done - fi - if [ -n "${xml_entries}" ]; then - echo "export xml_entries=\"${xml_entries}\"" >> $tmpf - fi - if [ -n "${sgml_entries}" -o -n "${xml_entries}" ]; then - _add_trigger xml-catalog - fi - # - # Handle X11 font updates via mkfontdir/mkfontscale. - # - if [ -n "${font_dirs}" ]; then - _add_trigger x11-fonts - echo "export font_dirs=\"${font_dirs}\"" >> $tmpf - fi - # - # Handle GTK+ Icon cache directories. - # - if [ -n "${gtk_iconcache_dirs}" ]; then - _add_trigger gtk-icon-cache - echo "export gtk_iconcache_dirs=\"${gtk_iconcache_dirs}\"" \ - >> $tmpf - fi - # - # Handle .desktop files in /usr/share/applications with - # desktop-file-utils. - # - if [ -d ${DESTDIR}/usr/share/applications ]; then - if find . -type f -name \*.desktop 2>&1 >/dev/null; then - _add_trigger update-desktopdb - fi - fi - # - # Handle GConf schemas/entries files with gconf-schemas. - # - if [ -n "${gconf_entries}" -o -n "${gconf_schemas}" ]; then - if find . -type f -name \*.schemas \ - -o -name \*.entries 2>&1 >/dev/null; then - _add_trigger gconf-schemas - fi - if [ -n "${gconf_entries}" ]; then - echo "export gconf_entries=\"${gconf_entries}\"" \ - >> $tmpf - fi - if [ -n "${gconf_schemas}" ]; then - echo "export gconf_schemas=\"${gconf_schemas}\"" \ - >> $tmpf - fi - fi - # - # Handle gio-modules trigger. - # - if [ -d ${DESTDIR}/usr/lib/gio/modules ]; then - if find ${DESTDIR}/usr/lib/gio/modules -type f -name \*.so 2>&1 >/dev/null; then - _add_trigger gio-modules - fi - fi - # - # Handle gsettings schemas in /usr/share/glib-2.0/schemas with - # gsettings-schemas. - # - if [ -d ${DESTDIR}/usr/share/glib-2.0/schemas ]; then - if find ${DESTDIR}/usr/share/glib-2.0/schemas -type f -name \*.xml 2>&1 >/dev/null; then - _add_trigger gsettings-schemas - fi - fi - # - # Handle mime database in /usr/share/mime with update-mime-database. - # - if [ -d ${DESTDIR}/usr/share/mime ]; then - if find ${DESTDIR}/usr/share/mime -type f -name \*.xml 2>&1 >/dev/null; then - _add_trigger mimedb - fi - fi - # - # Handle python bytecode archives with pycompile trigger. - # - if [ -n "${pycompile_dirs}" -o -n "${pycompile_module}" ]; then - if [ -n "${pycompile_dirs}" ]; then - echo "export pycompile_dirs=\"${pycompile_dirs}\"" >>$tmpf - fi - if [ -n "${pycompile_module}" ]; then - echo "export pycompile_module=\"${pycompile_module}\"" >>$tmpf - fi - _add_trigger pycompile - fi - - # End of trigger var exports. - echo >> $tmpf - - # - # Write the INSTALL/REMOVE package scripts. - # - if [ -n "$triggers" ]; then - triggers_found=1 - echo "case \"\${ACTION}\" in" >> $tmpf - echo "pre)" >> $tmpf - for f in ${triggers}; do - if [ ! -f $XBPS_TRIGGERSDIR/$f ]; then - rm -f $tmpf - msg_error "$pkgname: unknown trigger $f, aborting!\n" - fi - done - for f in ${triggers}; do - targets=$($XBPS_TRIGGERSDIR/$f targets) - for j in ${targets}; do - if ! $(echo $j|grep -q pre-${action}); then - continue - fi - printf "\t\${TRIGGERSDIR}/$f run $j \${PKGNAME} \${VERSION} \${UPDATE}\n" >> $tmpf - printf "\t[ \$? -ne 0 ] && exit \$?\n" >> $tmpf - done - done - printf "\t;;\n" >> $tmpf - echo "post)" >> $tmpf - for f in ${triggers}; do - targets=$($XBPS_TRIGGERSDIR/$f targets) - for j in ${targets}; do - if ! $(echo $j|grep -q post-${action}); then - continue - fi - printf "\t\${TRIGGERSDIR}/$f run $j \${PKGNAME} \${VERSION} \${UPDATE}\n" >> $tmpf - printf "\t[ \$? -ne 0 ] && exit \$?\n" >> $tmpf - done - done - printf "\t;;\n" >> $tmpf - echo "esac" >> $tmpf - echo >> $tmpf - fi - - case "$action" in - install) - if [ -f ${action_file} ]; then - found=1 - cat ${action_file} >> $tmpf - fi - echo "exit 0" >> $tmpf - mv $tmpf ${DESTDIR}/INSTALL && chmod 755 ${DESTDIR}/INSTALL - ;; - remove) - unset found - if [ -f ${action_file} ]; then - found=1 - cat ${action_file} >> $tmpf - fi - echo "exit 0" >> $tmpf - mv $tmpf ${DESTDIR}/REMOVE && chmod 755 ${DESTDIR}/REMOVE - ;; - esac -} diff --git a/xbps-src/shutils/patch_funcs.sh b/xbps-src/shutils/patch_funcs.sh deleted file mode 100644 index 9d9a413b3dd9a6..00000000000000 --- a/xbps-src/shutils/patch_funcs.sh +++ /dev/null @@ -1,93 +0,0 @@ -#- -# Copyright (c) 2008-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -# -# Applies to the build directory all patches found in PATCHESDIR -# (srcpkgs/$pkgname/patches). -# -_process_patch() -{ - local args _patch i=$1 - - args="-Np0" - _patch=$(basename $i) - if [ -f $PATCHESDIR/${_patch}.args ]; then - args=$(cat $PATCHESDIR/${_patch}.args) - elif [ -n "$patch_args" ]; then - args=$patch_args - fi - cp -f $i $wrksrc - - # Try to guess if its a compressed patch. - if $(echo $i|grep -q '.diff.gz'); then - gunzip $wrksrc/${_patch} - _patch=${_patch%%.gz} - elif $(echo $i|grep -q '.patch.gz'); then - gunzip $wrksrc/${_patch} - _patch=${_patch%%.gz} - elif $(echo $i|grep -q '.diff.bz2'); then - bunzip2 $wrksrc/${_patch} - _patch=${_patch%%.bz2} - elif $(echo $i|grep -q '.patch.bz2'); then - bunzip2 $wrksrc/${_patch} - _patch=${_patch%%.bz2} - elif $(echo $i|grep -q '.diff'); then - : - elif $(echo $i|grep -q '.patch'); then - : - else - msg_warn "$pkgver: unknown patch type: $i.\n" - continue - fi - - cd $wrksrc && patch -s ${args} < ${_patch} 2>/dev/null - if [ $? -eq 0 ]; then - msg_normal "$pkgver: Patch applied: ${_patch}.\n" - else - msg_error "'$pkgver: couldn't apply patch: ${_patch}.\n" - fi -} - -apply_tmpl_patches() -{ - local f - - [ ! -d $PATCHESDIR ] && return 0 - - if [ -r $PATCHESDIR/series ]; then - cat $PATCHESDIR/series | while read f; do - _process_patch "$PATCHESDIR/$f" - done - else - for f in $PATCHESDIR/*; do - if $(echo $f|grep -q '.args'); then - continue - fi - _process_patch $f - done - fi - - touch -f $XBPS_APPLYPATCHES_DONE -} diff --git a/xbps-src/shutils/pkgtarget_funcs.sh b/xbps-src/shutils/pkgtarget_funcs.sh deleted file mode 100644 index f8d7be2c44cbe3..00000000000000 --- a/xbps-src/shutils/pkgtarget_funcs.sh +++ /dev/null @@ -1,273 +0,0 @@ -#- -# Copyright (c) 2008-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -# -# Installs a pkg by reading its build template file. -# -make_repoidx() -{ - local f - - case "${XBPS_VERSION}" in - # >= 0.11.0 - [0-9].[1-9][1-9].[0-9]) - for f in ${XBPS_MACHINE} noarch nonfree/${XBPS_MACHINE}; do - msg_normal "Updating pkg-index for local repository at:\n" - msg_normal " $XBPS_PACKAGESDIR/$f\n" - ${XBPS_REPO_CMD} genindex ${XBPS_PACKAGESDIR}/${f} 2>/dev/null - done - ;; - *) - msg_normal "Updating pkg-index for local repository at:\n" - msg_normal " $XBPS_PACKAGESDIR\n" - ${XBPS_REPO_CMD} genindex ${XBPS_PACKAGESDIR} 2>/dev/null - ;; - esac -} - -_build_pkg_and_update_repos() -{ - local rval f - - [ -z "$BUILD_BINPKG" ] && return 0 - - # Build binary package and update local repo index if -B is set. - xbps_make_binpkg - if [ $? -ne 0 -a $? -ne 6 ]; then - return $? - fi - make_repoidx - - return 0 -} - -install_pkg() -{ - local curpkgn="$1" fullpkg pkg cdestdir - - pkg="$curpkgn-$version" - [ -n "$INSTALLING_DEPS" ] && setup_tmpl $curpkgn - # - # Refuse to install the same package that is already installed. - # - check_installed_pkg "$pkg" - if [ $? -eq 1 -o $? -eq 0 ]; then - instver="$($XBPS_PKGDB_CMD version $pkgname)" - if [ -n "$instver" -a -z "$DESTDIR_ONLY_INSTALL" ]; then - echo "=> $pkgname-$instver already installed." - return 0 - fi - fi - - # Always fetch distfiles before installing dependencies if - # template doesn't use nofetch and do_fetch(). - [ -z "$nofetch" ] && fetch_distfiles - - # - # Install dependencies required by this package. - # - if [ -z "$INSTALLING_DEPS" ]; then - install_dependencies_pkg $pkg || return $? - # - # At this point all required deps are installed, and - # only remaining is the origin package; install it. - # - unset INSTALLING_DEPS - setup_tmpl $curpkgn - msg_normal "$pkgver: starting installation...\n" - fi - - # Fetch distfiles after installing required dependencies, - # because some of them might be required for do_fetch(). - [ -n "$nofetch" ] && fetch_distfiles - - # - # Fetch, extract, build and install into the destination directory. - # - if [ ! -f "$XBPS_EXTRACT_DONE" ]; then - extract_distfiles || return $? - fi - - # Apply patches if requested by template file - if [ ! -f $XBPS_APPLYPATCHES_DONE ]; then - apply_tmpl_patches || return $? - fi - - if [ ! -f "$XBPS_CONFIGURE_DONE" ]; then - configure_src_phase || return $? - if [ "$INSTALL_TARGET" = "configure" ]; then - return 0 - fi - fi - - if [ ! -f "$XBPS_BUILD_DONE" ]; then - build_src_phase || return $? - if [ "$INSTALL_TARGET" = "build" ]; then - return 0 - fi - fi - - # Install pkg into destdir. - env XBPS_MACHINE=${XBPS_MACHINE} wrksrc=${wrksrc} \ - MASTERDIR="${XBPS_MASTERDIR}" \ - BOOTSTRAP_PKG_REBUILD=$BOOTSTRAP_PKG_REBUILD \ - CONFIG_FILE=${XBPS_CONFIG_FILE} \ - ${FAKEROOT_CMD} ${FAKEROOT_CMD_ARGS} \ - ${XBPS_LIBEXECDIR}/doinst-helper.sh \ - ${curpkgn} || return $? - - # Strip binaries/libraries. - strip_files - - # Always write metadata to package's destdir. - trap 'remove_pkgdestdir_sighandler $pkgname $KEEP_AUTODEPS' INT - xbps_write_metadata_pkg - if [ $? -ne 0 ]; then - msg_red "cannot write package metadata for '$pkgname'!\n" - trap - INT - return 1 - fi - trap - INT - - # If only installation to destdir, return. - if [ -n "$DESTDIR_ONLY_INSTALL" ]; then - if [ -d "$wrksrc" -a -z "$KEEP_WRKSRC" ]; then - remove_tmpl_wrksrc $wrksrc - fi - autoremove_pkg_dependencies $KEEP_AUTODEPS - _build_pkg_and_update_repos - return $? - fi - - # Stow package into masterdir. - stow_pkg_handler stow || return $? - - # Copy generated pkg metadata files into its metadata dir. - if [ ! -f ${DESTDIR}/files.plist ]; then - msg_error "${pkgname}: missing metadata files.plist!" - fi - cp -f ${DESTDIR}/files.plist ${XBPS_PKGMETADIR}/${pkgname} - if [ ! -f ${DESTDIR}/props.plist ]; then - msg_error "${pkgname}: missing metadata props.plist!" - fi - cp -f ${DESTDIR}/props.plist ${XBPS_PKGMETADIR}/${pkgname} - if [ -f ${DESTDIR}/INSTALL ]; then - install -m750 ${DESTDIR}/INSTALL \ - ${XBPS_PKGMETADIR}/${pkgname} - fi - if [ -f ${DESTDIR}/REMOVE ]; then - install -m750 ${DESTDIR}/REMOVE \ - ${XBPS_PKGMETADIR}/${pkgname} - fi - # - # Remove $wrksrc if -C not specified. - # - if [ -d "$wrksrc" -a -z "$KEEP_WRKSRC" ]; then - remove_tmpl_wrksrc $wrksrc - fi - - # - # Autoremove packages installed as dependencies if - # XBPS_PREFER_BINPKG_DEPS is set. - # - autoremove_pkg_dependencies $KEEP_AUTODEPS || return $? - # - # Build binary package and update local repo index if -B is set. - # - _build_pkg_and_update_repos - - return $? -} - -# -# Lists files installed by a package. -# -list_pkg_files() -{ - local pkg="$1" ver= - - [ -z $pkg ] && msg_error "unexistent package, aborting.\n" - - ver=$($XBPS_PKGDB_CMD version $pkg) - if [ -z "$ver" ]; then - msg_warn "$pkg is not installed.\n" - return 1 - fi - - cat $XBPS_PKGMETADIR/$pkg/flist -} - -# -# Removes a currently installed package (unstow + removed from destdir). -# -remove_pkg() -{ - local subpkg found pkg - - [ -z $pkgname ] && msg_error "unexistent package, aborting.\n" - - for subpkg in ${subpackages}; do - . ${XBPS_SRCPKGDIR}/${sourcepkg}/${subpkg}.template - set_tmpl_common_vars - pkg="${subpkg}-${version}" - if [ -d "$XBPS_DESTDIR/${pkg}" ]; then - msg_normal "${pkg}: removing files from destdir...\n" - rm -rf "$XBPS_DESTDIR/${pkg}" - found=1 - else - msg_warn "${pkg}: not installed in destdir!\n" - fi - # Remove leftover files in $wrksrc. - if [ -f "${wrksrc}/.xbps_do_install_${subpkg}_done" ]; then - rm -f ${wrksrc}/.xbps_do_install_${subpkg}_done - found=1 - fi - done - - pkg="${pkgname}-${version}" - if [ -d "$XBPS_DESTDIR/${pkg}" ]; then - msg_normal "${pkg}: removing files from destdir...\n" - rm -rf "$XBPS_DESTDIR/${pkg}" - found=1 - fi - - [ -f $XBPS_PRE_INSTALL_DONE ] && rm -f $XBPS_PRE_INSTALL_DONE - [ -f $XBPS_POST_INSTALL_DONE ] && rm -f $XBPS_POST_INSTALL_DONE - [ -f $XBPS_INSTALL_DONE ] && rm -f $XBPS_INSTALL_DONE - - if [ -n "$DESTDIR_ONLY_INSTALL" ]; then - if [ -n "$found" ]; then - return 0 - else - msg_warn "${pkg}: not installed in destdir!\n" - fi - fi - - stow_pkg_handler unstow || return $? - - [ -n "$found" ] && return 0 - - return 1 -} diff --git a/xbps-src/shutils/show_revdeps.sh b/xbps-src/shutils/show_revdeps.sh deleted file mode 100644 index 3bdac789dd1d39..00000000000000 --- a/xbps-src/shutils/show_revdeps.sh +++ /dev/null @@ -1,80 +0,0 @@ -#- -# Copyright (c) 2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -_show_hard_pkg_deps() -{ - local f tmplf deps revdepname _pkgn - - _pkgn=$(echo "$1"|sed 's|\+|\\+|g') - deps=$(grep -E "^Add_dependency[[:blank:]]+(run|full|build)[[:blank:]]+${_pkgn}([[:space:]]+\".*\")*$" $XBPS_SRCPKGDIR/*/*template|sed 's/:Add_dependency.*//g') - for f in ${deps}; do - [ -h "$(dirname $f)" ] && continue - tmplf=$(basename $f) - if [ "$tmplf" != template ]; then - revdepname=${tmplf%.template} - else - revdepname=$(basename $(dirname $f)) - fi - echo $revdepname - done -} - -_show_shlib_pkg_deps() -{ - local f j soname - - soname=$(echo "$1"|sed 's|\+|\\+|g') - - revshlibs=$(grep -E "^${soname}$" ${XBPS_SRCPKGDIR}/*/*.rshlibs) - for f in ${revshlibs}; do - unset pkg revdepname tmprev - revdepname=$(basename "$f") - revdepname=${revdepname%.rshlibs*} - tmprev=$(echo "$revdepname"|sed 's/-//g') - eval pkg=\$pkg_"${tmprev}" - if [ -z "${pkg}" ]; then - eval local pkg_${tmprev}=1 - echo "$revdepname" - fi - done -} - -show_pkg_revdeps() -{ - local SHLIBS_MAP=$XBPS_COMMONDIR/shlibs - local _pkgn shlibs - - [ -z "$1" ] && return 1 - - _pkgn=$(echo "$1"|sed 's|\+|\\+|g') - - shlibs=$(grep -E "^lib.*\.so\.[[:digit:]]+[[:blank:]]+${_pkgn}[[:blank:]]?.*$" $SHLIBS_MAP|awk '{print $1}') - if [ -n "$shlibs" ]; then - # pkg provides shlibs - _show_shlib_pkg_deps "$shlibs" - fi - # show pkgs that use Add_dependency - _show_hard_pkg_deps "$1" -} diff --git a/xbps-src/shutils/stow_funcs.sh b/xbps-src/shutils/stow_funcs.sh deleted file mode 100644 index 2d79adfc2d8676..00000000000000 --- a/xbps-src/shutils/stow_funcs.sh +++ /dev/null @@ -1,211 +0,0 @@ -#- -# Copyright (c) 2008-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -stow_pkg_handler() -{ - local action="$1" subpkg spkgrev - - for subpkg in ${subpackages}; do - if [ -n "$revision" ]; then - spkgrev="${subpkg}-${version}_${revision}" - else - spkgrev="${subpkg}-${version}" - fi - if [ "$action" = "stow" ]; then - check_installed_pkg ${spkgrev} - [ $? -eq 0 ] && continue - fi - if [ ! -f $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template ]; then - msg_error "Cannot find $subpkg subpkg build template!\n" - fi - unset revision pre_install pre_remove post_install \ - post_remove post_stow - . $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template - pkgname=${subpkg} - set_tmpl_common_vars - if [ "$action" = "stow" ]; then - stow_pkg_real || return $? - else - unstow_pkg_real || return $? - fi - setup_tmpl ${sourcepkg} - done - - if [ "$action" = "stow" ]; then - stow_pkg_real - else - unstow_pkg_real - fi - return $? -} - -# -# Stow a package, i.e copy files from destdir into masterdir -# and register pkg into the package database. -# -stow_pkg_real() -{ - local i lfile lver regpkgdb_flags - - [ -z "$pkgname" ] && return 2 - - if [ $(id -u) -ne 0 ] && [ ! -w $XBPS_MASTERDIR ]; then - msg_error "cannot stow $pkgname! (permission denied)\n" - fi - - if [ -n "$build_style" -a "$build_style" = "meta-template" ]; then - [ ! -d ${DESTDIR} ] && mkdir -p ${DESTDIR} - fi - - [ -n "$stow_flag" ] && setup_tmpl $pkgname - - cd ${DESTDIR} || return 1 - - if [ -n "$revision" ]; then - lver="${version}_${revision}" - else - lver="${version}" - fi - msg_normal "$pkgver: stowning files into masterdir, please wait...\n" - - # Copy files into masterdir. - for i in $(find -print); do - lfile="$(echo $i|sed -e 's|^\./||')" - # Skip pkg metadata - if [ "$lfile" = "INSTALL" -o "$lfile" = "REMOVE" -o \ - "$lfile" = "files.plist" -o "$lfile" = "props.plist" ]; then - continue - # Skip files that are already in masterdir. - elif [ -f "$XBPS_MASTERDIR/$lfile" ]; then - echo " Skipping $lfile file, already exists!" - continue - elif [ -h "$XBPS_MASTERDIR/$lfile" ]; then - echo " Skipping $lfile link, already exists!" - continue - elif [ -d "$XBPS_MASTERDIR/$lfile" ]; then - continue - fi - if [ -f "$i" -o -h "$i" ]; then - # Always copy the pkg metadata flist file. - if [ "$(basename $i)" = "flist" ]; then - cp -dp $i $XBPS_MASTERDIR/$lfile - continue - fi - if [ -n "$IN_CHROOT" -a -n "$stow_copy_files" ]; then - # Templates that set stow_copy_files require - # some files to be copied, rather than symlinked. - local found - for j in ${stow_copy_files}; do - if [ "/$lfile" = "${j}" ]; then - found=1 - break - fi - done - if [ -n "$found" ]; then - cp -dp $i $XBPS_MASTERDIR/$lfile - unset found - continue - fi - fi - if [ -n "$IN_CHROOT" -a -n "$stow_copy" -o -z "$IN_CHROOT" ]; then - # In the no-chroot case and templates that - # set $stow_copy, we can't stow with symlinks. - # Just copy them. - cp -dp $i $XBPS_MASTERDIR/$lfile - else - # Always use symlinks in the chroot with pkgs - # that don't have $stow_copy set, they can have - # full path. - ln -sf $DESTDIR/$lfile $XBPS_MASTERDIR/$lfile - fi - elif [ -d "$i" ]; then - mkdir -p $XBPS_MASTERDIR/$lfile - fi - done - - # - # Register pkg in plist file. - # - $XBPS_PKGDB_CMD register $pkgname $lver "$short_desc" || return $? - run_func post_stow - return 0 -} - -# -# Unstow a package, i.e remove its files from masterdir and -# unregister pkg from package database. -# -unstow_pkg_real() -{ - local f ver - - [ -z $pkgname ] && return 1 - - if [ $(id -u) -ne 0 ] && \ - [ ! -w $XBPS_MASTERDIR ]; then - msg_error "cannot unstow $pkgname! (permission denied)\n" - fi - - ver=$($XBPS_PKGDB_CMD version $pkgname) - if [ -z "$ver" ]; then - msg_warn "'${pkgname}' not installed in masterdir!\n" - return 1 - fi - - if [ "$build_style" = "meta-template" ]; then - # If it's a metapkg, do nothing. - : - elif [ ! -f ${XBPS_PKGMETADIR}/${pkgname}/flist ]; then - msg_warn "${pkgname}-${ver}: wasn't installed from source!\n" - return 1 - elif [ ! -w ${XBPS_PKGMETADIR}/${pkgname}/flist ]; then - msg_error "${pkgname}-${ver}: cannot be removed (permission denied).\n" - elif [ -s ${XBPS_PKGMETADIR}/${pkgname}/flist ]; then - msg_normal "${pkgname}-${ver}: removing files from masterdir...\n" - run_func pre_remove - # Remove installed files. - for f in $(cat ${XBPS_PKGMETADIR}/${pkgname}/flist); do - if [ -f $XBPS_MASTERDIR/$f -o -h $XBPS_MASTERDIR/$f ]; then - rm -f $XBPS_MASTERDIR/$f >/dev/null 2>&1 - if [ $? -eq 0 ]; then - echo "Removing file: $f" - fi - elif [ -d $XBPS_MASTERDIR/$f ]; then - rmdir $XBPS_MASTERDIR/$f >/dev/null 2>&1 - if [ $? -eq 0 ]; then - echo "Removing directory: $f" - fi - fi - done - fi - - run_func post_remove - # Remove metadata dir. - [ -d $XBPS_PKGMETADIR/$pkgname ] && rm -rf $XBPS_PKGMETADIR/$pkgname - - # Unregister pkg from plist file. - $XBPS_PKGDB_CMD unregister $pkgname $ver - return $? -} diff --git a/xbps-src/shutils/strip_files.sh b/xbps-src/shutils/strip_files.sh deleted file mode 100644 index 01042265b35403..00000000000000 --- a/xbps-src/shutils/strip_files.sh +++ /dev/null @@ -1,57 +0,0 @@ -#- -# Copyright (c) 2010-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -strip_files() -{ - local subpkg - - for subpkg in ${subpackages}; do - . $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template - pkgname=${subpkg} - set_tmpl_common_vars - strip_files_real - setup_tmpl ${sourcepkg} - done - - strip_files_real -} - -strip_files_real() -{ - [ -n "$nostrip" -o -n "$noarch" ] && return 0 - [ -z "$strip_cmd" ] && strip_cmd=strip - - msg_normal "$pkgver: stripping files, please wait...\n" - find ${DESTDIR} -type f | while read f; do - case "$(file -bi "$f")" in - application/x-executable*) - ${strip_cmd} "$f" && \ - echo " Stripped executable: $(basename $f)";; - application/x-sharedlib*|application/x-archive*) - ${strip_cmd} -S "$f" && \ - echo " Stripped library: $(basename $f)";; - esac - done -} diff --git a/xbps-src/shutils/tmpl_funcs.sh b/xbps-src/shutils/tmpl_funcs.sh deleted file mode 100644 index 29054df0385355..00000000000000 --- a/xbps-src/shutils/tmpl_funcs.sh +++ /dev/null @@ -1,398 +0,0 @@ -#- -# Copyright (c) 2008-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -# -# Shows info about a template. -# -info_tmpl() -{ - local i= - - for f in $XBPS_COMMONDIR/*.sh; do - [ -r ${f} ] && . ${f} - done - - echo "pkgname: $pkgname" - echo "version: $version" - [ -n "$revision" ] && echo "revision: $revision" - for i in ${distfiles}; do - [ -n "$i" ] && echo "distfiles: $i" - done - for i in ${checksum}; do - [ -n "$i" ] && echo "checksum: $i" - done - [ -n "$noarch" ] && echo "noarch: yes" - echo "maintainer: $maintainer" - [ -n "$homepage" ] && echo "Upstream URL: $homepage" - [ -n "$license" ] && echo "License(s): $license" - [ -n "$build_style" ] && echo "build_style: $build_style" - for i in ${configure_args}; do - [ -n "$i" ] && echo "configure_args: $i" - done - echo "short_desc: $short_desc" - for i in ${subpackages}; do - [ -n "$i" ] && echo "subpackages: $i" - done - for i in ${conf_files}; do - [ -n "$i" ] && echo "conf_files: $i" - done - for i in ${replaces}; do - [ -n "$i" ] && echo "replaces: $i" - done - for i in ${conflicts}; do - [ -n "$i" ] && echo "conflicts: $i" - done - echo "$long_desc" - echo - check_build_depends_pkg - if [ $? -eq 0 ]; then - echo "This package requires the following build-time dependencies:" - for i in ${build_depends}; do - echo " $i" - done - fi - if [ -n "${run_depends}" ]; then - echo - echo "This package requires the folloring run-time dependencies:" - for i in ${run_depends}; do - echo " $i" - done - fi -} - -# -# Resets all vars used by a template. -# -reset_tmpl_vars() -{ - local TMPL_VARS="pkgname distfiles configure_args strip_cmd \ - make_build_args make_install_args build_style \ - short_desc maintainer long_desc checksum wrksrc \ - make_cmd bootstrap register_shell \ - make_build_target configure_script noextract nofetch \ - build_depends nostrip nonfree \ - make_install_target version revision patch_args \ - sgml_catalogs xml_catalogs xml_entries sgml_entries \ - disable_parallel_build run_depends font_dirs preserve \ - only_for_archs conf_files keep_libtool_archives \ - noarch subpackages sourcepkg gtk_iconcache_dirs \ - abi_depends api_depends triggers make_dirs \ - replaces system_accounts system_groups provides \ - build_wrksrc create_wrksrc broken_as_needed pkgver \ - ignore_vdeps_dir noverifyrdeps conflicts dkms_modules \ - gconf_entries gconf_schemas stow_copy stow_copy_files \ - pycompile_dirs pycompile_module systemd_services \ - homepage license kernel_hooks_version makejobs \ - SUBPKG XBPS_EXTRACT_DONE XBPS_CONFIGURE_DONE \ - XBPS_BUILD_DONE XBPS_INSTALL_DONE FILESDIR DESTDIR \ - SRCPKGDESTDIR PATCHESDIR CFLAGS CXXFLAGS CPPFLAGS \ - CC CXX LDFLAGS LD_LIBRARY_PATH" - - local TMPL_FUNCS="pre_configure pre_build pre_install do_build \ - do_install do_configure post_configure post_build \ - post_install do_fetch pre_remove post_remove \ - post_stow post_extract" - - eval unset -v "$TMPL_VARS" - eval unset -f "$TMPL_FUNCS" -} - -# -# Reads a template file and setups required variables for operations. -# -setup_tmpl() -{ - local pkg="$1" - - [ -z "$pkg" ] && return 1 - - if [ "$pkgname" = "$pkg" ]; then - [ -n "$DESTDIR" ] && return 0 - fi - - for f in $XBPS_COMMONDIR/*.sh; do - [ -r ${f} ] && . ${f} - done - - if [ -f $XBPS_SRCPKGDIR/${pkg}/template ]; then - reset_tmpl_vars - . $XBPS_SRCPKGDIR/${pkg}/template - prepare_tmpl - else - msg_error "Cannot find $pkg build template file.\n" - fi - -} - -setup_subpkg_tmpl() -{ - local f - - [ -z "$1" ] && return 1 - - if [ -r "$XBPS_SRCPKGDIR/$1/$1.template" ]; then - setup_tmpl $1 - unset run_depends build_depends - . $XBPS_SRCPKGDIR/$1/$1.template - for f in ${subpackages}; do - [ "$f" != "$1" ] && continue - pkgname=$f - set_tmpl_common_vars - SUBPKG=1 - break - done - else - setup_tmpl $1 - fi -} - -check_builddep_dup() -{ - local dep="$1" i - - for i in ${build_depends}; do - [ "${i}" != "${dep}" ] && continue - return 1 - done -} - -check_rundep_dup() -{ - local dep="$1" i - - for i in ${run_depends}; do - [ "${i}" != "${dep}" ] && continue - return 1 - done -} - -dependency_version() -{ - local type="$1" pkgn="$2" - - if [ -f $XBPS_SRCPKGDIR/${pkgn}/${pkgn}.depends ]; then - . $XBPS_SRCPKGDIR/${pkgn}/${pkgn}.depends - elif [ -f $XBPS_SRCPKGDIR/${pkgn}/depends ]; then - . $XBPS_SRCPKGDIR/${pkgn}/depends - fi - - if [ "$type" = "build" ]; then - if [ -z "$api_depends" ]; then - echo "${pkgn}>=0" - else - echo "${pkgn}${api_depends}" - fi - elif [ "$type" = "run" ]; then - if [ -z "$abi_depends" ]; then - echo "${pkgn}>=0" - else - echo "${pkgn}${abi_depends}" - fi - fi - - unset abi_depends api_depends -} - -Add_dependency() -{ - local type="$1" pkgn="$2" ver="$3" - - case "$type" in - build|full|run) ;; - *) msg_error "[$pkgname] Unknown dependency type for $pkgn.\n" ;; - esac - - [ -z "$pkgn" ] && msg_error "[$pkgname] Add_dependency: pkgname empty!\n" - - if [ -f $XBPS_SRCPKGDIR/${pkgn}/${pkgn}.depends ]; then - . $XBPS_SRCPKGDIR/${pkgn}/${pkgn}.depends - elif [ -f $XBPS_SRCPKGDIR/${pkgn}/depends ]; then - . $XBPS_SRCPKGDIR/${pkgn}/depends - fi - - if [ "$type" = "full" -o "$type" = "build" ]; then - if [ -z "$ver" -a -z "$api_depends" ]; then - if check_builddep_dup "${pkgn}>=0"; then - build_depends="${build_depends} ${pkgn}>=0" - fi - elif [ -z "$ver" -a -n "$api_depends" ]; then - if check_builddep_dup "${pkgn}${api_depends}"; then - build_depends="${build_depends} ${pkgn}${api_depends}" - fi - else - if check_builddep_dup "${pkgn}${version}"; then - build_depends="${build_depends} ${pkgn}${ver}" - fi - fi - fi - - if [ "$type" = "full" -o "$type" = "run" ]; then - if [ -z "$ver" -a -z "$abi_depends" ]; then - if check_rundep_dup "${pkgn}>=0"; then - run_depends="${run_depends} ${pkgn}>=0" - fi - elif [ -z "$ver" -a -n "$abi_depends" ]; then - if check_rundep_dup "${pkgn}${api_depends}"; then - run_depends="${run_depends} ${pkgn}${abi_depends}" - fi - else - if check_rundep_dup "${pkgn}${ver}"; then - run_depends="${run_depends} ${pkgn}${ver}" - fi - fi - fi - - unset abi_depends api_depends -} - -# -# Checks some vars used in templates and sets some of them required. -# -prepare_tmpl() -{ - local REQ_VARS i found - - REQ_VARS="pkgname version short_desc long_desc" - - if [ -n "$build_style" -a "$build_style" = "meta-template" ]; then - nofetch=yes - noextract=yes - fi - - # Check if required vars weren't set. - for i in ${REQ_VARS}; do - eval val="\$$i" - if [ -z "$val" -o -z "$i" ]; then - msg_error "\"$i\" not set on $pkgname template.\n" - fi - done - - if [ -n "$only_for_archs" ]; then - if $(echo "$only_for_archs"|grep -q "$XBPS_MACHINE"); then - found=1 - fi - fi - if [ -n "${only_for_archs}" -a -z "$found" ]; then - msg_error "$pkgname: this package cannot be built on $XBPS_MACHINE.\n" - fi - - unset XBPS_EXTRACT_DONE XBPS_APPLYPATCHES_DONE - unset XBPS_CONFIGURE_DONE XBPS_BUILD_DONE XBPS_INSTALL_DONE - - [ -z "$wrksrc" ] && wrksrc="$pkgname-$version" - wrksrc="$XBPS_BUILDDIR/$wrksrc" - - XBPS_FETCH_DONE="$wrksrc/.xbps_fetch_done" - XBPS_EXTRACT_DONE="$wrksrc/.xbps_extract_done" - XBPS_APPLYPATCHES_DONE="$wrksrc/.xbps_applypatches_done" - XBPS_CONFIGURE_DONE="$wrksrc/.xbps_configure_done" - XBPS_PRECONFIGURE_DONE="$wrksrc/.xbps_pre_configure_done" - XBPS_POSTCONFIGURE_DONE="$wrksrc/.xbps_post_configure_done" - XBPS_BUILD_DONE="$wrksrc/.xbps_build_done" - XBPS_PRE_BUILD_DONE="$wrksrc/.xbps_pre_build_done" - XBPS_POST_BUILD_DONE="$wrksrc/.xbps_post_build_done" - XBPS_INSTALL_DONE="$wrksrc/.xbps_install_done" - XBPS_PRE_INSTALL_DONE="$wrksrc/.xbps_pre_install_done" - XBPS_POST_INSTALL_DONE="$wrksrc/.xbps_post_install_done" - - set_tmpl_common_vars -} - -remove_tmpl_wrksrc() -{ - local lwrksrc="$1" - - if [ ! -d "$lwrksrc" ]; then - return 0 - fi - - msg_normal "$pkgver: cleaning build directory...\n" - rm -rf $lwrksrc - return $? -} - -set_tmpl_common_vars() -{ - local cflags cxxflags cppflags ldflags - - [ -z "$pkgname" ] && return 1 - - if [ -n "$revision" ]; then - pkgver="${pkgname}-${version}_${revision}" - else - pkgver="${pkgname}-${version}" - fi - - . $XBPS_SHUTILSDIR/install_files.sh - - if [ -n "$BOOTSTRAP_PKG_REBUILD" ]; then - unset bootstrap - fi - - FILESDIR=$XBPS_SRCPKGDIR/$pkgname/files - PATCHESDIR=$XBPS_SRCPKGDIR/$pkgname/patches - DESTDIR=${XBPS_DESTDIR}/${pkgname}-${version} - if [ -z "${sourcepkg}" ]; then - sourcepkg=${pkgname} - fi - SRCPKGDESTDIR=${XBPS_DESTDIR}/${sourcepkg}-${version} - - [ -n "$XBPS_CFLAGS" ] && cflags="$XBPS_CFLAGS" - [ -n "$CFLAGS" ] && cflags="$cflags $CFLAGS" - [ -n "$XBPS_CXXFLAGS" ] && cxxflags="$XBPS_CXXFLAGS" - [ -n "$CXXFLAGS" ] && cxxflags="$cxxflags $CXXFLAGS" - [ -n "$XBPS_CPPFLAGS" ] && cppflags="$XBPS_CPPFLAGS" - [ -n "$CPPFLAGS" ] && cppflags="$cppflags $CPPFLAGS" - [ -n "$XBPS_LDFLAGS" ] && ldflags="$XBPS_LDFLAGS" - [ -n "$LDFLAGS" ] && ldflags="$ldflags $LDFLAGS" - - [ -n "$cflags" ] && export CFLAGS="$cflags" - [ -n "$cxxflags" ] && export CXXFLAGS="$cxxflags" - [ -n "$cppflags" ] && export CPPFLAGS="$cppflags" - [ -n "$ldflags" ] && export LDFLAGS="$ldflags" - - if [ -n "$broken_as_needed" -a -n "$XBPS_LDFLAGS" ]; then - export LDFLAGS="$(echo $LDFLAGS|sed -e "s|-Wl,--as-needed||g")" - fi - - if [ -z "$IN_CHROOT" ]; then - export CPPFLAGS="-I$XBPS_MASTERDIR/usr/include" - if [ -d /usr/lib/libfakeroot ]; then - LDLIBPATH="/usr/lib/libfakeroot:$XBPS_MASTERDIR/usr/lib" - else - LDLIBPATH="$XBPS_MASTERDIR/usr/lib" - fi - if [ -n "$BUILD_32BIT" ]; then - # Force gcc multilib to emit 32bit binaries. - export CC="gcc -m32" - export CXX="g++ -m32" - # Export default 32bit directories. - LDLIBPATH="$LDLIBPATH:/lib32:/usr/lib32" - LDFLAGS="-L/lib32 -L/usr/lib32" - fi - export LDFLAGS="$LDFLAGS -L$XBPS_MASTERDIR/usr/lib" - export LD_LIBRARY_PATH="$LDLIBPATH" - fi -} diff --git a/xbps-src/shutils/verify_rundeps.sh b/xbps-src/shutils/verify_rundeps.sh deleted file mode 100644 index a5e47221f7ebeb..00000000000000 --- a/xbps-src/shutils/verify_rundeps.sh +++ /dev/null @@ -1,241 +0,0 @@ -#- -# Copyright (c) 2010-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- -# -# Finds all required libraries for a package, by looking at its executables -# and shared libraries and skipping duplicated matches. -# -# Once the list is known it finds the binary package names mapped to those -# libraries and reports if any of them was not added. -# - -find_rundep() -{ - local dep="$1" i rpkgdep - - for i in ${run_depends}; do - rpkgdep="$($XBPS_PKGDB_CMD getpkgdepname $i)" - [ "${rpkgdep}" != "${dep}" ] && continue - return 1 - done -} - -verify_rundeps() -{ - local j f nlib verify_deps maplib found_dup igndir soname_arch - local broken rdep found rsonamef soname_list revbumped tmplf newrev - - maplib=$XBPS_COMMONDIR/shlibs - - [ -n "$noarch" -o -n "$noverifyrdeps" ] && return 0 - msg_normal "$pkgver: verifying required shlibs...\n" - - depsftmp=$(mktemp -t xbps_src_depstmp.XXXXXXXXXX) || exit 1 - find ${1} -type f -perm -u+w > $depsftmp 2>/dev/null - - exec 3<&0 # save stdin - exec < $depsftmp - while read f; do - # Don't check dirs specified in ignore_vdeps_dir. - for j in ${ignore_vdeps_dir}; do - if grep -q ${j} "${f}"; then - igndir=1 - break - fi - done - [ -n "$igndir" ] && continue - unset igndir - - case "$(file -bi "$f")" in - application/x-executable*|application/x-sharedlib*) - for nlib in $(objdump -p "$f"|grep NEEDED|awk '{print $2}'); do - if [ -z "$verify_deps" ]; then - verify_deps="$nlib" - continue - fi - for j in ${verify_deps}; do - [ "$j" != "$nlib" ] && continue - found_dup=1 - break - done - if [ -z "$found_dup" ]; then - verify_deps="$verify_deps $nlib" - fi - unset found_dup - done - ;; - esac - done - exec 0<&3 # restore stdin - rm -f $depsftmp - - if [ -f $XBPS_SRCPKGDIR/$pkgname/$pkgname.template ]; then - tmplf=$XBPS_SRCPKGDIR/$pkgname/$pkgname.template - else - tmplf=$XBPS_SRCPKGDIR/$pkgname/template - fi - # - # Add required run time packages by using required shlibs resolved - # above, the mapping is done thru the mapping_shlib_binpkg.txt file. - # - for f in ${verify_deps}; do - unset j rdep _rdep rdepcnt - rdep="$(grep "^${f}.*$" $maplib|awk '{print $2}')" - rdepcnt="$(grep "^${f}.*$" $maplib|awk '{print $2}'|wc -l)" - if [ -z "$rdep" ]; then - # Ignore libs by current pkg - soname=$(find ${DESTDIR} -type f -name "$f"); - if [ -z "$soname" ]; then - echo " SONAME: $f <-> UNKNOWN PKG PLEASE FIX!" - broken=1 - else - echo " SONAME: $f <-> $pkgname (ignored)" - fi - continue - elif [ "$rdepcnt" -gt 1 ]; then - unset j found - # Check if shlib is provided by multiple pkgs. - for j in ${rdep}; do - # if there's a SONAME matching pkgname, use it. - [ "${j}" != "${pkgname}" ] && continue - found=1 - break - done - if [ -n "$found" ]; then - _rdep=$j - else - # otherwise pick up the first one. - for j in ${rdep}; do - [ -z "${_rdep}" ] && _rdep=$j - done - fi - else - _rdep=$rdep - fi - if [ "${_rdep}" != "$pkgname" ]; then - echo " SONAME: $f <-> ${_rdep}" - else - # Ignore libs by current pkg - echo " SONAME: $f <-> ${_rdep} (ignored)" - continue - fi - # Add required shlib to rundeps. - if [ -z "$soname_list" ]; then - soname_list="${f}" - else - soname_list="${soname_list} ${f}" - fi - # Try to remove the line from template - sed -i -r "/^Add_dependency run ${_rdep}([[:space:]]+\".*\")*$/d" $tmplf - if find_rundep ${_rdep}; then - Add_dependency run ${_rdep} - fi - done - # - # If pkg uses any SONAME not known, error out. - # - [ -n "$broken" ] && \ - msg_error "$pkgver: cannot guess required shlibs, aborting!\n" - - # - # Update package's rshlibs file. - # - unset broken f - msg_normal "$pkgver: updating rshlibs file...\n" - rsonamef=${XBPS_SRCPKGDIR}/${pkgname}/${pkgname}.rshlibs - if [ ! -f $rsonamef ]; then - # file not found, add soname. - for j in ${soname_list}; do - echo " SONAME: $j (added)" - echo "${j}" >> $rsonamef - done - [ -n "$soname_list" ] && broken=1 - else - # check if soname is already in the rshlibs file. - for j in ${soname_list}; do - if ! grep -q "$j" $rsonamef; then - echo " SONAME: $j (added)" - echo "$j" >> $rsonamef - broken=1 - fi - done - unset f - exec 3<&0 # save stdin - exec < $rsonamef - # now check if any soname in the rshlibs file is unnecessary. - while read f; do - local _soname=$(echo "$f"|awk '{print $1}') - local _soname_arch=$(echo "$f"|awk '{print $2}') - - for j in ${soname_list}; do - if [ "${_soname}" = "$j" ]; then - found=1 - continue - fi - done - if [ -n "$found" ]; then - unset found - continue - fi - # Sometimes a required SONAME is arch dependent, so - # ignore it in such case. - if [ -n "${_soname_arch}" -a "${_soname_arch}" != "$XBPS_MACHINE" ]; then - continue - fi - - # If SONAME is arch specific, only remove it if - # matching on the target arch. - _soname_arch=$(grep "$f" $maplib|awk '{print $4}') - if [ -z "${_soname_arch}" ] || \ - [ -n "${_soname_arch}" -a "${_soname_arch}" = "$XBPS_MACHINE" ]; then - echo " SONAME: $f (removed, not required)" - sed -i "/^${_soname}$/d" $rsonamef - broken=1 - fi - unset _soname _soname_arch - done - exec 0<&3 # restore stdin - fi - - if [ -n "$broken" ]; then - msg_warn "$pkgver: shlibs changed... package has been revbumped!\n" - _rev=$(egrep '^revision=.*' $tmplf) - if [ -n "${_rev}" ]; then - if [ -z "$revbumped" ]; then - readonly newrev=$((${_rev#revision=} + 1)) - sed -i "s/^revision=.*$/revision=${newrev}/" $tmplf - export revision=${newrev} - export pkgver="${pkgname}-${version}_${revision}" - revbumped=1 - fi - else - if [ -z "$revbumped" ]; then - sed -i "/^short_desc=.*$/irevision=1" $tmplf - export revision=1 - export pkgver="${pkgname}-${version}_${revision}" - revbumped=1 - fi - fi - fi -} diff --git a/xbps-src/vars.mk b/xbps-src/vars.mk deleted file mode 100644 index 557bbd9fc74e85..00000000000000 --- a/xbps-src/vars.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Common variables. - -PREFIX ?= /usr/local -SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin -# -# The following vars shouldn't be specified with DESTDIR! -# -SHAREDIR ?= $(PREFIX)/share/xbps-src -LIBEXECDIR ?= $(PREFIX)/libexec/xbps-src -ETCDIR ?= $(PREFIX)/etc/xbps diff --git a/xbps-src/xbps-src.sh.in b/xbps-src/xbps-src.sh.in deleted file mode 100644 index f123b093651279..00000000000000 --- a/xbps-src/xbps-src.sh.in +++ /dev/null @@ -1,508 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2008-2011 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- -readonly XBPS_SRC_BUILD_VERSION=20111118-1 - -if [ -n "$IN_CHROOT" ]; then - export XBPS_ETCDIR=/usr/local/etc/xbps - export XBPS_SHAREDIR=/usr/local/share/xbps-src - export XBPS_LIBEXECDIR=/usr/local/libexec/xbps-src -else - export XBPS_PREFIX=@@XBPS_INSTALL_PREFIX@@ - export XBPS_ETCDIR=@@XBPS_INSTALL_ETCDIR@@ - export XBPS_SBINDIR=@@XBPS_INSTALL_SBINDIR@@ - export XBPS_SHAREDIR=@@XBPS_INSTALL_SHAREDIR@@ - export XBPS_LIBEXECDIR=@@XBPS_INSTALL_LIBEXECDIR@@ -fi - -XBPS_CONFIG_FILE=${XBPS_ETCDIR}/xbps-src.conf -PROGNAME=$(basename $0) -FAKEROOT_CMD=/usr/bin/fakeroot -FAKEROOT_CMD_ARGS="--" -SUDO_CMD=sudo -CHROOT_CMD=chroot -XBPS_MACHINE=$(uname -m) - -# Required utilities in host system. -REQHOST_UTILS="awk bash bison sed gcc msgfmt patch makeinfo \ - perl fakeroot tar xz gzip bzip2 xbps-bin.static \ - xbps-repo.static xbps-uhelper.static" - -check_reqhost_utils() -{ - local broken - - [ -n "$IN_CHROOT" ] && return 0 - - for f in ${REQHOST_UTILS}; do - if ! command -v ${f} 2>&1 >/dev/null; then - echo "${f} is missing in your system, can't continue!" - broken=1 - fi - done - - [ -n "$broken" ] && exit 1 -} - -usage() -{ - cat << _EOF -$PROGNAME: [-BCDhKS] [-c file] [-m dir] [-p dir] [-s dir] [target] [pkgname] - -Targets: - bootstrap - Build and install from source the bootstrap packages into . - - bootstrap-update - Updates bootstrap packages with latest versions available from registered - repositories in the XBPS configuration file, by default set to - /usr/local/etc/xbps/repositories.plist. - - build [pkgname] - Build package source (fetch + extract + configure + build). - - build-pkg [pkgname|all] - Build a binary package from or all packages with the - keyword. The package(s) must be installed into for this to work. - - checkvers - Checks installed package versions in against the srcpkgs tree - for new available versions. - - chroot - Enter to the chroot in . - - clean [pkgname] - Remove build directory. - - clean-autodeps - Removes all package dependencies installed automatically. - - configure [pkgname] - Configure a package (fetch + extract + configure). - - extract [pkgname] - Extract package source distribution file(s) into the build directory. - By default set to /builddir. - - fetch [pkgname] - Download package source distribution file(s). - - install [pkgname] - Installs a package into destination directory and \`stows' its files into - . If a package is not from bootstrap group, its files will be - symlinked rather than being fully copied. - - list - List installed packages in . - - make-repoidx - Build a package index for the local repository associated with the - master directory . By default set to . - - remove [pkgname] - Remove package completely from and . - - show [pkgname] - Show information for the specified package. - - show-files - Show package files from . Package must be fully installed - into for this to work (stowed). - - show-revdeps - Show reverse dependencies for , i.e packages that are currently - depending on . - - stow [pkgname] - Stow files from into and register package - in database. When a package is \`stowed', its files will be available in - , and other packages will be able to found it. - - unstow [pkgname] - Remove files from and unregister package - from database. - -On targets that accept [pkgname], a package name can be specified and xbps-src -will execute the task on any CWD (Current Working Directory). If the argument -is omitted xbps-src assumes that CWD is in the target package. Example: - - $ cd srcpkgs/libX11 && xbps-src install - $ xbps-src install libX11 - -Both ways are equivalent. - -Options: - -B Used in the install target, a binary package is built for any - required dependency as well as for . The local repository - pkg-index is created or updated after a successful package installation. - -C Do not remove build directory after successful installation. - -c Path to global configuration file: - if not specified ${XBPS_ETCDIR}/xbps-src.conf is used. - -D Only install to package's destdir (set to - /destdir/- by default). - -h Usage output. - -K Do not remove automatic package dependencies while building - or installing a package with XBPS_PREFER_BINPKG_DEPS enabled. - -m Master directory, overwritting the value set in the configuration - file xbps-src.conf. - -p Local packages repository, overwritting default path at - /host/binpkgs or if XBPS_HOSTDIR is set /binpkgs. - -S Overrides and disables XBPS_PREFER_BINPKG_DEPS even if it was - set in the configuration file xbps-src.conf. - -s Source distribution files directory, overwritting default path at - /host/sources or if XBPS_HOSTDIR is set /sources. -_EOF -} - -basename_cwd() -{ - echo $(basename $(pwd)) -} - -check_path() -{ - eval local orig="$1" - - case "$orig" in - /) ;; - /*) orig="${orig%/}" ;; - *) orig="$(pwd)/${orig%/}" ;; - esac - - path_fixed="$orig" -} - -run_file() -{ - local file="$1" - - check_path "$file" - . $path_fixed -} - -check_config_vars() -{ - local val cffound f cfpaths cf="xbps-src.conf" - - if [ -z "$XBPS_CONFIG_FILE" ]; then - cfpaths="@@XBPS_INSTALL_PREFIX@@/etc/${cf} ./etc/${cf}" - for f in $cfpaths; do - if [ -f ${f} ]; then - XBPS_CONFIG_FILE=${f} - cffound=yes - break - fi - done - [ -z "$cffound" ] && msg_error "cannot find a config file\n" - fi - - run_file ${XBPS_CONFIG_FILE} - export XBPS_CONFIG_FILE=$path_fixed - - if [ ! -f "$XBPS_CONFIG_FILE" ]; then - msg_error "cannot find configuration file: $XBPS_CONFIG_FILE\n" - fi - - for f in XBPS_DISTRIBUTIONDIR XBPS_MASTERDIR; do - eval val="\$${f}" - if [ -z "$val" ]; then - msg_error "'${f}' not set in configuration file!\n" - fi - done - if [ ! -w "$XBPS_MASTERDIR" ]; then - echo "ERROR: not enough perms for masterdir $XBPS_MASTERDIR.\n" - exit 1 - fi -} - -# -# main() -# -while getopts "CBc:DhKm:p:Ss:V" opt; do - case $opt in - B) export BUILD_BINPKG=1;; - C) export KEEP_WRKSRC=1;; - c) XBPS_CONFIG_FILE="$OPTARG";; - D) export DESTDIR_ONLY_INSTALL=1;; - h) usage && exit 0;; - K) export KEEP_AUTODEPS=1;; - m) - _MASTERDIR_FLAG=1 - _MASTERDIR="$OPTARG" - if [ ! -d ${_MASTERDIR} ]; then - mkdir -p ${_MASTERDIR} - fi - ;; - p) - _PACKAGEDIR="$OPTARG" - if [ ! -d ${_PACKAGEDIR} ]; then - mkdir -p ${_PACKAGEDIR}/${XBPS_MACHINE} - mkdir -p ${_PACKAGEDIR}/noarch - fi - ;; - S) UNSET_PREFER_BINPKG_DEPS=1;; - s) export XBPS_SRCDISTDIR="$OPTARG";; - V) echo $XBPS_SRC_BUILD_VERSION && exit 0;; - --) shift; break;; - esac -done -shift $(($OPTIND - 1)) - -[ $# -eq 0 -o $# -gt 2 ] && usage && exit 1 - -target="$1" -_pkgname="$2" - -if [ -z "$target" ]; then - echo "=> ERROR: missing target." - usage && exit 1 -fi - -# -# Check configuration vars before anyting else, and set defaults vars. -# -check_config_vars -if [ -n "${_MASTERDIR}" ]; then - export XBPS_MASTERDIR=${_MASTERDIR} -fi -. ${XBPS_SHAREDIR}/shutils/init_funcs.sh - -set_defvars -for f in $XBPS_SHUTILSDIR/*.sh; do - [ -r "$f" ] && . $f -done - -# Disable XBPS_PREFER_BINPKG_DEPS if requested. -[ -n "$UNSET_PREFER_BINPKG_DEPS" ] && unset XBPS_PREFER_BINPKG_DEPS - -# -# Check for required utilities in host system. -# -check_reqhost_utils - -# -# Fix up some vars when XBPS_USE_CAPABILITIES is set. -# -if [ -z "$IN_CHROOT" -a -n "$XBPS_USE_CAPABILITIES" ]; then - CHROOT_CMD="@@XBPS_INSTALL_LIBEXECDIR@@/capchroot" - unset SUDO_CMD -fi - -if [ "$(id -u)" -eq 0 ]; then - # disable sudo and fakeroot if uid==0 - CHROOT_CMD="chroot" - unset SUDO_CMD - if [ -n "$IN_CHROOT" ]; then - unset FAKEROOT_CMD - unset FAKEROOT_CMD_ARGS - fi -fi - -# -# Sanitize PATH. -# -if [ -z "$IN_CHROOT" ]; then - # In non chroot case always prefer host tools. - MYPATH="$PATH:$XBPS_MASTERDIR/bin:$XBPS_MASTERDIR/usr/bin" - MYPATH="$MYPATH:$XBPS_MASTERDIR/usr/local/bin" - MYPATH="$MYPATH:$XBPS_MASTERDIR/usr/local/sbin" - export PATH="$MYPATH" -else - MYPATH="/tools/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin" - MYPATH="$MYPATH:/usr/local/bin:/usr/lib/perl5/core_perl/bin" - export PATH="$MYPATH" - if [ -n "$XBPS_CCACHE" ]; then - CCACHEPATH="/usr/lib/ccache/bin" - if [ -n "$XBPS_HOSTDIR" ]; then - [ ! -d "$XBPS_HOSTDIR/ccache" ] && \ - mkdir -p $XBPS_HOSTDIR/ccache - export CCACHE_DIR="$XBPS_HOSTDIR/ccache" - else - [ ! -d "$XBPS_MASTERDIR/host/ccache" ] && \ - mkdir -p $XBPS_MASTERDIR/host/ccache - export CCACHE_DIR="$XBPS_MASTERDIR/host/ccache" - fi - export PATH="$CCACHEPATH:$PATH" - fi -fi - -# -# If masterdir is ready (base-chroot installed and chroot set up) and -# XBPS_PREFER_BINPKG_DEPS enabled, force ignoring rules to handle -# bootstrap packages. -# -if [ -n "$DESTDIR_ONLY_INSTALL" -a -n "$XBPS_PREFER_BINPKG_DEPS" \ - -a -f "$XBPS_MASTERDIR/.xbps_perms_done" ]; then - export BOOTSTRAP_PKG_REBUILD=1 -fi - -# -# Main switch. -# -case "$target" in -bootstrap) - [ ! -d $XBPS_SRCPKGDIR/base-chroot ] && \ - msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot directory!\n" - cd $XBPS_SRCPKGDIR/base-chroot && _ORIGINPKG="$(basename_cwd)" - setup_tmpl ${_ORIGINPKG} && install_pkg $pkgname - ;; -bootstrap-update) - if [ -z "$IN_CHROOT" ]; then - xbps_chroot_handler ${target} dummy - else - ${FAKEROOT_CMD} ${FAKEROOT_CMD_ARGS} ${XBPS_BIN_CMD} -y autoupdate - fi - ;; -build-pkg) - if [ -n "${_PACKAGEDIR}" ]; then - export XBPS_PACKAGESDIR=${_PACKAGEDIR} - fi - if [ "$2" = "all" ]; then - for f in $($XBPS_BIN_CMD list|awk '{print $1}'); do - pkg=$(${XBPS_PKGDB_CMD} getpkgname $f) - setup_tmpl $pkg - if [ "${pkg}" = "${sourcepkg}" ]; then - xbps_make_binpkg - fi - done - else - if [ -z "${_pkgname}" ]; then - [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" - _pkgname=$(basename_cwd) - fi - setup_tmpl ${_pkgname} - xbps_make_binpkg - fi - ;; -checkvers) - check_installed_packages - ;; -chroot) - xbps_chroot_handler chroot dummy - ;; -clean) - if [ -z "${_pkgname}" ]; then - [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" - _pkgname=$(basename_cwd) - fi - setup_tmpl ${_pkgname} - remove_tmpl_wrksrc $wrksrc - ;; -clean-autodeps) - if [ -z "$IN_CHROOT" ]; then - xbps_chroot_handler clean-autodeps dummy - else - pkgver=xbps-src - autoremove_pkg_dependencies - fi - ;; -extract|fetch) - if [ -z "${_pkgname}" ]; then - [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" - _pkgname=$(basename_cwd) - fi - setup_tmpl ${_pkgname} - if [ "$target" = "info" ]; then - info_tmpl - exit $? - fi - fetch_distfiles $update_checksum - [ "$target" = "extract" ] && extract_distfiles - ;; -build|configure|install) - if [ -z "${_pkgname}" ]; then - [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" - _pkgname=$(basename_cwd) - fi - setup_tmpl ${_pkgname} - _ORIGINPKG="${_pkgname}" - if [ -z "$IN_CHROOT" -a -z "$bootstrap" ]; then - xbps_chroot_handler $target ${_ORIGINPKG} || exit $? - else - INSTALL_TARGET=$target install_pkg $pkgname || exit $? - fi - ;; -list) - $XBPS_BIN_CMD list - ;; -make-repoidx) - if [ -n "${_PACKAGEDIR}" ]; then - export XBPS_PACKAGESDIR=${_PACKAGEDIR} - fi - make_repoidx - ;; -remove) - if [ -z "${_pkgname}" ]; then - [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" - _pkgname=$(basename_cwd) - fi - setup_tmpl ${_pkgname} - if [ -z "$IN_CHROOT" -a -z "$bootstrap" ]; then - xbps_chroot_handler $target ${_pkgname} - else - remove_pkg - fi - ;; -show) - if [ -z "${_pkgname}" ]; then - [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" - _pkgname=$(basename_cwd) - fi - setup_tmpl ${_pkgname} - info_tmpl - ;; -show-files) - list_pkg_files ${_pkgname} - ;; -show-revdeps) - show_pkg_revdeps ${_pkgname} - ;; -stow) - stow_flag=yes - if [ -z "${_pkgname}" ]; then - [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" - _pkgname=$(basename_cwd) - fi - setup_tmpl ${_pkgname} - stow_pkg_handler stow - ;; -unstow) - if [ -z "${_pkgname}" ]; then - [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" - _pkgname=$(basename_cwd) - else - pkgname=${_pkgname} - fi - stow_pkg_handler unstow - ;; -*) - msg_red "xbps-src: invalid target $target.\n" - usage && exit 1 -esac - -# Agur -exit $?