Truck in shop 7 months getting new engine HELP

Hi I’m puzzeled… literally.
Fed 28 I took my gmc Sierra 1500 to have a engine installed only because the leaks we had and repair work needed would be jus a lil less then a engine so we decided put a another one in cause it still had original engine in it. the mechanic said it would be 2 weeks so we paid $2000 cash .now for some reason it has (check engine light) been on all along since I acquired the truck but now with a new engine the light will still not go off and the mechanic says he cant release it to me as long as it’s on, its against the law he has changed the tps, some valves , electrical and other stuff and still can not locate the problem he has done according to him everything under the sun even located a gmc specialist with the diagram for the truck and still cant figure it out. It probably doesn’t help the the previous owners where tweakers and I believe tweaked on it cause he found parts that dont even belong. So here we are 7 months later and he still has my truck I dont know what to do he thinks its th CPU but we cant locate one they dont make them for my truck anymore supposedly my truck was only a few made and it was the first computer to be put in that model… so now I have put a new tranny and engine in but in California if ur engine light is on it’s an automatic fail in smog and it is due for smog so I’m damned if I take it with engine light on cause I cant smog and drive it and I’m damned if I dont so I’m stuck we only have these 2 vehicle and right now we are jus down to using my SUVfor EVERYTHING… WHAT DO I DO. It is still in shop being worked on (trying find problem) SOMEONE PLEASE HELP… can my mechanic actually keep my truck since it’s been there so long?? What do I do?? Thanks

@cdaquila Duplicate post.

You beat me to it…

Posting on all boards for info help