#!/usr/bin/env perl use strict; use Carp; use warnings; sub Main { my $ProgName = $0; my $str; my $WP = $ENV {'WINEPREFIX'}; $WP = "" unless defined $WP; $WP =~ s@\s+\z@@s; my $HOME = $ENV {'HOME'}; $HOME = "" unless defined $HOME; $HOME =~ s@\s+\z@@s; $ENV {'HOME' } = $HOME; die unless length ($HOME) && -d $HOME; my $BOOTARCH = $ENV {'BOOTARCH'}; $BOOTARCH = "" unless defined $BOOTARCH; $BOOTARCH =~ s@\s+\z@@s; die unless length ($BOOTARCH); my $PATH = $ENV {'PATH'}; $PATH = "" unless defined $PATH; $PATH =~ s@\s+\z@@s; $PATH =~ s@:+\z@@; die unless length ($PATH); my $BITS = 32; $BITS = $1 if $WP =~ m@(32|64)\z@; for my $arg (@ARGV) { next unless $arg =~ m@\.exe\z@i; next unless -f $arg; $str = `file "$arg" 2>&1`; $str = "" unless defined $str; $str =~ s@\s+\z@@s; $BITS = ($str =~ m@x86.64@i) ? 64 : 32; } $WP = "$HOME/.wine$BITS" unless length $WP; die "Error: WINEPREFIX setting must end in 32 or 64\n" unless $WP =~ s@(32|64)\z@$BITS@; $ENV {'WINEPREFIX'} = $WP; my $BINPREFIX = "/glibc$BITS/pkg/wine$BITS"; my $WINEBIN = "$BINPREFIX/bin/wine$BITS"; $WINEBIN =~ s@32\z@@; die "Error: $WINEBIN hasn't been built\n" unless -f $WINEBIN; $PATH = "$BINPREFIX/bin:$PATH"; $ENV {'PATH'} = $PATH; if (($BOOTARCH =~ m@32\z@) && ($BINPREFIX =~ m@64\z@)) { die "Error: Can't run 64-bit WINE from a 32-bit distro\n"; } exec $WINEBIN, @ARGV; } &Main();