From 2b14031db2e5a636679c0208622f7a70e693c17a Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 3 Oct 2008 18:53:58 +0200 Subject: [PATCH] Some changes in how the configuration file is searched. If the configuration file is not specified through the -c flag, try to find it before at default location, and as last resort in current directory. This avoids having to specify -c all the time, even if you are using it from distribution dir. --HG-- extra : convert_revision : d0b48a1e53a064fe011c72c4f2492a897b113179 --- README | 21 +++++++++++---------- pkgfs.sh | 19 +++++++++++++++++-- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/README b/README index 91f0bad2c83..588246dbde9 100644 --- a/README +++ b/README @@ -15,12 +15,13 @@ Once you download it, you should edit the configuration file located at the pkgfs directory. By default it uses the pkgfs directory in your $HOME. If PKGFS_CONFIG_FILE is not set or specified from the command line with the --c flag, it will use the location "/usr/local/etc/pkgfs.conf". +-c flag, it will first try to use the default location at +/usr/local/etc/pkgfs.conf, and as last resort in current directory. Once that you read the "pkgfs.conf" file and configured it, you can start installing packages by using the command: - $ pkgfs.sh -c pkgfs.conf install glib-2.18.1 + $ pkgfs.sh install glib-2.18.1 Please note that it's assumed that PKGFS_TEMPLATESDIR is properly defined and actually contains valid template files. @@ -35,7 +36,7 @@ on which ``Xstow To remove a currently installed (and stowned) package, you can use: - $ pkgfs.sh -c pkgfs.conf remove glib-2.18.1 + $ pkgfs.sh remove glib-2.18.1 Please note that when you remove it, the package will also be removed from PKGFS_DESTDIR and previously "unstowned". @@ -50,11 +51,11 @@ PKGFS_DESTDIR/. Summary, to stow an already installed package (into PKGFS_DESTDIR/): - $ pkgfs.sh -c pkgs.conf stow glib-2.18.1 + $ pkgfs.sh stow glib-2.18.1 and to unstow an already installed (stowned) package: - $ pkgfs.sh -c pkgfs.conf unstow glib-2.18.1 + $ pkgfs.sh unstow glib-2.18.1 You can also print some stuff about any template, e.g: @@ -62,23 +63,23 @@ You can also print some stuff about any template, e.g: To list installed (stowned) packages, use this: - $ pkgfs.sh -c pkgfs.conf list + $ pkgfs.sh list To only extract the distfile, without configuring/building/installing: - $ pkgfs.sh -c pkgfs.conf -i install foo-1.0 + $ pkgfs.sh -i install foo-1.0 To not remove the build directory after successful installation: - $ pkgfs.sh -c pkgfs.conf -C install blah-1.0 + $ pkgfs.sh -C install blah-1.0 To only fetch the distfile: - $ pkgfs.sh -c pkgfs.conf -e install blah-1.0 + $ pkgfs.sh -e install blah-1.0 To only install the package, _without_ stowning it into the master directory: - $ pkgfs.sh -c pkgfs.conf -i install blob-4.0 + $ pkgfs.sh -i install blob-4.0 That's all for now folks. I hope you find it useful, as I do. diff --git a/pkgfs.sh b/pkgfs.sh index 085da963cd4..dc250f349c0 100755 --- a/pkgfs.sh +++ b/pkgfs.sh @@ -243,6 +243,20 @@ apply_tmpl_patches() check_config_vars() { + local cffound= + + if [ -z "$config_file_specified" ]; then + config_file_paths="$PKGFS_CONFIG_FILE ./pkgfs.conf" + for f in $config_file_paths; do + [ -f $f ] && PKGFS_CONFIG_FILE=$f && cffound=yes + done + if [ -z "$cffound" ]; then + echo -n "*** ERROR: config file not specified " + echo "and not in default location or current dir ***" + exit 1 + fi + fi + run_file ${PKGFS_CONFIG_FILE} PKGFS_CONFIG_FILE=$path_fixed @@ -934,8 +948,8 @@ list_tmpls() local reg_pkgdb="$PKGFS_DESTDIR/$PKGFS_REGISTERED_PKG_DB" if [ ! -r "$reg_pkgdb" ]; then - echo "*** ERROR: couldn't find the $reg_pkgdb, aborting ***" - exit 1 + echo "=> No packages registered or missing register db file." + exit 0 fi for i in $($db_cmd btree $reg_pkgdb); do @@ -983,6 +997,7 @@ while [ "$#" -gt 0 ]; do dontrm_builddir=yes ;; -c) + config_file_specified=yes PKGFS_CONFIG_FILE="$2" shift ;;