The movie “War Dogs” debuts Friday with Jonah Hill playing the role of Efraim Diveroli, a brash college dropout in Miami Beach who decides to sell guns and ammunition to the Pentagon. It’s a comedy, but the real-life story is no laughing matter: Diveroli’s company eventually won a $298 million Defense Department contract, but sent substandard equipment from Eastern Bloc countries to Afghanistan and found itself at the center of a sprawling criminal investigation.

Diveroli’s rise and fall was covered at length after the misdeeds of AEY Inc., his company, were discovered. They were outlined in a 28-page report in 2008 by the House Committee on Oversight and Government Reform and in a March 2011 Rolling Stone magazine article that relies heavily on interviews with Diveroli’s former colleague, David Packouz.

AEY was awarded its largest contract in January 2007 to send ammunition to the Afghan military, but it supplied illegal and faulty Chinese ammunition through Albania. The practice was exposed by the New York Times in March 2008 and led to Diveroli, Packouz and two others being indicted, according to the House report.

Diveroli pleaded guilty in 2009 to a single count of conspiracy. He was sentenced in 2011 to four years in prison and avoided an additional two years on a separate weapons charge when a judge ruled that he could serve the two sentences concurrently.

Faced with that kind of past, some felons disappear into obscurity. But not Diveroli. Now 30, he was released from prison last year and finished a memoir called “Once a Gun Runner…” that was published in May. He also helped start a media company — named Incarcerated Entertainment — and filed a lawsuit this spring against virtually everyone involved in the production of “War Dogs,” alleging that material from “Once a Gun Runner…” was used to write the manuscript for the movie without his authorization.

The lawsuit alleged that movie producer Elliot Kahn signed a nondisclosure agreement as part of a deal to pitch Diveroli’s book for a potential movie in 2014 while Diveroli was in prison. The filing also states that the author of the Rolling Stone article, Guy Lawson, carried out a jailhouse interview with Diveroli and said that if his article about Diveroli and Packouz gained traction, “it could turn into a book that he suggested both Lawson and Diveroli would co-author.”

Diveroli wrote a manuscript for his book in January 2012 and “expressed to Mr. Lawson” that it should be kept confidential, the lawsuit alleged. The former arms dealer believed that they would finalize their collaboration on the book when he was released from prison in early 2015, the lawsuit said. It adds that in a June 2014 message, Lawson acknowledged that he will not act without the felon’s consent.

Instead, the lawsuit alleged, Lawson went forward and wrote a book about Diveroli’s life called “The Arms and the Dudes” and was credited as the sole author. Lawson also reached an agreement with a screenwriter, Todd Phillips, in which the rights to his Rolling Stone article — which does not list Diveroli as an author — were optioned for a potential movie.

Lawson is not named in the lawsuit and could not be reached for comment. Those who are include Phillips, who served as director, Warner Bros. Entertainment and actor Bradley Cooper, who served as a producer for the movie and appears in it as Henry Girard, a dangerous foreign arms dealer with whom Diveroli does business.

The lawsuit asks a Florida court for monetary damages and a “reasonable royalty” of the movies profits, additional punitive damages and the destruction of all products and marketing bearing Diveroli’s name, which has been used in publicizing the movie as “based on a true story.”

Warner Bros. and the others named in the suit filed a motion to dismiss the case in July, arguing it is baseless and that Incarcerated Entertainment cannot point to any document that prevented Lawson from reporting material that Diveroli gave him. The motion also argues that the lawsuit does not “point to a single private fact” that the creators of “War Dogs” took from Diveroli’s manuscript. They add that a movie is generally shielded by the First Amendment protecting free speech, especially when it dramatizes real-life events.

Diveroli did not respond to a request for an interview and has recently declined other requests citing the pending litigation. On his Twitter account, he casts aspersions on “unauthorized versions of my life story” and bills his book as a “tell-all memoir.”

The case isn’t the only one involving Diveroli going through the courts. As a recent Miami New Times article outlines, Packouz and another former business partner, Ralph Merrill, have sued Diveroli for money they say they are still owed from the $298 million contract that AEY landed in 2007. Diveroli left prison still rich from their deal, they alleged.

“It’s important that everyone know Efraim’s book is a work of fiction,” Packouz told the newspaper. “It’s the work of a megalomaniac, a damaged person.”

Packouz was sentenced to house arrest in the criminal case — receiving a reduced sentence in part because he testified against Diveroli.