Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Commit

Permalink
scripts: Add 'archive' script
Browse files Browse the repository at this point in the history
  • Loading branch information
jvirtanen committed Dec 6, 2020
1 parent 7ddf3b2 commit 0b0f9d4
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions scripts/archive
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
#
# Copyright 2020 Parity authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#
# This script generates a release archive based on the release manifest.
#
# Run this script as follows:
#
# ./scripts/archive parity-<version>.zip < ./scripts/archive.txt
#

import os.path
import sys
import zipfile

if len(sys.argv) != 2:
sys.exit('Usage: {} <filename>'.format(os.path.basename(sys.argv[0])))

filename = sys.argv[1]

filenames = [line.strip() for line in sys.stdin if not line.startswith('#')]

prefix, _ = os.path.splitext(filename)

with zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED) as outfile:
for filename in filenames:
try:
outfile.write(filename, os.path.join(prefix, filename))
except OSError as e:
sys.exit('error: {}: {}'.format(filename, e.strerror))

0 comments on commit 0b0f9d4

Please sign in to comment.