Skip to content

Commit

Permalink
Add README example and update ini generator to use argparse
Browse files Browse the repository at this point in the history
  • Loading branch information
Eloston committed Mar 13, 2018
1 parent c46bdbb commit 9d01cb8
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 28 deletions.
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ When creating new pages or adding new versions, use an existing version as a tem
Prerequisites:
* [Python-Markdown](//github.com/waylan/Python-Markdown) for `site_generator.py`

Steps to publish new binaries to the website:
#### Steps

Steps to publish a new binary. An example of these steps is in the next section.

1. Fork the main binaries repository ([ungoogled-software/ungoogled-chromium-binaries](//github.com/ungoogled-software/ungoogled-chromium-binaries))
* If this has been done before, pull in new changes from this one if necessary.
Expand All @@ -32,6 +34,36 @@ Notes:
* `platform_ini_generator.py` is currently restricted to generating INI files with URLs to binaries in GitHub releases. If binaries are uploaded elsewhere, then the INI must be created by other means.
* Additional changes can be made to the website configuration before step 5 as necessary.

#### Example

Example command-line steps (with comments, denoted by a hash `#` symbol). Replace `YOURNAME` in the steps with your GitHub username.

**First-time setup**:

```
# In GitHub, fork ungoogled-software/ungoogled-chromium-binaries to YOURNAME/ungoogled-chromium-binaries
git clone https://github.com/YOURNAME/ungoogled-chromium-binaries.git
cd ungoogled-chromium-binaries
git remote add upstream https://github.com/ungoogled-software/ungoogled-chromium-binaries.git
```

**Publish binaries**:

This example demonstrates publishing Debian 9 (stretch) amd64 packages located in `/path/to/binaries/` for ungoogled-chromium version `99.0.1234.567-1`:

```
# In GitHub, create a new Release on YOURNAME/ungoogled-chromium-binaries with a name "99.0.1234.567-1" (without quotes) and a new tag "99.0.1234.567-1" (without quotes; insert it into the tag field). Upload all necessary files from /path/to/binaries/ into the Release.
cd ungoogled-chromium-binaries # The same as the one setup above
git pull
# Edit config/valid_versions and add "99.0.1234.567-1" (without quotes) only if it does NOT exist.
./utilities/platform_ini_generator.py 99.0.1234.567-1 YOURNAME /path/to/binaries/*.deb /path/to/binaries/*.changes /path/to/binaries/*.buildinfo > config/platforms/debian/stretch_amd64/99.0.1234.567-1.ini
./utilities/site_generator.py
git add *
git commit -m 'Add 99.0.1234.567-1 binaries for Debian stretch amd64'
git push origin master
# In GitHub, create a pull request in ungoogled-software/ungoogled-chromium-binaries with the new change in YOURNAME/ungoogled-chromium-binaries
```

## External resources

* [github-markdown-css](//github.com/sindresorhus/github-markdown-css)
Expand Down
49 changes: 22 additions & 27 deletions utilities/platform_ini_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
# found in the LICENSE file.

'''
This script takes in files and generates a platform ini as if they were uploaded to the Releases page
This script takes in files and generates a platform ini as if they were uploaded to the Releases page.
Output is to stdout, so consider redirecting the output to a file
'''

import sys
import argparse
import pathlib
import hashlib
import collections
Expand Down Expand Up @@ -89,33 +89,28 @@ def add_download(self, filepath):
self._downloads[filepath.name][algorithm] = hasher.hexdigest()
fileobj.seek(0)

def print_usage_info():
print("\n".join([
"Arguments: tag_name github_username file_path [file_path [...]]",
"",
"This script outputs an INI file to standard output containing hashes and links to files as if they were uploaded to a GitHub Release.",
"The files that are passed in are read to generate hashes. Also, their file names are assumed to be identical in the GitHub Release.",
"This script *cannot* be used to generate non-GitHub Release file URLs.",
"",
"Argument descriptions:",
"tag_name is the name of the tag used in the GitHub Release.",
"github_username is your username that contains the ungoogled-chromium-binaries fork.",
"file_path are one or more paths to local files with the same name as the ones in the GitHub Release."
]), file=sys.stderr)

def main(args):
print(args, file=sys.stderr)
if args[0] == "--help" or args[0] == "-h" or args[0] == "help":
print_usage_info()
return 0
args_parser = iter(args)
current_version = next(args_parser)
username = next(args_parser)
DownloadsManager.set_params(username, _REPOSITORY_NAME, current_version)
for filename in args_parser:
def main(arg_list=None):
"""
This script outputs an INI file to standard output containing hashes and links to files as if they were uploaded to a GitHub Release.
The files that are passed in are read to generate hashes. Also, their file names are assumed to be identical in the GitHub Release.
This script *cannot* be used to generate non-GitHub Release file URLs.
"""
parser = argparse.ArgumentParser(description=main.__doc__)
parser.add_argument('tag_name', help='Name of the tag used in the GitHub Release')
parser.add_argument(
'github_username',
help='GitHub username containing the fork of ungoogled-chromium-binaries')
parser.add_argument(
'file_path', nargs='+',
help=('One or more paths to local files with the same name as the ones '
'in the GitHub Release.'))
args = parser.parse_args(args=arg_list)
DownloadsManager.set_params(
args.github_username, _REPOSITORY_NAME, args.tag_name)
for filename in args.file_path:
DownloadsManager.add_download(pathlib.Path(filename))
print(DownloadsManager.to_ini())
return 0

if __name__ == "__main__":
exit(main(sys.argv[1:]))
exit(main())

0 comments on commit 9d01cb8

Please sign in to comment.