> > I was about to suggest the following.
> >
> > +    (package-delete (cadr (assq pkg package-alist)) 'force)
> > +    (package-install pkg selected)))
>
> At first I had the same idea, but after I thought it was calling two time
> custom-save-varaible for nothing (i.e one time to remove the package and
> on time to add it again), so I think it is better to just delete the
> package without removing it from the list.

Good point.