This commit is contained in:
Santosh D 2017-05-28 17:37:40 +02:00
commit 4ab785a978
12 changed files with 76 additions and 9 deletions

11
.travis.yml Normal file
View File

@ -0,0 +1,11 @@
language: "python"
python: "3.6"
addons:
apt:
sources:
- debian-sid
packages:
- shellcheck
install: "pip install flake8"
script: "test/static_code_analysis.sh"

12
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,12 @@
To contribute, please [fork](https://guides.github.com/activities/forking/) this repository, commit your changes and then make a [pull-request](https://guides.github.com/activities/forking/#making-a-pull-request).
If you have changed Python code, please make sure, that the testsuite runs through. Install `pytest`, then execute `pytest` inside the `pmbootstrap` folder.
Additionally, the [static code analyis script](https://github.com/postmarketOS/pmbootstrap/blob/master/test/static_code_analysis.sh) must run through. Install `shellcheck` and `flake8`, then run:
```
test/static_code_analysis.sh
```
*(As of now, Travis CI can only do the static code analysis. Running the testsuite automatically is planned.)*
**If you need any help, don't hesitate to open an [issue](https://github.com/postmarketOS/pmbootstrap/issues) and ask!**

View File

@ -2,13 +2,17 @@
Sophisticated chroot/build/flash tool to develop and install [postmarketOS](https://ollieparanoid.github.io/post/postmarketOS).
[Static code analysis](https://github.com/postmarketOS/pmbootstrap/blob/master/test/static_code_analysis.sh) status: [![travis badge](https://api.travis-ci.org/postmarketOS/pmbootstrap.png?branch=master)](https://travis-ci.org/postmarketOS/pmbootstrap)
## Requirements
* GNU/Linux
* Python 3
* openssh
* OpenSSL
## Usage
**Check out the [porting guide](https://github.com/postmarketOS/pmbootstrap/wiki/Porting-to-a-new-device) for a practical start!**
Run `./pmbootstrap.py init` first, to select a target device and the work folder, which will contain all the chroots and other data.
After that, you can run any command. All dependencies (e.g. chroots) will be installed automatically, if they are not available yet.
@ -42,3 +46,4 @@ Format and partition the SD card `/dev/mmcblk0`, and put a full postmarketOS ins
## Testsuite
Simply install `pytest` (via your package manager or via pip) and run it inside the pmbootstrap folder.

View File

@ -16,7 +16,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
import urllib.request
import os
import logging
import shutil
@ -158,7 +157,6 @@ def init(args):
"""
Download, verify, extract $WORK/apk.static.
"""
base_url = args.mirror_alpine + "edge/main/" + args.arch_native
apkindex = download(args, "APKINDEX.tar.gz")
index_data = pmb.parse.apkindex.read(args, "apk-tools-static", apkindex)
version = index_data["version"]

View File

@ -16,6 +16,8 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
def replace(path, old, new):
text = ""
with open(path, 'r') as handle:

45
test/static_code_analysis.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/sh
# Copyright 2017 Oliver Smith
#
# This file is part of pmbootstrap.
#
# pmbootstrap is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pmbootstrap is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
set -e
DIR="$(cd "$(dirname "$0")" && pwd -P)"
cd "$DIR"/..
# Shell: shellcheck
sh_files="test/static_code_analysis.sh"
echo "Test $sh_files with shellcheck..."
for file in ${sh_files}; do
shellcheck "${file}"
done
# Python: flake8
# E501: max line length
# F401: imported, but not used, does not make sense in __init__ files
# E402: module import not on top of file, not possible for testcases
echo "Test *.py files with flake8..."
echo "NOTE: Run 'autopep8 -ria $PWD' to fix code style issues"
py_files="$(find . -name '*.py')"
_ignores="E501,E402"
# shellcheck disable=SC2086
flake8 --exclude=__init__.py --ignore "$_ignores" $py_files
# shellcheck disable=SC2086
flake8 --filename=__init__.py --ignore "F401,$_ignores" $py_files
# Done
echo "Success!"

View File

@ -16,7 +16,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
#!/usr/bin/env python3
import os
import sys
import tarfile

View File

@ -16,7 +16,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
#!/usr/bin/env python3
import os
import sys
import pytest

View File

@ -16,7 +16,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
#!/usr/bin/env python3
import os
import sys
import pytest

View File

@ -16,7 +16,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
#!/usr/bin/env python3
import os
import sys
import pytest

View File

@ -16,7 +16,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
#!/usr/bin/env python3
import os
import sys
import pytest

View File

@ -16,7 +16,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
#!/usr/bin/env python3
import os
import sys
import pytest