#!/usr/bin/env perl use File::Find; use File::Spec; use strict; use warnings; my $file = shift @ARGV or die 'Missing required argument'; die "Extra arguments: @ARGV" if @ARGV; if (-d $file) { my $game = uc ($file); # Rename to uppercase for no reason finddepth ({no_chdir => 1, wanted => sub { use Data::Dumper; my @comp = File::Spec->splitdir($File::Find::name); $comp[$#comp] = uc $comp[$#comp]; rename ($File::Find::name, File::Spec->join(@comp)) or die `pwd`." $! $File::Find::name"; }}, $file); # Pack it up $file = "$game.tar.lzma"; system ("tar cf - $game |lzma -c -9 >$file") and die; } $file =~ /^([^\.]*)/ or die; my $game = $1; my $pkgname = lc $game; # Determine the exe file $_ = $file; my $compress = /\.lzma$/ ? 'lzma -d' : (/\.gz$/ ? 'gzip -d' : (/\.bz(2)?$/ ? "bzip$1 -d" : 'cat')); my $exefile; foreach (split ("\n", `$compress <$file |tar tf -`)) { last if $exefile and $exefile =~ /$game.exe/i; /\.exe/i and $exefile = $_; }; # Create a wrapper script my ($exedir, $exebase) = File::Spec->splitdir($exefile); $exefile =~ s/\//\\/g; open (my $wrapper, ">$pkgname"); print $wrapper "#!/bin/sh\n"; print $wrapper 'exec /usr/bin/dosbox -c "$(echo -e "MOUNT C: /usr/games/dos\nC:\nCD '. $exedir.'\n'.$exebase.' $*\nEXIT")"'; close $wrapper; open (my $desktop, ">$pkgname.desktop"); # Create a desktop entry print $desktop <'); chomp $banner; open (my $spec, ">$pkgname.spec"); print $spec <