fceux/pipelines/debpkg.pl

122 lines
2.8 KiB
Perl
Raw Normal View History

2020-05-16 00:12:21 +00:00
#!/usr/bin/perl
use strict;
my $VERSION="2.6.0";
2020-05-16 00:12:21 +00:00
my $INSTALL_PREFIX="/tmp/fceux";
my $CTL_FILENAME="$INSTALL_PREFIX/DEBIAN/control";
my $ARCH="amd64";
my $PKG_OUTPUT_FILE="fceux-$VERSION-$ARCH.deb";
2020-05-16 00:12:21 +00:00
2020-05-16 01:27:17 +00:00
# Start by auto figuring out dependencies of the executable.
# the rest of the package creation is trival.
my $SO_LIST="";
$SO_LIST=`objdump -x $INSTALL_PREFIX/usr/bin/fceux`;
2021-04-12 00:34:43 +00:00
#$SO_LIST= $SO_LIST . `objdump -x $INSTALL_PREFIX/usr/bin/fceux-gtk`;
2020-05-16 00:12:21 +00:00
#print "$SO_LIST";
my $i; my $j; my $k; my $pkg;
2020-05-16 00:12:21 +00:00
my @fd = split /\n/, $SO_LIST;
my @libls;
$#libls=0;
for ($i=0; $i<=$#fd; $i++)
{
#$fd[$i] =~ s/^\s+//;
#print "$fd[$i]\n";
if ( $fd[$i] =~ m/NEEDED\s+(.*)/ )
{
#print "$1 \n";
$libls[$#libls] = $1; $#libls++;
}
}
my %pkghash; my $pkgsearch;
my @pkglist; my @pkgdeps;
my $pkg; my $filepath;
2020-05-16 00:12:21 +00:00
$#pkgdeps=0;
2020-05-16 00:12:21 +00:00
for ($i=0; $i<$#libls; $i++)
{
$pkgsearch=`dpkg-query -S $libls[$i]`;
@pkglist = split /\n/, $pkgsearch;
for ($j=0; $j<=$#pkglist; $j++)
2020-05-16 00:12:21 +00:00
{
#$pkghash{$pkg} = 1;
#print " $libls[$i] '$pkglist[$j]' \n";
2020-05-16 00:12:21 +00:00
if ( $pkglist[$j] =~ m/(.*):$ARCH:\s+(.*)/ )
2020-05-16 00:12:21 +00:00
{
$pkg = $1;
$filepath = $2;
$filepath =~ s/^.*\///;
if ( $libls[$i] eq $filepath )
{
#print "PKG: '$pkg' '$libls[$i]' == '$filepath' \n";
# Don't put duplicate entries into the pkg depend list.
if ( !defined( $pkghash{$pkg} ) )
{
$pkgdeps[ $#pkgdeps ] = $pkg; $#pkgdeps++;
$pkghash{$pkg} = 1;
}
}
2020-05-16 00:12:21 +00:00
}
}
}
#
#
system("mkdir -p $INSTALL_PREFIX/DEBIAN");
open CTL, ">$CTL_FILENAME" or die "Error: Could not open file '$CTL_FILENAME'\n";
#
print CTL "Package: fceux\n";
print CTL "Version: $VERSION\n";
print CTL "Section: games\n";
print CTL "Priority: extra\n";
print CTL "Architecture: $ARCH\n";
print CTL "Homepage: http://fceux.com/\n";
print CTL "Essential: no\n";
#print CTL "Installed-Size: 1024\n";
print CTL "Maintainer: mjbudd77\n";
print CTL "Description: fceux is an emulator of the original (8-bit) Nintendo Entertainment System (NES)\n";
print CTL "Depends: $pkgdeps[0]";
for ($i=1; $i<$#pkgdeps; $i++)
{
print CTL ", $pkgdeps[$i]";
}
print CTL "\n";
2020-05-16 00:12:21 +00:00
close CTL;
#system("cat $CTL_FILENAME");
2020-05-16 00:12:21 +00:00
#
chdir "/tmp";
system("dpkg-deb --build fceux ");
if ( !(-e "/tmp/fceux.deb") )
{
die "Error: Failed to create package $PKG_OUTPUT_FILE\n";
}
system("mv fceux.deb $PKG_OUTPUT_FILE");
system("dpkg-deb -I $PKG_OUTPUT_FILE");
2020-05-16 00:12:21 +00:00
#
if ( -e "/tmp/$PKG_OUTPUT_FILE" )
{
print "**********************************************\n";
print "Created deb package: /tmp/$PKG_OUTPUT_FILE\n";
print "**********************************************\n";
}
else
{
die "Error: Failed to create package $PKG_OUTPUT_FILE\n";
}