# -*-shell-script-*-

# constant definitions and translation bootstraps

###
#
# This code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# Copyright 2002 Mike Hearn (mike@theoretic.com)
#
###

# detect if we have set the SKELETON_DIR environment variable
if [[ "$SKELETON_DIRS" == "" ]]; then
    _skel_dirs=("/usr/local/share/autopackage/skeletons")
else
    # parse into an array
    _skel_dirs=(`echo "$SKELETON_DIRS" | tr ':' '\n'`)
fi

# set $TMP variable to "/tmp" if it's not already set
if [ ! -d "${TMP}" ]; then
    TMP="/tmp"
fi

skeleton_filename="skeleton"

TEST_PASS=0
TEST_PASS_RIGHT_VERSION=1
TEST_FAIL=50
TEST_FAIL_WRONG_VERSION=51

# Internationalized strings
TEXTDOMAIN=autopackage


# why do we need these functions? So we can easily use %s substitutions in internationalized strings
function out() {
    s="$1"; shift; 
    printf "$s\n" "$@"
    unset s
}

function outn() {
    s="$1"; shift; 
    printf "$s" "$@"
    unset s
}



intl_FAIL=$"FAIL: "
intl_FAILED=$"failed"
intl_DONE=$"done"
intl_DONE_WITH_WARNINGS=$"done with warnings"
intl_DONE_WITH_WARNINGS_SUPPRESSED=$"done with warnings (suppressed)"
intl_PASSED=$"passed"
intl_YESNO=$"Please type y for yes, or n for no"
intl_WARNING=$"WARNING: "
intl_PREFIX_QUERY=$"Please specify prefix"
intl_ERRORS=$"ERRORS: "

intl_ACCESS_DENIED=$"Access denied - installation of autopackages is restricted on this system"
intl_PROTOCOL_FAILURE=$"Protocol failure - ensure your installation of autopackage is correct"
intl_PROTOCOL_MISMATCH=$"Protocol version mismatch, was asked for %s - ensure your installation of autopackage is correct"
intl_ABORTED=$"Install aborted"
intl_BAD_CONFIG_VERSION=$"Bad config file version. Please rerun setup"
intl_PREFIX_NOT_SPECIFIED=$"If you give the --prefix option, you need to specify a prefix as the next argument"
intl_UNKNOWN_OPTION=$"Unknown option %s"
intl_PACKAGE_ALREADY_INSTALLED=$"The selected package is already installed"
intl_INSTALLER_HELP=$"autopackage for %s

    -p, --prefix          Sets the prefix that the package will install to
    -f, --force           Overrides the normally fatal warnings to force
	                  the install to proceed
    -d, --debug		  Extracts but does not automatically run the installer
    -x, --extract         Extracts the package and returns	  
    -h, --help            Display this help screen			  
"			  
intl_NO_DISK_SPACE=$"You don't have enough disk space for %s in prefix %s, you need at least %s bytes"

intl_BAD_CALL=$"There was an error in the package scripts, a bad API call was made: %s"
intl_BAD_CALL_REQUIRE1=$"require needs at least two arguments"

intl_ASSERTION_FAILURE=$"Assertion Failure: "
intl_ASSERTION_NOT_REACHED=$"A theoretically unreachable section of code was executed.\nThis program is in an inconsistant state and will be terminated."

################################################################################
## funclib


intl_FUNCLIB_DEPDB_CORRUPTION=$"Dependancy database corruption: %s"
intl_FUNCLIB_SUPPORTSDB_CORRUPTION=$"Supports database corruption"
intl_FUNCLIB_PACKAGE_REQUIRED=$"Package %s is required - attempting retrieval"
intl_FUNCLIB_PACKAGE_BAD_VERSION=$"You don't have the right version of package %s - attempting retrieval"
intl_FUNCLIB_RETRIEVAL_OK=$"Retrieval was successful, proceeding... "
intl_FUNCLIB_RETRIEVAL_FAILED=$"Retrieval failed. You need to install '%s'"
intl_FUNCLIB_RECOMMEND=$"It is recommended that you have package '%s' installed - it will enhance this package."
intl_FUNCLIB_CONFIGURING=$"Configuring.... "
intl_FUNCLIB_MAKING=$"Making...."
intl_FUNCLIB_INSTALLING=$"Installing to %s..."
intl_FUNCLIB_CLEANING=$"Cleaning up..."
intl_FUNCLIB_RECONFIGURING=$"reconfiguring to %s...."
intl_FUNCLIB_COPY_EXES=$"Copying executables to %s"
intl_FUNCLIB_COPY_DATA=$"Copying data to %s"
intl_FUNCLIB_COPY_DOCS=$"Copying documentation to %s"
intl_FUNCLIB_UPDATING_DB=$"Updating database... "
intl_FUNCLIB_FAILSAFE=$"Failsafe section '%s' has been triggered by the following line:"
intl_FUNCLIB_CHECKING_FOR_GLIBC_SYMBOL_VERSIONS=$"the required C library versions"
intl_FUNCLIB_NEED_SYMBOLS=$"Your copy of glibc, a core system library, is too old for this package.
You need at least the following symbols in glibc: %s.
This error normally means that whoever built the package did not build it correctly. 
Upgrading glibc is highly dangerous, so we recommend in this situation that you compile from the sources if possible. Sorry :("
# I guess we could add more detail here, it's not like users would be able to understand even what this is

intl_MKDIRS_ERROR=$"Could not create directory, error output was: %s"

intl_INSTALLING_FILES=$"Copying files to %s"
intl_INSTALLING_EXES=$"Installing executables... "
intl_INSTALLING_LIB=$"Installing libraries... "
intl_INSTALLING_MAN=$"Installing manual pages... "
intl_INSTALLING_INFO=$"Installing Info documentation... "
intl_INSTALLING_DESKTOP=$"Installing desktop entries... "
intl_INSTALLING_ICON=$"Installing icons... "
intl_INSTALLING_SOUND=$"Installing sounds... "
intl_INSTALLING_PATH_NOT_IN_LINKER_CACHE=$"Libraries are being placed in a location that isn't registered with the linker cache"
intl_INSTALLING_PATH_NOT_IN_LINKER_CACHE_SOLUTION=$"You should either place %s in /etc/ld.so.conf or install as a user"
intl_INSTALLING_UPDATING_LINKER=$"Updating linker cache... "

################################################################################
## autopackage ttyfe

intl_APKG_TTYFE_ROOT_PWD=$"Please enter the root password below"
intl_APKG_TTYFE_ROOT_SWITCH_FAILED=$"Switch to root failed"
intl_APKG_TTYFE_TESTING=$"Checking for %s .... "
intl_APKG_TTYFE_RECOMMENDED=$"recommended"
intl_APKG_TTYFE_COMPLETED=$"Operation completed."
intl_APKG_TTYFE_ABORTED=$"Operation aborted."
intl_APKG_TTYFE_DEPENDANCY_COMPLETED=$"Dependancy installed succesfully"

################################################################################
## makeinstaller

intl_MAKEINSTALLER_HELP=$"autopackage install builder
Usage from source directory root:
    makeinstaller [\"spec-filename1\" \"spec-filename2\" ... ]

Otherwise if no spec filename is declared then
spec filename autopackage/default.spec will be used.

The script will create a software package that will
be written to the file specified in the spec file."

intl_MAKEINSTALLER_NO_SPECFILE_GIVEN=$"No specfile specified - run 'makeinstaller foo' to use ./autopackage/foo.spec"
intl_MAKEINSTALLER_BUILDING=$"Building installer for %s"
intl_MAKEINSTALLER_NO_SPECFILE_FOUND=$"%s could not be found"
intl_MAKEINSTALLER_NO_SKELETON=$"Could not locate skeleton package for \"%s\""
intl_MAKEINSTALLER_NO_DESCRIPTION=$"No description found in the specfile, you should add one"
intl_MAKEINSTALLER_NO_UNINSTALLER=$"No uninstaller script found in the specfile, you should add one"
intl_MAKEINSTALLER_NO_INSTALLER=$"No install script found in the specfile, this is required"
intl_MAKEINSTALLER_NO_PREP=$"No prep script found in the specfile, you probably want one of these"
intl_MAKEINSTALLER_NO_DISPLAYNAME=$"No DisplayName key found in the [Meta] section. You need one"
intl_MAKEINSTALLER_NO_SHORTNAME=$"No ShortName key found in the [Meta] section."
intl_MAKEINSTALLER_NO_ROOTNAME=$"You forgot the RootName key in the [Meta] section. That's pretty important you know :)"
intl_MAKEINSTALLER_NO_ROOTNAME_VERSION=$"There is no version part of the rootname. You probably want to add ':\$SOFTWAREVERSION' to the end"
intl_MAKEINSTALLER_NO_VERSION=$"No SoftwareVersion key found in the [Meta] section, please add one"
intl_MAKEINSTALLER_NO_EXTRACTIONS=$"No [Extractions] section found."
intl_MAKEINSTALLER_TRY_CVS=$"Try running cvs update in the skeletons directory to get the latest files"
intl_MAKEINSTALLER_PREPARE_FAILED=$"Prepare failed. Please refer to above messages to see why."
intl_MAKEINSTALLER_EXTRACTING=$"extracting files to %s"
intl_MAKEINSTALLER_PLACED_IN=$"Package will be placed in %s"
intl_MAKEINSTALLER_SOURCE_DIR_DOESNT_EXIST=$"The source directory specified does not exist"
intl_MAKEINSTALLER_EXTRACT_COPY_FAIL=$"Could not extract files: %s"
intl_MAKEINSTALLER_GENERATING=$"Generating package.... "
intl_MAKEINSTALLER_DONE_WITH_WARNINGS=$"done with warnings"
intl_MAKEINSTALLER_SKEL_MISSING_VERSION=$"skeleton file (%s) is missing version"
intl_MAKEINSTALLER_BAD_SKELETON=$"Bad skeleton for %s, not in ASCII text format"

################################################################################
## autopackage verify

intl_APKG_VERIFY_VERSION=$"apkg-verify: version %s."
intl_APKG_VERIFY_MUST_SPECIFY=$"apkg-verify: Must specify a package to verify."
intl_APKG_VERIFY_VERIFYING=$"Verifying %s... please wait."
intl_APKG_VERIFY_PACKAGE_NOT_FOUND=$"Package %s not found."
intl_APKG_VERIFY_PACKAGES_ARE_BROKEN=$"The following packages are broken:"
intl_APKG_VERIFY_SUCCESS=$"Verified succesfully: all required components for this package are present."

################################################################################
## install

intl_INSTALL_SUCCESS=$"Package %s installed successfully."
intl_INSTALL_PACKAGE_NOT_FOUND=$"Package %s not found."
intl_INSTALL_ERROR=$"Package %s could not be installed."
intl_INSTALL_MUST_SPECIFY=$"apkg-install: Must specify a package to install."

################################################################################
## query

intl_QUERY_PACKAGE_NOT_FOUND=$"Package %s not found."
intl_QUERY_PACKAGE_NOT_INSTALLED=$"Package %s not installed.
Tip: if you are trying to query a package file, try the -p option."
intl_QUERY_PACKAGE_INVALID_FORMAT=$"File %s is not a valid Autopackage package."
intl_QUERY_MUST_SPECIFY=$"apkg-query: Must specify a package to query."
intl_QUERY_ERROR=$"Package %s could not be found."

################################################################################
## uninstall

intl_UNINSTALL_MUST_BE_ROOT=$"This package was installed by root, so you must be root to uninstall it."
intl_UNINSTALL_UNINSTALLING=$"Uninstalling %s... "
intl_UNINSTALL_PACKAGE_NOT_FOUND=$"package not found.";
intl_UNINSTALL_WOULD_BREAK=$"Removing this package would break:"
intl_UNINSTALL_DO_IT_ANYWAY=$"If you'd like to uninstall anyway, run this program with the -f force option."
intl_UNINSTALL_NOT_AUTOPACKAGE=$"This package is in the database but was not installed by autopackage";
intl_UNINSTALL_MUST_SPECIFY=$"apkg-uninstall: Must specify a package to uninstall."
intl_UNINSTALL_NO_SUDO=$"You are running as root, but this package was installed to your home directory.\nIf you're using sudo, you don't need it this time."

################################################################################
## package app

intl_PACKAGE_HELP=$"autopackage, (c) 2002 Mike Hearn

Usage: package <action> [options] [package name]

A package name can either be a short name (such as "gimp") or a root name, for
instance @gimp.org/gimp/1.4

Actions:
  info     : Print information about the named package, either from the
              database, online or a file.
  uninstall: Uninstalls the named package.
  install  : Retrieves either from the network or local media the named
              package, then installs it.
  verify   : Checks the package to see if the installation has been broken.

Options for info:
  -p packagefile : Print info from the specified package file.

Options for uninstall:
  -f             : Force uninstallation even when it would break other packages.
"

 intl_PACKAGE_FILE_MUST_EXIST=$"File %s must exist"
  intl_PACKAGE_INFO_SHORTNAME=$"Short name:     %s"
intl_PACKAGE_INFO_DISPLAYNAME=$"Display name:   %s"
   intl_PACKAGE_INFO_ROOTNAME=$"Root name:      %s"
    intl_PACKAGE_INFO_VERSION=$"Version:        %s"

intl_PACKAGE_UNKNOWN_COMMAND=$"The action '%s' is unrecognised. Run 'package --help' to see a list of possible actions."

# following are action menus RMB for .desktop files added during setupDesktopFile called from installDesktop
DESKTOP_ACTION_REMOVE=$"[Desktop Action Apkg-Remove]
Exec=package remove \"%s\"
Name[de]=Entfernen Paket
Name[en]=Remove Package
Name[es]=Quite El Paquete
Name[fr]=Enlevez Le Paquet
Name[it]=Rimuova Il Pacchetto
Name[nl]=Pakket Verwijderen
Name=Remove Package
"

DESKTOP_ACTION_VERIFY=$"[Desktop Action Apkg-Verify]
Exec=package verify \"%s\"
Name[de]=Validieren Paket
Name[en]=Verify Package
Name[es]=Verifique El Paquete
Name[fr]=Vérifier l'emballage
Name[it]=Verifichi Il Pacchetto
Name[nl]=Pakket Controleren
Name=Verify Package
"

DESKTOP_ACTION_UPDATE=$"[Desktop Action Apkg-Update]
Exec=package update \"%s\"
Icon=gnome-sync.png
Name[de]=Aktualisieren Paket
Name[en]=Update Package
Name[es]=Paquete De la Actualización
Name[fr]=Paquet de Mise à jour
Name[it]=Pacchetto Aggiornamento
Name[nl]=Pakket Bijwerken
Name=Update Package
"
