When a young Afghan woman disregards familial disapproval and death threats to appear on the television talent show “Afghan Star,” it’s a rousing story of the human spirit and the transformative power of the arts. At least it was, when that story line was part of the 2009 documentary “Afghan Star,” which charted the fortunes of villager Setara Hussainzada and three other contestants on the Kabul-based reality show.

The same plot, as grafted by screenwriter Mitch Glazer (“Scrooged”) into the middle of the crass screwball comedy “Rock the Kasbah” by Barry Levinson (“Diner”), is more like a Frankensteinian brain transplant. The thing is alive, but it ain’t what it used to be.

Sexist, racist, overlong, dull, visually ugly and, worst of all, unfunny, “Kasbah” squanders its cast, headlined by Bill Murray as a dissolute American rock promoter stuck in Afghanistan, and featuring Zooey Deschanel, Bruce Willis, Kate Hudson, Danny McBride and Scott Caan in unmemorable supporting roles. It takes some strenuous effort to extinguish that much party-hearty talent, but the script is like a blast of fire retardant. All that’s left at the end of this flame-out of a movie is a heap of smoldering ash.

When Murray’s Richie Lanz escorts his secretary/cover singer (Deschanel) to a USO tour in Afghanistan, he’s surprised to see her abscond — with his wallet and, less explicably, his passport — back to Van Nuys, after they’re greeted by bombs and other life-threatening surprises. In a plot too convoluted to explain, but involving gun-runners (McBride and Caan), a mercenary (Willis) and a hooker with a heart of gold (Hudson), Richie finds himself in a Pashtun village, where he encounters a woman (Leem Lubany) with the voice of an angel and a repertoire of Cat Stevens songs under her hijab. To kill time, and make a little money, he maneuvers to get her on “Afghan Star,” wriggling around the disapproval of her father (Fahim Fazli) and the show’s producers, who believe that it is shameful — or, at the very least, unheard of — for a woman to sing in public.

The problem with “Kasbah” is that, in the tut-tutting attitude it takes toward Pashtun sexism, it seems to have overlooked its own deeply offensive misogyny. The film’s sniggering, piggish portrayal of Hudson’s Mercy is just as bad as — if not worse than — the supposedly “backward” Afghan patriarchy, whose exponents are portrayed as one or two steps away from cavemen.

The unattractive cinematography cannot be blamed entirely on the desert landscape, which Richie compares, in a rare example of a quip that works, to “Aspen in wartime.” Levinson never seems to know what to point his camera at, or when to cut, and Glazer never seems to know when to leave a joke alone and let the cast work.

I have an answer for both of them. They should have pulled out six years ago, before this Afghan escapade turned into another quagmire.

R. At area theaters. Contains obscenity, drug use, sexual references and violence. 106 minutes.