'Remove install_dir if it already exists and then recreate it unless
preserve_install_dir is specified as True.
Fetch the package into the pkg_dir. Untar the package into install_dir
The assumption is that packages are of the form :
<pkg_type>.<pkg_name>.tar.bz2
name        : name of the package
type        : type of the package
fetch_dir   : The directory into which the package tarball will be
fetched to.
install_dir : the directory where the package files will be untarred to
repo_url    : the url of the repository to fetch the package from.'

def install_pkg(self, name, pkg_type, fetch_dir, install_dir, preserve_install_dir=False, repo_url=None):

    if self.do_locking:
        lockfile_name = ('.%s-%s-lock' % (re.sub('/', '_', name), pkg_type))
        lockfile = open(os.path.join(self.pkgmgr_dir, lockfile_name), 'w')
    try:
        if self.do_locking:
            fcntl.flock(lockfile, fcntl.LOCK_EX)
        self._run_command(('mkdir    -p    %s' % fetch_dir))
        pkg_name = self.get_tarball_name(name, pkg_type)
        try:
            fetcher = self.fetch_pkg(pkg_name, fetch_dir, use_checksum=True, repo_url=repo_url, install=True)
            fetcher.install_pkg_post(pkg_name, fetch_dir, install_dir, preserve_install_dir)
        except error.PackageFetchError as why:
            raise error.PackageInstallError(('Installation    of    %s(type:%s)    failed    :    %s' % (name, pkg_type, why)))
    finally:
        if self.do_locking:
            fcntl.flock(lockfile, fcntl.LOCK_UN)
            lockfile.close()
