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

Implement using deb822 format in source application add command #457

Merged
merged 14 commits into from
Jan 10, 2024
121 changes: 94 additions & 27 deletions docs/Manifest Parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -918,10 +918,10 @@ The query command can be used to gather information about the system and the Vis
| `<type></type>` | `<type>source</type>` | R | |
| `<applicationSource>` | `<applicationSource>` | R | |
| `<add>` | `<add>` | R | |
| `<gpg>` | `<gpg>` | R | |
| `<uri></uri>` | `<uri>https://dl-ssl.google.com/linux/linux_signing_key.pub</uri>` | R | |
| `<keyname></keyname>` | `<keyname>google-chrome.gpg</keyname>` | R | |
| `</gpg>` | `</gpg>` | R | |
| `<gpg>` | `<gpg>` | O | |
| `<uri></uri>` | `<uri>https://dl-ssl.google.com/linux/linux_signing_key.pub</uri>` | O | |
| `<keyname></keyname>` | `<keyname>google-chrome.gpg</keyname>` | O | |
| `</gpg>` | `</gpg>` | O | |
| `<repo>` | `<repo>` | R | |
| `<repos>` | `<repos>` | R | |
| `<source_pkg>` | `<source_pkg>deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main</source_pkg>` | R | |
Expand All @@ -935,7 +935,7 @@ The query command can be used to gather information about the system and the Vis



#### Source application add Manifest Example
#### Source Application Add Manifest Example using remote GPG key
```xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
Expand All @@ -958,6 +958,59 @@ The query command can be used to gather information about the system and the Vis
</manifest>
```

#### Source Application Add Manifest Example (deb822 format)
```xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<type>source</type>
<applicationSource>
<repo>
<repos>
<source_pkg>Enabled: yes</source_pkg>
<source_pkg>Types: deb</source_pkg>
<source_pkg>URIs: http://dl.google.com/linux/chrome/deb/</source_pkg>
<source_pkg>Suites: stable</source_pkg>
<source_pkg>Components: main</source_pkg>
<source_pkg>Signed-By:</source_pkg>
<source_pkg> -----BEGIN PGP PUBLIC KEY BLOCK-----</source_pkg>
<source_pkg> Version: GnuPG v1.4.2.2 (GNU/Linux)</source_pkg>
<source_pkg> .</source_pkg>
<source_pkg> mQGiBEXwb0YRBADQva2NLpYXxgjNkbuP0LnPoEXruGmvi3XMIxjEUFuGNCP4Rj/a</source_pkg>
<source_pkg> kv2E5VixBP1vcQFDRJ+p1puh8NU0XERlhpyZrVMzzS/RdWdyXf7E5S8oqNXsoD1z</source_pkg>
<source_pkg> fvmI+i9b2EhHAA19Kgw7ifV8vMa4tkwslEmcTiwiw8lyUl28Wh4Et8SxzwCggDcA</source_pkg>
<source_pkg> feGqtn3PP5YAdD0km4S4XeMEAJjlrqPoPv2Gf//tfznY2UyS9PUqFCPLHgFLe80u</source_pkg>
<source_pkg> QhI2U5jt6jUKN4fHauvR6z3seSAsh1YyzyZCKxJFEKXCCqnrFSoh4WSJsbFNc4PN</source_pkg>
<source_pkg> b0V0SqiTCkWADZyLT5wll8sWuQ5ylTf3z1ENoHf+G3um3/wk/+xmEHvj9HCTBEXP</source_pkg>
<source_pkg> 78X0A/0Tqlhc2RBnEf+AqxWvM8sk8LzJI/XGjwBvKfXe+l3rnSR2kEAvGzj5Sg0X</source_pkg>
<source_pkg> 4XmfTg4Jl8BNjWyvm2Wmjfet41LPmYJKsux3g0b8yzQxeOA4pQKKAU3Z4+rgzGmf</source_pkg>
<source_pkg> HdwCG5MNT2A5XxD/eDd+L4fRx0HbFkIQoAi1J3YWQSiTk15fw7RMR29vZ2xlLCBJ</source_pkg>
<source_pkg> bmMuIExpbnV4IFBhY2thZ2UgU2lnbmluZyBLZXkgPGxpbnV4LXBhY2thZ2VzLWtl</source_pkg>
<source_pkg> eW1hc3RlckBnb29nbGUuY29tPohjBBMRAgAjAhsDBgsJCAcDAgQVAggDBBYCAwEC</source_pkg>
<source_pkg> HgECF4AFAkYVdn8CGQEACgkQoECDD3+sWZHKSgCfdq3HtNYJLv+XZleb6HN4zOcF</source_pkg>
<source_pkg> AJEAniSFbuv8V5FSHxeRimHx25671az+uQINBEXwb0sQCACuA8HT2nr+FM5y/kzI</source_pkg>
<source_pkg> A51ZcC46KFtIDgjQJ31Q3OrkYP8LbxOpKMRIzvOZrsjOlFmDVqitiVc7qj3lYp6U</source_pkg>
<source_pkg> rgNVaFv6Qu4bo2/ctjNHDDBdv6nufmusJUWq/9TwieepM/cwnXd+HMxu1XBKRVk9</source_pkg>
<source_pkg> XyAZ9SvfcW4EtxVgysI+XlptKFa5JCqFM3qJllVohMmr7lMwO8+sxTWTXqxsptJo</source_pkg>
<source_pkg> pZeKz+UBEEqPyw7CUIVYGC9ENEtIMFvAvPqnhj1GS96REMpry+5s9WKuLEaclWpd</source_pkg>
<source_pkg> K3krttbDlY1NaeQUCRvBYZ8iAG9YSLHUHMTuI2oea07Rh4dtIAqPwAX8xn36JAYG</source_pkg>
<source_pkg> 2vgLAAMFB/wKqaycjWAZwIe98Yt0qHsdkpmIbarD9fGiA6kfkK/UxjL/k7tmS4Vm</source_pkg>
<source_pkg> CljrrDZkPSQ/19mpdRcGXtb0NI9+nyM5trweTvtPw+HPkDiJlTaiCcx+izg79Fj9</source_pkg>
<source_pkg> KcofuNb3lPdXZb9tzf5oDnmm/B+4vkeTuEZJ//IFty8cmvCpzvY+DAz1Vo9rA+Zn</source_pkg>
<source_pkg> cpWY1n6z6oSS9AsyT/IFlWWBZZ17SpMHu+h4Bxy62+AbPHKGSujEGQhWq8ZRoJAT</source_pkg>
<source_pkg> G0KSObnmZ7FwFWu1e9XFoUCt0bSjiJWTIyaObMrWu/LvJ3e9I87HseSJStfw6fki</source_pkg>
<source_pkg> 5og9qFEkMrIrBCp3QGuQWBq/rTdMuwNFiEkEGBECAAkFAkXwb0sCGwwACgkQoECD</source_pkg>
<source_pkg> D3+sWZF/WACfeNAu1/1hwZtUo1bR+MWiCjpvHtwAnA1R3IHqFLQ2X3xJ40XPuAyY</source_pkg>
<source_pkg> /FJG</source_pkg>
<source_pkg> %20=Quqp</source_pkg>
<source_pkg> -----END PGP PUBLIC KEY BLOCK-----</source_pkg>
</repos>
<filename>google-chrome.sources</filename>
</repo>
</add>
</applicationSource>
</manifest>
```

#### Source Application Update Manifest Parameters
| Tag | Example | Required/Optional | Notes |
|:-----------------------------------------|:-----------------------------------------------------------------------------------------------|:-----------------:|:------|
Expand All @@ -966,7 +1019,6 @@ The query command can be used to gather information about the system and the Vis
| `<type></type>` | `<type>source</type>` | R | |
| `<applicationSource>` | `<applicationSource>` | R | |
| `<update>` | `<update>` | R | |
| `<gpg>` | `<gpg>` | R | |
| `<repo>` | `<repo>` | R | |
| `<repos>` | `<repos>` | R | |
| `<source_pkg>` | `<source_pkg>deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main</source_pkg>` | R | |
Expand Down Expand Up @@ -999,27 +1051,27 @@ The query command can be used to gather information about the system and the Vis
```

#### Source Application Remove Manifest Parameters
| Tag | Example | Required/Optional | Notes |
|:-----------------------------------------|:-----------------------------------------|:-----------------:|:------|
| `<?xml version='1.0' encoding='utf-8'?>` | `<?xml version='1.0' encoding='utf-8'?>` | R | |
| `<manifest>` | `<manifest>` | R | |
| `<type></type>` | `<type>source</type>` | R | |
| `<applicationSource>` | `<applicationSource>` | R | |
| `<remove>` | `<remove>` | R | |
| `<gpg>` | `<gpg>` | R | |
| `<keyname></keyname>` | `<keyname>google-chrome.gpg</keyname>` | R | |
| `</gpg>` | `<gpg>` | R | |
| `<repo>` | `<repo>` | R | |
| `<filename></filename>` | `<filename>google-chrom.list</filename>` | R | |
| `</repo>` | `</repo>` | R | |
| `</remove>` | `</remove>` | R | |
| `</applicationSource>` | `</applicationSource>` | R | |
| `</manifest>` | `</manifest>` | R | |




#### Source Application Remove Manifest Example
| Tag | Example | Required/Optional | Notes |
|:-----------------------------------------|:------------------------------------------|:-----------------:|:------|
| `<?xml version='1.0' encoding='utf-8'?>` | `<?xml version='1.0' encoding='utf-8'?>` | R | |
| `<manifest>` | `<manifest>` | R | |
| `<type></type>` | `<type>source</type>` | R | |
| `<applicationSource>` | `<applicationSource>` | R | |
| `<remove>` | `<remove>` | R | |
| `<gpg>` | `<gpg>` | O | |
| `<keyname></keyname>` | `<keyname>google-chrome.gpg</keyname>` | O | |
| `</gpg>` | `<gpg>` | O | |
| `<repo>` | `<repo>` | R | |
| `<filename></filename>` | `<filename>google-chrome.list</filename>` | R | |
| `</repo>` | `</repo>` | R | |
| `</remove>` | `</remove>` | R | |
| `</applicationSource>` | `</applicationSource>` | R | |
| `</manifest>` | `</manifest>` | R | |




#### Source Application Remove Manifest Example (Including GPG key)
```xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
Expand All @@ -1037,6 +1089,21 @@ The query command can be used to gather information about the system and the Vis
</manifest>
```

#### Source Application Remove Manifest Example (Excluding GPG key)
```xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<type>source</type>
<applicationSource>
<remove>
<repo>
<filename>google-chrome.sources</filename>
</repo>
</remove>
</applicationSource>
</manifest>
```

#### Source Application List Manifest Parameters
| Tag | Example | Required/Optional | Notes |
|:-----------------------------------------|:-----------------------------------------|:-----------------:|:------|
Expand Down
78 changes: 66 additions & 12 deletions inbc-program/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,20 +414,20 @@ inbc query --option sw

## SOURCE APPLICATION ADD
### Description
Downloads and encrypts GPG key and stores it on the system under <em>/usr/share/keyrings</em>. Creates a file under <em>/etc/apt/sources.list.d</em> to store the update source information.
This list file is used during 'sudo apt update' to update the application
Optionally Downloads and encrypts GPG key and stores it on the system under <em>/usr/share/keyrings</em>. Creates a file under <em>/etc/apt/sources.list.d</em> to store the update source information.
This list file is used during 'sudo apt update' to update the application. <em>Deb882</em> format may be used instead of downloading a GPG key.

### Usage
```
inbc source application add
{--gpgKeyUri, -gku=GPG_KEY_URI}
{--gpgKeyName, -gkn=GPG_KEY_NAME}
inbc source application add
{--sources, -s=SOURCES}
{--filename, -f=FILENAME}
[--gpgKeyUri, -gku=GPG_KEY_URI]
[--gpgKeyName, -gkn=GPG_KEY_NAME]
```

### Example
#### Add an application source
#### Add an Application Source (non-deb822 format with remote GPG key)
```
inbc source application add
--gpgKeyUri https://dl-ssl.google.com/linux/linux_signing_key.pub
Expand All @@ -436,25 +436,81 @@ inbc source application add
--filename google-chrome.list
```

#### Add an Application Source (using deb822 format)

**NOTE:** In the Signed-By: Section, use the following guidelines.

- Each blank line has a period in it. -> " ."
- Each line after the Signed-By: starts with a space -> " gibberish"

```
inbc source application add
--sources
"Enabled: yes"
"Types: deb"
"URIs: http://dl.google.com/linux/chrome/deb/"
"Suites: stable"
"Components: main"
"Signed-By:"
" -----BEGIN PGP PUBLIC KEY BLOCK-----"
" Version: GnuPG v1.4.2.2 (GNU/Linux)"
" ."
" mQGiBEXwb0YRBADQva2NLpYXxgjNkbuP0LnPoEXruGmvi3XMIxjEUFuGNCP4Rj/a"
" kv2E5VixBP1vcQFDRJ+p1puh8NU0XERlhpyZrVMzzS/RdWdyXf7E5S8oqNXsoD1z"
" fvmI+i9b2EhHAA19Kgw7ifV8vMa4tkwslEmcTiwiw8lyUl28Wh4Et8SxzwCggDcA"
" feGqtn3PP5YAdD0km4S4XeMEAJjlrqPoPv2Gf//tfznY2UyS9PUqFCPLHgFLe80u"
" QhI2U5jt6jUKN4fHauvR6z3seSAsh1YyzyZCKxJFEKXCCqnrFSoh4WSJsbFNc4PN"
" b0V0SqiTCkWADZyLT5wll8sWuQ5ylTf3z1ENoHf+G3um3/wk/+xmEHvj9HCTBEXP"
" 78X0A/0Tqlhc2RBnEf+AqxWvM8sk8LzJI/XGjwBvKfXe+l3rnSR2kEAvGzj5Sg0X"
" 4XmfTg4Jl8BNjWyvm2Wmjfet41LPmYJKsux3g0b8yzQxeOA4pQKKAU3Z4+rgzGmf"
" HdwCG5MNT2A5XxD/eDd+L4fRx0HbFkIQoAi1J3YWQSiTk15fw7RMR29vZ2xlLCBJ"
" bmMuIExpbnV4IFBhY2th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
" -----END PGP PUBLIC KEY BLOCK-----"
--filename google-chrome.sources
```

## SOURCE APPLICATION REMOVE
### Description
Removes the GPG key file from under <em>/usr/share/keyrings</em>. Removes the source file from under /etc/apt/sources.list.d/.
Removes the source file from under /etc/apt/sources.list.d/. Optionally removes the GPG key file from under <em>/usr/share/keyrings</em>.

### Usage
```
inbc source application remove
{--gpgKeyName, -gkn=GPG_KEY_NAME}
inbc source application remove
{--filename, -f=FILE_NAME}
[--gpgKeyName, -gkn=GPG_KEY_NAME]
```

### Example
#### Remove an application source
#### Remove an application source (Both GPG key and Source File)
```commandline
inbc source application remove
--gpgKeyName google-chrome.gpg
--filename google-chrome.list
```

#### Remove an application source (deb822 format)
```commandline
inbc source application remove
--filename google-chrome.sources
```

## SOURCE APPLICATION UPDATE
### Description
Updates Application sources that are used to update the system
Expand All @@ -478,7 +534,6 @@ inbc source application update
## SOURCE APPLICATION LIST
### Description
Lists Application sources
NOTE: Currently this only works on Ubuntu

### Usage
pillaiabhishek marked this conversation as resolved.
Show resolved Hide resolved
```
Expand Down Expand Up @@ -545,7 +600,6 @@ inbc source os update
## SOURCE OS LIST
### Description
Lists OS sources
NOTE: Currently this only works on Ubuntu

### Usage
```commandline
Expand Down
6 changes: 3 additions & 3 deletions inbc-program/inbc/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ def parse_source_args(self) -> None:

# Application Add Command
app_add_parser = app_subparsers.add_parser('add')
app_add_parser.add_argument('--gpgKeyUri', '-gku', required=True,
app_add_parser.add_argument('--gpgKeyUri', '-gku', required=False,
type=lambda x: validate_string_less_than_n_characters(
x, 'str', 1500),
help='Uri from which to download GPG key')
app_add_parser.add_argument('--gpgKeyName', '-gkn', required=True,
app_add_parser.add_argument('--gpgKeyName', '-gkn', required=False,
type=lambda x: validate_string_less_than_n_characters(
x, 'str', 200),
help='Name to store the GPG key information')
nmgaston marked this conversation as resolved.
Show resolved Hide resolved
Comment on lines +68 to 75
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The 'required' flag for '--gpgKeyUri' and '--gpgKeyName' arguments in the 'app_add_parser' has been changed from True to False. Ensure that the rest of the code properly handles cases where these arguments might not be provided, to prevent runtime errors. [possible issue]
NOTE: Ensure that the suggested code is comprehensive. This serves as an example of the code you could use. The user should verify it after accepting the suggestion.

Suggested change
app_add_parser.add_argument('--gpgKeyUri', '-gku', required=False,
type=lambda x: validate_string_less_than_n_characters(
x, 'str', 1500),
help='Uri from which to download GPG key')
app_add_parser.add_argument('--gpgKeyName', '-gkn', required=True,
app_add_parser.add_argument('--gpgKeyName', '-gkn', required=False,
type=lambda x: validate_string_less_than_n_characters(
x, 'str', 200),
help='Name to store the GPG key information')
# It's assumed that the application_add function is designed to handle optional GPG key parameters.
# If not, the function should be updated accordingly to avoid runtime errors when these arguments are not provided.

Expand All @@ -85,7 +85,7 @@ def parse_source_args(self) -> None:

# Application Remove Command
app_remove_parser = app_subparsers.add_parser('remove')
app_remove_parser.add_argument('--gpgKeyName', '-gkn', required=True,
app_remove_parser.add_argument('--gpgKeyName', '-gkn', required=False,
type=lambda x: validate_string_less_than_n_characters(
x, 'str', 50),
help='GPG key name of the source to remove.')
nmgaston marked this conversation as resolved.
Show resolved Hide resolved
nmgaston marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading