In a spice grinder, a clean coffee grinder, or a mortar, grind the salt, oregano, rosemary, caraway, cumin, and turmeric to a fine powder. Transfer to a bowl and add the harissa and chopped garlic. Add the olive oil to make a thick paste. Make 8 or 9 deep slits all over the lamb and insert some of the spice paste, rubbing the paste all over the surface of the meat. Cover and let stand for 1 hour at room temperature or, preferably, refrigerate for at least 5 hours or overnight. Bring to room temperature before roasting. Preheat the oven to 450°F. Place the leg of lamb fat side down in a roasting pan that will hold the onions in one layer. Roast for 20 minutes. Mix the lemon juice and wine in a small bowl. Turn the meat and pour the lemon-wine mixture over it. (If you are roasting the lamb in a clay dish, warm the mixture first, because cold liquid can cause the clay to crack.) Reduce the oven temperature to 375°F and roast for 35 minutes, basting every 10 to 15 minutes with the pan juices. If the pan dries out, add a little more wine. Transfer the lamb to a plate and add the onions to the pan, tossing them well to coat them with the pan juices. Add the rosemary sprigs or sprinkle with dried rosemary, toss, place the lamb on the onions, and continue roasting, basting often, for another 30 minutes, or until an instant-read thermometer inserted into the thickest part of the meat reads 135°F. Transfer the meat to a heated platter, cover with a double layer of aluminum foil, and set aside. (Leave the oven on.) If the pan juices are watery, transfer most of them to a saucepan and cook briefly to reduce. Meanwhile, return the pan to the oven and continue baking the onions until tender, with browned edges. Turn the oven to broil. Place the lamb on the onions again and broil for 2 to 3 minutes, or until the surface is deep brown and crackling. Carve the lamb and serve, passing the pan juices in a bowl or sauceboat at the table.