From 028cacdd2a6da80b6619a18b32f4308fcdac6ba2 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 18 Feb 2009 00:28:35 +0100 Subject: [PATCH] Add support to set automatic install flag for srcpkgs. --HG-- extra : convert_revision : fa0e103ce44a4758858124ecd63aea0dec400720 --- bin/xbps-pkgdb/main.c | 13 ++++++++++--- doc/TODO | 1 - shutils/builddep_funcs.sh | 8 ++++---- shutils/pkgtarget_funcs.sh | 5 +++-- shutils/stow_funcs.sh | 17 ++++++++++++++--- 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/bin/xbps-pkgdb/main.c b/bin/xbps-pkgdb/main.c index 9461199351d..8d093174577 100644 --- a/bin/xbps-pkgdb/main.c +++ b/bin/xbps-pkgdb/main.c @@ -65,6 +65,9 @@ usage(void) " Options shared by all actions:\n" " -r\t\t\t\n" "\n" + " Options used by the register action:\n" + " -a\t\t\tSet automatic installation flag.\n" + "\n" " Examples:\n" " $ xbps-pkgdb getpkgname foo-2.0\n" " $ xbps-pkgdb getpkgversion foo-2.0\n" @@ -82,11 +85,15 @@ main(int argc, char **argv) prop_dictionary_t dict; const char *version; char *plist, *pkgname, *in_chroot_env, *root = NULL; - bool in_chroot = false; + bool automatic = false, in_chroot = false; int c, rv = 0; - while ((c = getopt(argc, argv, "r:")) != -1) { + while ((c = getopt(argc, argv, "ar:")) != -1) { switch (c) { + case 'a': + /* Set automatic install flag */ + automatic = true; + break; case 'r': /* To specify the root directory */ root = strdup(optarg); @@ -123,7 +130,7 @@ main(int argc, char **argv) usage(); rv = xbps_register_pkg(NULL, argv[1], argv[2], - argv[3], false); + argv[3], automatic); if (rv == EEXIST) { printf("%s=> %s-%s already registered.\n", in_chroot ? "[chroot] " : "", argv[1], argv[2]); diff --git a/doc/TODO b/doc/TODO index 551241983a9..3b37d9ee765 100644 --- a/doc/TODO +++ b/doc/TODO @@ -5,7 +5,6 @@ xbps-src: * Add support to run the prepost-* scripts, so that the same actions are performed in source/bin packages. Use current postinstall_helpers to automatically add triggers, shared by src/bin pkgs. [IN PROGRESS] - * Fix the "automatic-install" object in regpkgdb.plist. Packages: * fix mpfr hardcoded rpath for gmp. diff --git a/shutils/builddep_funcs.sh b/shutils/builddep_funcs.sh index de45b568c88..982a0e76542 100644 --- a/shutils/builddep_funcs.sh +++ b/shutils/builddep_funcs.sh @@ -90,11 +90,11 @@ install_pkg_deps() else echo "=> Installing $curpkgname dependency: $j" jname=$(xbps-pkgdb getpkgname ${j}) - install_pkg $jname + install_pkg $jname auto fi done - install_pkg $curpkgname + install_pkg $curpkgname auto } # @@ -142,7 +142,7 @@ install_dependencies_pkg() check_build_depends_pkg $i if [ $? -eq 1 ]; then msg_normal "Installing $lpkgname dependency: $ipkgname" - install_pkg $ipkgname + install_pkg $ipkgname auto else install_pkg_deps $i $pkg fi @@ -165,7 +165,7 @@ install_builddeps_required_pkg() if [ $? -ne 0 ]; then msg_normal "Installing $pkgname dependency: $dep." depname=$(xbps-pkgdb getpkgname ${dep}) - install_pkg $depname + install_pkg $depname auto fi done } diff --git a/shutils/pkgtarget_funcs.sh b/shutils/pkgtarget_funcs.sh index 753e909fb76..659fa1c6a2d 100644 --- a/shutils/pkgtarget_funcs.sh +++ b/shutils/pkgtarget_funcs.sh @@ -1,5 +1,5 @@ #- -# Copyright (c) 2008 Juan Romero Pardines. +# Copyright (c) 2008-2009 Juan Romero Pardines. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -30,6 +30,7 @@ install_pkg() { local pkg= local curpkgn="$1" + local automatic="$2" local cdestdir= local cur_tmpl="$XBPS_TEMPLATESDIR/$curpkgn/template" @@ -117,7 +118,7 @@ install_pkg() # if [ -z "$install_destdir_target" ]; then . $XBPS_SHUTILSDIR/stow_funcs.sh - stow_pkg $pkg + stow_pkg $pkg $automatic fi } diff --git a/shutils/stow_funcs.sh b/shutils/stow_funcs.sh index 19b509f3924..8bc375d0092 100644 --- a/shutils/stow_funcs.sh +++ b/shutils/stow_funcs.sh @@ -1,5 +1,5 @@ #- -# Copyright (c) 2008 Juan Romero Pardines. +# Copyright (c) 2008-2009 Juan Romero Pardines. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -30,6 +30,7 @@ stow_pkg() { local pkg="$1" + local automatic="$2" local i= local destdir=$XBPS_DESTDIR/$pkgname-$version @@ -59,8 +60,16 @@ stow_pkg() cp -ar ${i} $XBPS_MASTERDIR done - $XBPS_REGPKGDB_CMD register $pkgname $version "$short_desc" - [ $? -ne 0 ] && exit 1 + # + # Register pkg in plist file and add automatic installation + # object if requested. + # + local regpkgdb_flags= + if [ -n "$automatic" ]; then + regpkgdb_flags="-a" + fi + $XBPS_REGPKGDB_CMD $regpkgdb_flags register \ + $pkgname $version "$short_desc" || exit 1 # # Run template postinstall helpers if requested. @@ -129,6 +138,8 @@ unstow_pkg() # Remove metadata dir. rm -rf $XBPS_PKGMETADIR/$pkgname + + # Unregister pkg from plist file. $XBPS_REGPKGDB_CMD unregister $pkgname $ver return $?