Skip to content

Commit

Permalink
Added gpg picker
Browse files Browse the repository at this point in the history
  • Loading branch information
clayrisser committed Jun 1, 2018
1 parent 1b7b9cf commit 4c202d5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.2.4] - 2018-06-01
### Added
* gpg key picker

## [0.2.3] - 2018-06-01
### Added
* modify initrd filesystem
Expand Down
31 changes: 24 additions & 7 deletions forkbuntu/services/gpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pydash import _
from subprocess import check_output, CalledProcessError, STDOUT
import glob
import inquirer
import json
import os
import re
Expand Down Expand Up @@ -58,13 +59,7 @@ def build_keyring(self):
keyrings_path = path.join(ubuntu_keyring_path, 'keyrings')
os.chdir(keyrings_path)
s.util.subproc('gpg --import < ' + path.join(keyrings_path, 'ubuntu-archive-keyring.gpg'))
gpg_key = None
if len(self.app.gpg_keys) == 1:
gpg_key = self.app.gpg_keys[0]
elif len(self.app.gpg_keys) > 1:
gpg_key = self.app.gpg_keys[0]
if not gpg_key:
raise Exception('failed to find gpg key')
gpg_key = self.get_key()
s.util.subproc(
'gpg --export ' + ' '.join(self.ubuntu_keys) + ' '
+ gpg_key.pub.key.short + ' > ' + path.join(keyrings_path, 'ubuntu-archive-keyring.gpg')
Expand Down Expand Up @@ -167,6 +162,28 @@ def get_keys(self, include_ubuntu_keys=False, trying_again=False):
return self.get_keys(trying_again=True)
return keys

def get_key(self):
c = self.app.conf
spinner = self.app.spinner
gpg_keys = self.app.gpg_keys
gpg_key = None
if len(gpg_keys) == 1:
gpg_key = gpg_keys[0]
elif len(gpg_keys) > 1:
spinner.stop()
answer = munchify(inquirer.prompt([
inquirer.List(
'gpg_key',
message='choose a gpg key',
choices=_.map(gpg_keys, lambda x: x.pub.key.short + ': ' + x.name + ' <' + x.email + '>')
)
])).gpg_key
spinner.start()
gpg_key = _.find(gpg_keys, lambda x: x.pub.key.short == answer[:answer.index(':')])
if not gpg_key:
raise Exception('failed to find gpg key')
return gpg_key

def __chmod_gpg(self):
s = self.app.services
user = s.util.get_real_user()
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
backports.shutil-get-terminal-size==1.0.0
blessings==1.6.1
cement==2.10.12
cfoundation==0.2.1
checksum==1.0.2
Expand All @@ -7,12 +8,14 @@ colorama==0.3.9
cursor==1.2.0
enum34==1.1.6
halo==0.0.12
inquirer==2.2.0
Jinja2==2.10
log-symbols==0.0.11
MarkupSafe==1.0
munch==2.3.2
pydash==4.5.0
PyYAML==3.12
readchar==0.7
six==1.11.0
spinners==0.0.19
termcolor==1.1.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
setup(
name='forkbuntu',

version='0.2.3',
version='0.2.4',

description='Easily create your own ubuntu distribution and install cd',

Expand Down

0 comments on commit 4c202d5

Please sign in to comment.