Mounting a shelf flush to a curved wall (or any wall that just isn't flat enough for a nice fit) calls for a traditional carpentry technique known as scribing. Scribing is a simple trick of using the surface itself—the curved wall, in this case—to mark the cutting line onto a template or the workpiece itself (the shelf). To scribe a line, you hold the template in place against the surface, then drag a compass (or other marking device) along the surface, letting the pencil mark the cutting line onto the template as you go. This transfers all of the contours and irregularities of the surface directly to the template and is much more accurate than conventional measuring and marking.
Scribing a Shelf to a Curved Wall
Cut a piece of butcher paper or thin cardboard a little longer than the shelf dimension. Make two marks along one edge of the paper to represent the ends of the finished shelf.
Lay the paper on the floor directly below the planned location of the shelf. With a convex wall, make sure the paper is equidistant from the wall at the shelf-end markings.
Set a compass (the kind you used in elementary school to draw circles) to span a little beyond the widest gap between the paper's edge and the wall. Keeping the compass perpendicular to the wall at all times, move the pointed end of the compass along the wall while the pencil end marks the paper. If you don't have a compass you can use a pencil taped to a block of wood.
Cut the paper along the scribed line with scissors. Check the fit against the wall and make any fine adjustments to the paper as needed for a tight fit.
Clamp or tape the template to the shelf board, and trace along its edge to mark a cutting line onto the board. Cut the board using a jig saw. Test the fit, and refine and smooth the cut as needed with sandpaper. Install the shelf as desired.