# Add new distribution

### Ways to add a new distribution (Work in progress)
<pre>cd /var/www/be</pre>    

**Create distribution folder:**  
<pre>
mkdir data/distributions/%distribution-name%
</pre>  

**Use/Copy the template:**   
<pre>
cp SW/templates/distribution.yaml  ./</pre>  

**Convert the yaml to json:** (need to have node.js installed)  
<pre>
yaml2json distribution.yaml (this will create a distribution.json file in the same dir)
</pre>   
Now we have a json file:   
<pre>distribution.json</pre>  

**Rename it to the distribution-name:**  
<pre>
mv distribution.json %distribution-version%.json
mv %distribution-version%.json data/distributions/%distribution-name%/
</pre>   
<br>

#### **1st approach - using the Database (DB)** 
**Add the data manually to the DB:**  
- Product
- Distribution product data
Commands...  
Examples:  <pre>cat create_table.sql |sqlite3 db/egi-repos-fe-test.db  
sqlite3 db/egi-repos-fe-test.db ".read insert_data.sql"  
sqlite3 db/egi-repos-fe-test.db "select MAX(f1) from tbl2;" ".exit"
sqlite3 db/egi-repos-fe-test.db "INSERT INTO tbl2 ('f1','f2','f3') VALUES('001','teste','ttttt');" ".exit" </pre>
---  
<pre>
INSERT INTO `distributions`(
            distributionType, distributionVersion, currentState,
            majorVersion, minorVersion, revisionVersion,
            releaseDate, created,
            lastUpdated, description,
            repositoryURL, releaseNotes,
            additionalDetails, installationNotes,
            contact, technicalContact,
            knownIssues, changeLog
            ) 
VALUES ('','','','','','','','','','','','','','','','','','');
</pre>

**Export/prepare all the data from DB (replacing the data in data/*)**  
<pre>$ export-full-dataset.sh</pre>
...................................................  
php export-distributions.php  
php export-distributions.php --individual-distributions  (Each distribution)
php export-products.php  
php export-products.php --individual-products    (Each product)

<br>


#### **2nd approach - add the data manually to the json files**
**Manually add distribution**

**add distribution data (to the software distributions catalog):**   
data/software-distributions.json (item[] array)  
ex. of distribution item: (DON'T FORGET TO ADD A COMMA , BEFORE THE BRACKETS)
<pre>,
{
  "distributionType": "",
  "distributionVersion": "%version%0.0.0",
  "currentState": "deployed",  
  "releaseDate": "",
  "description": "",
  "products": [ 
        {
          "name": "product-name",
          "version": "0.0.0",
          "capabilities": ["Client Tools"],
          "status": 1
        }
     ]
}
</pre>