diff --git a/HACKING.md b/HACKING.md index 99bd25ed7..dbb8ee1e6 100644 --- a/HACKING.md +++ b/HACKING.md @@ -83,6 +83,29 @@ development environment inside a systemd-nspawn container. host$ ./container ssh ``` +6. The default distribution used by the container script is "testing", but you + can choose a different distribution (e.g. "stable") in two ways. + + 1. Using an environment variable. + + ```bash + host$ DISTRIBUTION=stable ./container up + host$ DISTRIBUTION=stable ./container ssh + ``` + + ```bash + host$ export DISTRIBUTION=stable + host$ ./container up + host$ ./container ssh + ``` + + 2. Using the `--distribution` option for each command. + + ```bash + host$ ./container up --distribution=stable + host$ ./container ssh --distribution=stable + ``` + #### Using after Setup After logging into the container, the source code is available in `/freedombox` diff --git a/container b/container index c02f13766..bad1aa60c 100755 --- a/container +++ b/container @@ -261,10 +261,16 @@ def parse_arguments(): distributions = list(URLS.keys()) + distribution = os.environ.get('DISTRIBUTION') + + default_distribution = 'testing' + if distribution and distribution in distributions: + default_distribution = distribution + # Up subparser = subparsers.add_parser('up', help='Bring up the container') subparser.add_argument( - '--distribution', choices=distributions, default='testing', + '--distribution', choices=distributions, default=default_distribution, help='Distribution of the image to download and setup') subparser.add_argument('--image-size', default='16G', help='Disk image size to resize to after download') @@ -273,20 +279,20 @@ def parse_arguments(): subparser = subparsers.add_parser( 'ip', help='Print the IP address of the container.') subparser.add_argument( - '--distribution', choices=distributions, default='testing', + '--distribution', choices=distributions, default=default_distribution, help='Distribution of the container to print IP address') # ssh subparser = subparsers.add_parser('ssh', help='SSH into the container') subparser.add_argument('--distribution', choices=distributions, - default='testing', + default=default_distribution, help='Distribution of the container to SSH into') # Run tests subparser = subparsers.add_parser('run-tests', help='Run tests in the container') subparser.add_argument('--distribution', choices=distributions, - default='testing', + default=default_distribution, help='Distribution of the container to run tests') subparser.add_argument( '--pytest-args', nargs='...', @@ -295,21 +301,21 @@ def parse_arguments(): # Stop subparser = subparsers.add_parser('stop', help='Stop the container') subparser.add_argument('--distribution', choices=distributions, - default='testing', + default=default_distribution, help='Distribution of the container to stop') # Destroy subparser = subparsers.add_parser('destroy', help='Destroy the container image') subparser.add_argument('--distribution', choices=distributions, - default='testing', + default=default_distribution, help='Distribution of the image to delete') # Update subparser = subparsers.add_parser( 'update', help='Update the container image to the latest version') subparser.add_argument('--distribution', choices=distributions, - default='testing', + default=default_distribution, help='Distribution of the image to update') return parser.parse_args()