Skip to content

Commit

Permalink
add --recipe update with csv files
Browse files Browse the repository at this point in the history
  • Loading branch information
kareefardi committed Dec 5, 2021
1 parent b11bb41 commit 0bbaf1e
Show file tree
Hide file tree
Showing 22 changed files with 129 additions and 80 deletions.
15 changes: 8 additions & 7 deletions images/base/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args" : {
"BASE_IMAGE" : "centos:centos7",
"NAME": "base",
"REPO_COMMIT": "alpha",
"REPO_URL": "n/a"
}
}
"args": {
"GIT": "false",
"BASE_IMAGE": "centos:centos7",
"NAME": "base",
"REPO_COMMIT": "alpha",
"REPO_URL": "n/a"
}
}
1 change: 1 addition & 0 deletions images/covered/info.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"args" : {
"GIT": "true",
"BASE_IMAGE" : "base",
"NAME": "covered",
"REPO_URL": "https://github.com/Manarabdelaty/verilog-covered",
Expand Down
1 change: 1 addition & 0 deletions images/foss-asic-tools/info.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"args": {
"GIT": "false",
"BASE_IMAGE": "base",
"NAME": "foss-asic-tools",
"REPO_URL": "https://github.com/efabless/foss-asic-tools",
Expand Down
2 changes: 1 addition & 1 deletion images/foss-asic-tools/scripts/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ klayout_path=$(realpath $base_path/klayout/* )
netgen_path=$(get_path "netgen")
openlane_tools_path=$(get_path "openlane_tools" )
riscv32i_path=$(get_path "riscv-gnu-toolchain-rv32i" )
gaw3_path=$(get_path "gaw3")
gaw3_path=$(get_path "gaw3-xschem")
ngscope_path=$(realpath $base_path/ngscope/*/usr/local/bin )
ngspice_path=$(get_path "ngspice")
xschem_path=$(get_path "xschem")
Expand Down
7 changes: 4 additions & 3 deletions images/gaw3-xschem/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args": {
"GIT": "true",
"BASE_IMAGE": "base",
"NAME": "gaw3",
"NAME": "gaw3-xschem",
"REPO_URL": "https://github.com/StefanSchippers/xschem-gaw.git",
"REPO_COMMIT": "2a1fc97bcc3081af72fc37a8bc52bc4632e176b2"
"REPO_COMMIT": "52ff1cf547c241d36d314bb3af8ab6b908ac7754"
}
}
}
15 changes: 8 additions & 7 deletions images/gtkwave/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args" : {
"BASE_IMAGE" : "base",
"NAME": "gtkwave",
"REPO_URL": "https://github.com/gtkwave/gtkwave",
"REPO_COMMIT": "bc06f0fabd174d44f50647b09d6f7c702b3b6c40"
}
}
"args": {
"GIT": "true",
"BASE_IMAGE": "base",
"NAME": "gtkwave",
"REPO_URL": "https://github.com/gtkwave/gtkwave",
"REPO_COMMIT": "13fc69b24caa203d3b1946eb228d462c1e9d98c5"
}
}
3 changes: 2 additions & 1 deletion images/irsim/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args": {
"GIT": "true",
"BASE_IMAGE": "base",
"NAME": "irsim",
"REPO_URL": "https://github.com/rtimothyedwards/irsim",
"REPO_COMMIT": " 5f33a7328787f726c1a22e787c8cc810f46971d3"
"REPO_COMMIT": "3813495e55a21a024e62e21bd6993fac068a61b9"
}
}
15 changes: 8 additions & 7 deletions images/iverilog/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args" : {
"BASE_IMAGE" : "base",
"NAME": "iverilog",
"REPO_URL": "https://github.com/steveicarus/iverilog.git",
"REPO_COMMIT": "v11_0"
}
}
"args": {
"GIT": "true",
"BASE_IMAGE": "base",
"NAME": "iverilog",
"REPO_URL": "https://github.com/steveicarus/iverilog.git",
"REPO_COMMIT": "71c36d1289873e9e9fb2699c1de1f22dee2021e6"
}
}
3 changes: 2 additions & 1 deletion images/klayout/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args": {
"GIT": "true",
"BASE_IMAGE": "base",
"NAME": "klayout",
"REPO_URL": "https://github.com/KLayout/klayout",
"REPO_COMMIT": "8b1278808485cc06aeb29cb9425b089df4c58546"
"REPO_COMMIT": "4598f87466f33fdab9dd52c2afc490df6df5f8c2"
}
}
3 changes: 2 additions & 1 deletion images/magic/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args": {
"GIT": "true",
"BASE_IMAGE": "base",
"NAME": "magic",
"REPO_URL": "https://github.com/rtimothyedwards/magic",
"REPO_COMMIT": "73929a0bccd3083c3fe5c74b7ebf5a20d74bb4ee"
"REPO_COMMIT": "bfdf1227a704dbbfb78f42f69965ccc2c81989c1"
}
}
3 changes: 2 additions & 1 deletion images/netgen/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args": {
"GIT": "true",
"BASE_IMAGE": "base",
"NAME": "netgen",
"REPO_URL": "https://github.com/rtimothyedwards/netgen",
"REPO_COMMIT": "18dcac73bcb10455475826facbfdb4c25ce1a951"
"REPO_COMMIT": "cfdc60104b8487be153541697df476ca84598e4a"
}
}
5 changes: 3 additions & 2 deletions images/ngscope/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args": {
"GIT": "false",
"BASE_IMAGE": "base",
"NAME": "ngscope",
"REPO_URL": "none",
"REPO_URL": "n/a",
"REPO_COMMIT": "0.9.5"
}
}
}
15 changes: 8 additions & 7 deletions images/ngspice/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args" : {
"BASE_IMAGE" : "base",
"NAME": "ngspice",
"REPO_URL": "https://git.code.sf.net/p/ngspice/ngspice",
"REPO_COMMIT": "51cc21de1637d1abca1b361b756784e69a28cf76"
}
}
"args": {
"GIT": "true",
"BASE_IMAGE": "base",
"NAME": "ngspice",
"REPO_URL": "https://git.code.sf.net/p/ngspice/ngspice",
"REPO_COMMIT": "87b9df66816696c085007e5d7731bc457d6208ba"
}
}
1 change: 1 addition & 0 deletions images/open_pdks/info.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"args": {
"GIT": "true",
"BASE_IMAGE": "base",
"MAGIC_IMAGE": "magic",
"NAME": "open_pdks",
Expand Down
3 changes: 2 additions & 1 deletion images/openlane/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args": {
"GIT": "true",
"BASE_IMAGE": "base",
"NAME": "openlane",
"REPO_URL": "https://github.com/The-OpenROAD-Project/OpenLane",
"REPO_COMMIT": "2021.09.23_03.17.13"
"REPO_COMMIT": "445acc69b3a1180533f7133fb1db08ab4fdedd9a"
}
}
15 changes: 8 additions & 7 deletions images/riscv-gnu-toolchain-rv32i/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args" : {
"BASE_IMAGE" : "base",
"NAME": "riscv-gnu-toolchain-rv32i",
"REPO_URL": "https://github.com/riscv/riscv-gnu-toolchain",
"REPO_COMMIT": "411d134"
}
}
"args": {
"GIT": "true",
"BASE_IMAGE": "base",
"NAME": "riscv-gnu-toolchain-rv32i",
"REPO_URL": "https://github.com/riscv/riscv-gnu-toolchain",
"REPO_COMMIT": "b39e36160aa0649ba0dfb9aa314d375900d610fb"
}
}
15 changes: 8 additions & 7 deletions images/skywater-pdk/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args" : {
"BASE_IMAGE" : "base",
"NAME": "skywater-pdk",
"REPO_URL": "https://github.com/google/skywater-pdk.git",
"REPO_COMMIT" : "c094b6e83a4f9298e47f696ec5a7fd53535ec5eb"
}
}
"args": {
"GIT": "true",
"BASE_IMAGE": "base",
"NAME": "skywater-pdk",
"REPO_URL": "https://github.com/google/skywater-pdk.git",
"REPO_COMMIT": "b5ff6174d9aa921f670f12a2893969fe4a516f6c"
}
}
3 changes: 2 additions & 1 deletion images/xschem/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args": {
"GIT": "true",
"BASE_IMAGE": "base",
"NAME": "xschem",
"REPO_URL": "https://github.com/StefanSchippers/xschem.git",
"REPO_COMMIT": "945368db9cf21c6a402260f6ee03350893a233ef"
"REPO_COMMIT": "de1db1e87a89efe9d8b69a1ac9fdf51eaa75b53a"
}
}
5 changes: 3 additions & 2 deletions images/xyce/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"args": {
"GIT": "true",
"BASE_IMAGE": "base",
"NAME": "xyce",
"REPO_URL": "https://github.com/Xyce/Xyce.git",
"REPO_COMMIT": "a157dbaa9516d5c218725f174b35f670b9e34131"
"REPO_COMMIT": "3f88510cc7108101ba461363fbb3c62523ef23c1"
}
}
}
26 changes: 18 additions & 8 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def update(args):
def handleRecipe(args):
json_file = args.json
csv_file = args.csv
update = args.update
dict = None

if json_file != None:
Expand All @@ -60,15 +61,23 @@ def handleRecipe(args):
dict = recipe.parseCsvFile(csv_file)

images = recipe.parseRecipeDict(dict)
builder = DockerBuilder()
for image in images:
image.build_status = builder.build(image)
if update == True:
csv = "Name,Version\n"
for image in images:
image.update(updateFlag=True)
csv += f"{image.name},{image.version}\n"
with open(csv_file, "w") as file:
file.writelines(csv)
else:
builder = DockerBuilder()
for image in images:
image.build_status = builder.build(image)

for image in images:
status = "Fail"
if image.build_status == True:
status = "Success"
print("Image | {:^30} | {:10} ".format(image.name, status))
for image in images:
status = "Fail"
if image.build_status == True:
status = "Success"
print("Image | {:^30} | {:10} ".format(image.name, status))


parser = argparse.ArgumentParser(
Expand All @@ -92,6 +101,7 @@ def handleRecipe(args):
help="recipe ")
recipe_subparser.add_argument("--json", type=str)
recipe_subparser.add_argument("--csv", type=str)
recipe_subparser.add_argument("--update", action="store_true")
recipe_subparser.set_defaults(func=handleRecipe)

args = parser.parse_args()
Expand Down
41 changes: 25 additions & 16 deletions src/image/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def __init__(self, name, path, args, json_file, meta_data):
self.version = self.args["REPO_COMMIT"]
self.build_status = False

self.is_git = True if self.args["GIT"] == "true" else False


@classmethod
def createFromPath(cls, path):
Expand All @@ -25,6 +27,7 @@ def createFromPath(cls, path):

return cls.createFromJSON(json_file)


@classmethod
def createFromJSON(cls, json_file):
f = open(json_file)
Expand All @@ -46,10 +49,12 @@ def createFromJSON(cls, json_file):


def getLatestVersion(self):
url = self.url
g = git.cmd.Git()
response = g.ls_remote(url, 'HEAD')
latest_version = response.split()[0]
latest_version = ""
if self.is_git == True:
url = self.url
g = git.cmd.Git()
response = g.ls_remote(url, 'HEAD')
latest_version = response.split()[0]

return latest_version

Expand All @@ -67,21 +72,25 @@ def updatePrompt(self, new_version):


def update(self, updateFlag=False):
current_version = self.version
new_version = self.getLatestVersion()
if self.is_git == True:
current_version = self.version
new_version = self.getLatestVersion()

if (new_version != current_version):
if (updateFlag == True):
self.commitVersion(new_version)
else:
response = self.updatePrompt(new_version)
if (response == True):
if (new_version != current_version):
if (updateFlag == True):
self.commitVersion(new_version)
print("New version commited!")
print(f"{self.name} updated to {self.version}")
else:
response = self.updatePrompt(new_version)
if (response == True):
self.commitVersion(new_version)
print(f"{self.name} updated to {self.version}")
else:
print("Latest version for (%s) synced.\n"
"Run install to install it.\n"
"Nothing to be done." % self.name)
else:
print("Latest version for (%s) synced.\n"
"Run install to install it.\n"
"Nothing to be done." % self.name)
print(f"{self.name} is not git-based")


def commitVersion(self, new_version):
Expand Down
12 changes: 12 additions & 0 deletions src/image/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
from .image import Image


def genRecipe(images):
csv = "Name,Version\n"
for image_name in images:
image_path = getImagePath(image_name)
image = Image.createFromPath(image_path)
version = image.version
csv += f"{image_name},{version}\n"

return csv



def parseRecipeDict(recipe_dict):
images = []
for item in recipe_dict:
Expand Down

0 comments on commit 0bbaf1e

Please sign in to comment.