Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

beebox / crossover   deb

Repository URL to install this package:

Version: 18.5.0-1 

/ opt / cxoffice / bin / cxbottle

#!/usr/bin/perl
# (c) Copyright 2005-2018. CodeWeavers, Inc.
use warnings;
use strict;

# Portable which(1) implementation
sub cxwhich($$;$)
{
    my ($dirs, $app, $noexec)=@_;
    if ($app =~ /^\//)
    {
        return $app if ((-x $app or $noexec) and -f $app);
    }
    elsif ($app =~ /\//)
    {
        require Cwd;
        my $path=Cwd::cwd() . "/$app";
        return $path if ((-x $path or $noexec) and -f $path);
    }
    else
    {
        foreach my $dir (split /:/, $dirs)
        {
            return "$dir/$app" if ($dir ne "" and (-x "$dir/$app" or $noexec) and -f "$dir/$app");
        }
    }
    return undef;
}

# Fast dirname() implementation
sub _cxdirname($)
{
    my ($path)=@_;
    return undef if (!defined $path);
    return "." if ($path !~ s!/+[^/]+/*$!!s);
    return "/" if ($path eq "");
    return $path;
}

# Locate where CrossOver is installed by looking for the directory
# where the cxmenu script is located, unwinding symlinks on the way
sub locate_cx_root(;$)
{
    my ($fallback)=@_;
    my $argv0=cxwhich($ENV{PATH},$0);
    $argv0=$0 if (!defined $argv0);
    if ($argv0 !~ m+^/+)
    {
        require Cwd;
        $argv0=Cwd::cwd() . "/$argv0";
    }
    my $dir=_cxdirname($argv0);
    my $bindir=$dir;
    $bindir =~ s%/lib$%/bin%;
    while (!-x "$bindir/cxmenu" or !-f "$bindir/cxmenu")
    {
        last if (!-l $argv0);
        $argv0=readlink($argv0);
        $argv0="$dir/$argv0" if ($argv0 !~ m+^/+);
        $dir=_cxdirname($argv0);
        $bindir=$dir;
        $bindir =~ s%/lib$%/bin%;
    }
    $bindir =~ s%/(?:\./)+%/%g;
    $bindir =~ s%/\.$%%;
    $ENV{CX_ROOT}=_cxdirname($bindir);
    if ((!-x "$ENV{CX_ROOT}/bin/cxmenu" or !-f "$ENV{CX_ROOT}/bin/cxmenu") and
        $fallback)
    {
        $ENV{CX_ROOT}=$fallback;
    }
    if (!-x "$ENV{CX_ROOT}/bin/cxmenu" or !-f "$ENV{CX_ROOT}/bin/cxmenu")
    {
        my $name0=$0;
        $name0 =~ s+^.*/++;
        print STDERR "$name0:error: could not find CrossOver in '$ENV{CX_ROOT}'\n";
        exit 1;
    }
    return $ENV{CX_ROOT};
}

BEGIN {
    unshift @INC, locate_cx_root() . "/lib/perl";
}
use CXLog;
use CXUtils;


# Packaging helpers
my $package_version="18.5.0";

{
    package CXBDebian;
    use CXDebian;
    use base "CXDebian";

    sub new($$$)
    {
        my ($class, $buildroot, $installroot)=@_;
        my $self=CXDebian::new($class, $buildroot);
        $self->{installroot}=$installroot if ($self);
        return $self;
    }

    sub map_directory($$$)
    {
        my ($self, $root, $dir)=@_;
        return undef if ($dir eq "desktopdata");
        return "$self->{installroot}/$dir";
    }

    sub map_file($$$)
    {
        my ($self, $root, $file)=@_;
        return undef if ($file eq "files");
        return undef if ($self->{hardcode} and $file eq "cxbottle.conf");
        return $file if ($file =~ m%^/%);
        return "$self->{installroot}/$file";
    }
}

{
    package CXBRPM;
    use CXRPM;
    use base "CXRPM";

    sub map_directory($$$$)
    {
        my ($self, $root, $dir, $mode)=@_;
        $mode|=0055;

        return undef if ($dir eq "desktopdata");
        return ($dir, $mode);
    }

    sub map_file($$$$)
    {
        my ($self, $root, $file, $mode)=@_;

        # Setuid and setgid don't make sense for bottle files and
        # are dangerous. So remove them. Allow the sticky bit though.
        $mode=($mode & 01777) | ($mode & 0100 ? 0055 : 0044);

        return undef if ($file eq "files");
        return ($file, $mode);
    }
}

{
    package CXBSunpkg;
    use CXSunpkg;
    use base "CXSunpkg";

    sub package_directory($$$$)
    {
        my ($self, $root, $dir, $mode)=@_;

        return undef if ($dir =~ /^(?:desktopdata|drive_c)$/);
        $mode|=0055;
        return $mode;
    }

    sub package_file($$$$)
    {
        my ($self, $root, $file, $mode)=@_;

        return undef if ($file eq "files");
        # Setuid and setgid don't make sense for bottle files and
        # are dangerous. So remove them. Allow the sticky bit though.
        $mode=($mode & 01777) | ($mode & 0100 ? 0055 : 0044);
        return $mode;
    }
}

sub get_tmpdir(;$)
{
    my ($tmpdir)=@_;
    foreach my $dir ($tmpdir, $ENV{TMPDIR})
    {
        return $dir if (defined $dir and -d $dir and -w _);
    }
    return "/tmp";
}


# Process command-line options
my $opt_create;
my $opt_description;
my $opt_param;
my $opt_delete;
my $opt_install;
my $opt_uninstall;
my $opt_removeall;
my $opt_ro_desktopdata;
my $opt_tar;
my $opt_cpio;
my $opt_deb;
my $opt_rpm;
my $opt_sunpkg;
my $opt_sunzip;
my $opt_release;
my $opt_hardcode;
my $opt_packager;
my $opt_productid;
my $opt_rename;
my $opt_restore;
my $opt_restored;
my $opt_set_timestamps;
my $opt_new_uuid;
my $opt_set_uuid;
my $opt_get_uuid;
my $opt_copy;
my $opt_status;
my $opt_default;
my $opt_undefault;
my $opt_utf8;
my $opt_bottle;
my $opt_pattern;
my $opt_template;
my $opt_scope;
my $opt_force;
my $opt_verbose;
my $opt_help;
require CXOpts;
my $cxopts=CXOpts->new();
$cxopts->add_options(["create"        => \$opt_create,
                      "delete"        => \$opt_delete,
                      "install"       => \$opt_install,
                      "uninstall"     => \$opt_uninstall,
                      "removeall"     => \$opt_removeall,
                      "ro-desktopdata"=> \$opt_ro_desktopdata,
                      "tar=s"         => \$opt_tar,
                      "cpio=s"        => \$opt_cpio,
                      "deb"           => \$opt_deb,
                      "rpm"           => \$opt_rpm,
                      "sunpkg"        => \$opt_sunpkg,
                      "sunzip=s"      => \$opt_sunzip,
                      "release=s"     => \$opt_release,
                      "hardcode"      => \$opt_hardcode,
                      "packager=s"    => \$opt_packager,
                      "productid=s"   => \$opt_productid,
                      "rename=s"      => \$opt_rename,
                      "restore=s"     => \$opt_restore,
                      "restored"      => \$opt_restored,
                      "set-timestamps"=> \$opt_set_timestamps,
                      "new-uuid"      => \$opt_new_uuid,
                      "set-uuid=s"    => \$opt_set_uuid,
                      "get-uuid"      => \$opt_get_uuid,
                      "copy=s"        => \$opt_copy,
                      "status"        => \$opt_status,
                      "default"       => \$opt_default,
                      "undefault"     => \$opt_undefault,
                      "description=s" => \$opt_description,
                      "param=s@"      => \$opt_param,
                      "bottle=s"      => \$opt_bottle,
                      "pattern=s"     => \$opt_pattern,
                      "template=s"    => \$opt_template,
                      "scope=s"       => \$opt_scope,
                      "force"         => \$opt_force,
                      "verbose!"      => \$opt_verbose,
                      "?|h|help"      => \$opt_help
                     ]);
my $err=$cxopts->parse();
CXLog::fdopen(2) if ($opt_verbose);


# Validate the command line options
my $usage;
my $template_dir;
my ($only_removeall, $relax_wineprefix);
my $no_update;
if ($err)
{
    cxerr("$err\n");
    $usage=2;
}
elsif ($opt_help)
{
    $usage=0;
}
else
{
    if (!$opt_utf8)
    {
        # Re-encode the parameters to UTF-8
        require CXRecode;
        $opt_description=CXRecode::from_sys("UTF-8", $opt_description);
    }

    my $cmd_count=0;
    $cmd_count++ if (defined $opt_create);
    $cmd_count++ if (defined $opt_restore);
    $cmd_count++ if (defined $opt_restored);
    $cmd_count++ if (defined $opt_copy);
    $cmd_count++ if (defined $opt_status);
    if ($cmd_count > 1)
    {
        cxerr("--create, --restore, --copy, --restored and --status are mutually incompatible\n");
        $usage=2;
    }
    $cmd_count++ if (defined $opt_delete);
    $cmd_count++ if (defined $opt_removeall);
    $cmd_count++ if (defined $opt_set_timestamps);

    my $cmd_count_all=$cmd_count;
    $cmd_count_all++ if (defined $opt_new_uuid);
    $cmd_count_all++ if (defined $opt_set_uuid);
    $cmd_count_all++ if (defined $opt_get_uuid);
    $cmd_count_all++ if (defined $opt_install);
    $cmd_count_all++ if (defined $opt_uninstall);
    my $archive_count=0;
    $archive_count++ if (defined $opt_tar);
    $archive_count++ if (defined $opt_cpio);
    $archive_count++ if (defined $opt_deb);
    $archive_count++ if (defined $opt_rpm);
    $archive_count++ if (defined $opt_sunpkg);
    $cmd_count_all+=$archive_count;
    $cmd_count_all++ if (defined $opt_description);
    $cmd_count_all++ if (defined $opt_default);
    $cmd_count_all++ if (defined $opt_undefault);
    if ($opt_status and $cmd_count_all > 1)
    {
        cxerr("--status is incompatible with all other commands\n");
        $usage=2;
    }

    if ($opt_undefault and $cmd_count_all > 1)
    {
        cxerr("--undefault is incompatible with all other commands\n");
        $usage=2;
    }

    $only_removeall=1 if ($cmd_count_all == 1 and defined $opt_removeall);
    $relax_wineprefix=1 if ($cmd_count_all == $archive_count or $opt_status or $opt_get_uuid);
    if ($cmd_count_all == 0)
    {
        cxerr("you must specify the operation to perform\n");
        $usage=2;
    }
    elsif ($cmd_count_all == $cmd_count)
    {
        $no_update=1;
    }
    if (defined $opt_set_uuid)
    {
Loading ...