mirror of
https://github.com/freedoom/freedoom.git
synced 2025-09-02 07:25:45 -04:00
Convert makepkgs script to Python.
This commit is contained in:
parent
a1511aac95
commit
5abf2dccfe
1 changed files with 66 additions and 42 deletions
108
makepkgs
108
makepkgs
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env perl
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||||
# Contributors to the Freedoom project. All rights reserved.
|
# Contributors to the Freedoom project. All rights reserved.
|
||||||
#
|
#
|
||||||
|
@ -27,59 +28,82 @@
|
||||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
use strict;
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
sub cmd
|
# Documentation files included with distributions.
|
||||||
{
|
|
||||||
my ($cmd) = @_;
|
|
||||||
|
|
||||||
print "$cmd\n";
|
DIST_DOCS = [
|
||||||
`$cmd`;
|
"NEWS",
|
||||||
|
"ChangeLog",
|
||||||
|
"COPYING",
|
||||||
|
"CREDITS",
|
||||||
|
"README"
|
||||||
|
]
|
||||||
|
|
||||||
|
# Most WADs are given a ZIP equal to their name, but some have different
|
||||||
|
# names:
|
||||||
|
|
||||||
|
DIR_NAMES = {
|
||||||
|
'doom2' : 'freedoom-iwad',
|
||||||
|
'doom1' : 'freedoom-demo',
|
||||||
|
'doom' : 'freedoom-episodes',
|
||||||
|
'freedoom' : 'freedoom-resource-wad',
|
||||||
}
|
}
|
||||||
|
|
||||||
my $version = $ENV{'VERSION'};
|
# Run a command, displaying it before executing it.
|
||||||
|
|
||||||
foreach (@ARGV) {
|
def run_command(command):
|
||||||
my $file = $_;
|
print "> " + command
|
||||||
die if $file !~ /(.*)\/([^\/]*)\.wad$/;
|
os.system(command)
|
||||||
|
|
||||||
my ($path, $pkgname) = ($1, $2);
|
# Find the version to build:
|
||||||
|
|
||||||
my %dirnames = (
|
version = os.getenv("VERSION")
|
||||||
'doom2' => 'freedoom-iwad',
|
|
||||||
'doom1' => 'freedoom-demo',
|
|
||||||
'freedoom' => 'freedoom-resource-wad',
|
|
||||||
);
|
|
||||||
|
|
||||||
my $basedir;
|
if version is None:
|
||||||
|
raise Exception("Version not specified for release!")
|
||||||
|
|
||||||
if ($dirnames{$pkgname}) {
|
# Build all of the packages
|
||||||
$basedir = $dirnames{$pkgname};
|
|
||||||
} else {
|
|
||||||
$basedir = $pkgname;
|
|
||||||
}
|
|
||||||
|
|
||||||
$basedir .= "-$version";
|
for filename in sys.argv[1:]:
|
||||||
$basedir =~ tr/_/-/;
|
|
||||||
|
|
||||||
my $fulldir = "$path/$basedir";
|
|
||||||
|
|
||||||
# mkdir($dir);
|
path = os.path.dirname(filename)
|
||||||
# `cp NEWS ChangeLog COPYING CREDITS $dir`;
|
basename = os.path.basename(filename)
|
||||||
# `cp $file $dir`;
|
|
||||||
|
|
||||||
cmd("mkdir $fulldir");
|
# Cut off the extension, and build the directory name
|
||||||
cmd("cp NEWS ChangeLog COPYING CREDITS $fulldir");
|
|
||||||
cmd("cp README $fulldir/README");
|
|
||||||
cmd("cp $file $fulldir\n");
|
|
||||||
|
|
||||||
my $cwd = `pwd`;
|
pkgname = basename[0:-4]
|
||||||
chomp $cwd;
|
|
||||||
|
|
||||||
chdir($path);
|
if pkgname in DIR_NAMES:
|
||||||
cmd("rm -f $basedir.zip");
|
base_dir = DIR_NAMES[pkgname]
|
||||||
cmd("zip -r $basedir.zip $basedir");
|
else:
|
||||||
cmd("rm -rf $basedir");
|
base_dir = pkgname
|
||||||
chdir($cwd);
|
|
||||||
}
|
# Append the version:
|
||||||
|
|
||||||
|
base_dir += "-" + version
|
||||||
|
|
||||||
|
# Replace underscores with hyphens:
|
||||||
|
|
||||||
|
base_dir = base_dir.replace("_", "-")
|
||||||
|
|
||||||
|
full_path = path + "/" + base_dir
|
||||||
|
|
||||||
|
# Create directory, and add files.
|
||||||
|
|
||||||
|
run_command("mkdir %s" % full_path)
|
||||||
|
|
||||||
|
for doc in DIST_DOCS + [ filename ]:
|
||||||
|
run_command("cp %s %s" % (doc, full_path))
|
||||||
|
|
||||||
|
# Change to the parent directory, and build the zip
|
||||||
|
|
||||||
|
orig_dir = os.getcwd()
|
||||||
|
|
||||||
|
os.chdir(path)
|
||||||
|
run_command("rm -f %s.zip" % base_dir)
|
||||||
|
run_command("zip -r %s.zip %s" % (base_dir, base_dir))
|
||||||
|
run_command("rm -rf %s" % base_dir)
|
||||||
|
os.chdir(orig_dir)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue