Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a check to the nature of the package #4

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
713a739
Start revamp, atm only take npf(s) and unwraps them
melis-m Jun 20, 2019
ea2baec
Add log functions (from nbuild + qlog)
melis-m Jun 20, 2019
22be1a1
Remove Kind enum
melis-m Jun 20, 2019
388406f
Add tarball/npf wrap function, no updates of the manifest.toml yet
melis-m Jun 20, 2019
fdb3be8
Remove args.{output,backup}, as they're not used yet
melis-m Jun 24, 2019
8c5ff82
Add function to refresh date of manifest wrap_date
melis-m Jun 24, 2019
4e39c71
Add log to data.tar.gz creation and manifest.toml
melis-m Jun 24, 2019
230cd2f
Add options to args to choose from fix/edit/diff
melis-m Jun 28, 2019
a90ad70
Add .gitignore
melis-m Jun 28, 2019
f2adf6e
Add .gitignore and definition of core.pushd
melis-m Jun 28, 2019
8409633
Add basis for checks
melis-m Jun 28, 2019
0c0740c
Add executable checks on shlibs/binaries
melis-m Jun 28, 2019
9ba0e49
Merge branch 'master' of github.com:raven-os/npf-checker into checks
melis-m Jul 5, 2019
02c7e30
npf-checker now only takes one .npf
melis-m Jul 17, 2019
d9d7e42
Add base class for checks modifying manifest.toml
melis-m Jul 17, 2019
0c4c80f
Fix utils.ask_yne default (when pressing enter directly)
melis-m Jul 17, 2019
3fdc2d5
Add some log.push and use of colored_path in tar creation logs
melis-m Jul 17, 2019
0599448
Reintroduce pkg to check_package, and to checks with manifest.toml
melis-m Jul 17, 2019
b8fe5f7
Add checks on manifest.toml's description
melis-m Jul 17, 2019
d82214b
Remove self.manifest{,path} from CheckWithManifest, now use self.pkg
melis-m Jul 17, 2019
fb7bff4
add correct caps formatting to default option to utils.ask_yne
melis-m Jul 17, 2019
2f4964a
Add check on pkg kind, and a bit more logs to other things
melis-m Jul 21, 2019
9624071
Add log when running DescCheck's run function
melis-m Jul 23, 2019
6444c74
Add spacing in the sentences of utils.ask_yn{,e}
melis-m Jul 23, 2019
67d7d8a
Rename nature to kind
melis-m Jul 23, 2019
f3cad7d
Fix pkg.show_manifest, version is now displayed properly
melis-m Jul 23, 2019
6532775
Refresh self.pkg.is_effective in CheckWithManifest after manual edit
melis-m Jul 26, 2019
6d63419
Add space after edit questions in pkg kind check
melis-m Jul 26, 2019
aebbcc2
Fix edit question in pkg kind check, when answer isn't 1 or 2
melis-m Jul 26, 2019
a87a832
Add /{,s}bin/ and /lib{,32,64}/ and /usr/lib/ to Exec Checks
melis-m Aug 12, 2019
75791b3
Add help section to --action argument
melis-m Aug 12, 2019
58afa1d
Merge branch 'master' of github.com:raven-os/npf-checker into checks
melis-m Sep 3, 2019
77655e4
Merge branch 'checks' into pkg_nature
melis-m Sep 3, 2019
a5c79e9
Move run message to run function, and add write_manifest after fix
melis-m Sep 3, 2019
cddd150
Remove duplicate log
melis-m Sep 3, 2019
e5670dc
Remove extra space in question during run
melis-m Sep 3, 2019
d931a1d
Rename 'nest file' to 'NPF'
melis-m Sep 22, 2019
982b7b8
Remove commented code
melis-m Sep 22, 2019
caca88d
Reformat indentation on one line
melis-m Sep 22, 2019
6593347
Merge branch 'master' of github.com:raven-os/npf-checker
melis-m Sep 22, 2019
e92ee19
Merge branch 'master' into pkg_nature
melis-m Sep 22, 2019
67eb5a1
Fix a typo in a variable definition
melis-m Sep 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/check.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import core.checks.executable as exe
import core.checks.syntax_check as stx
import core.checks.kind as kind
import core.checks.version_validity as version


def check_package(pkg):
exe.ExecCheck().run()
stx.DescriptionCheck(pkg).run()
kind.KindCheck(pkg).run()
version.VersionValidityCheck(pkg).run()
1 change: 1 addition & 0 deletions core/checks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(self, pkg, items):
def edit(self, item):
utils.open_editor(self.pkg.manifest_path)
self.pkg.manifest = toml.load(self.pkg.manifest_path)
self.pkg.is_effective = self.pkg.manifest['kind'] == 'effective'

def write_pkg_manifest(self):
with open(self.pkg.manifest_path, 'w') as filename:
Expand Down
60 changes: 60 additions & 0 deletions core/checks/kind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import os
import core.log as log
import core.checks.base as base
import core.checks.utils as utils


class KindCheck(base.CheckWithManifest):
def __init__(self, pkg):
super().__init__(pkg, [None])

def run(self):
log.s("Checking package kind")
super().run()

def validate(self, _):
length = len(os.listdir(self.pkg.cache))
return (self.pkg.is_effective and length != 1) \
or (not self.pkg.is_effective and length == 1)

def show(self, _):
if self.pkg.is_effective:
log.e("Package is effective but is missing a data.tar.gz")
else:
log.e("Package is virtual but has a data.tar.gz")

def diff(self, _):
target = 'virtual' if self.pkg.is_effective else 'effective'
log.i(f"Package kind would be changed to {target}")

def fix(self, _):
target = 'virtual' if self.pkg.is_effective else 'effective'
self.pkg.manifest['kind'] = target
self.pkg.is_effective = not self.pkg.is_effective
self.write_pkg_manifest()

def edit(self, _):
if self.pkg.is_effective:
ans = self._ask_1or2("Would you like to edit the manifest.toml (1) "
"or to add files to the package (2)? ")
if ans == 1:
super().edit(_)
elif ans == 2:
utils.open_shell(self.pkg.cache)
else:

ans = self._ask_1or2("Would you like to edit the manifest.toml (1) "
"or to remove the files from the package? (2) ")
if ans == 1:
super().edit(_)

@staticmethod
def _ask_1or2(question):
while True:
ans = log.q(question)
if ans == '1':
return 1
elif ans == '2':
return 2
else:
log.w("Only recognized answers are 1 and 2")
3 changes: 3 additions & 0 deletions core/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def wrap(self):
self.show_manifest()
if self.is_effective:
self.create_data_tar()
else:
log.i("Ignoring data.tar.gz creation phase because package is virtual")
self.create_nest_file()

def update_manifest_toml_wrap_date(self):
Expand Down Expand Up @@ -75,6 +77,7 @@ def create_nest_file(self):
os.remove('data.tar.gz')
new_path = f'{self.npf_path}.new'
os.rename(os.path.join(self.cache, new_nest_file_path), new_path)
log.s(f"New NPF is located at {new_path}")

def show_manifest(self):
m = self.manifest
Expand Down