[verb (dictionary form)] + よりしかたがない [verb (dictionary form)] + よりしかたない [verb (dictionary form)] + よりしようがない
よりしかたがない follows the dictionary form of a verb and means "there's nothing for it but to": no other way is left, and you accept the one that is. It is より, "other than", with しかたがない, "there's no way", so it reads "there's no way other than doing it". It sounds a step more formal and more resigned than しかない, the everyday way to say the same thing.
The verb stays in the dictionary form whatever the tense; the past goes on the end, as in しかたがなかった.
In speech が often drops out, giving よりしかたない, and よりしようがない means the same. In polite speech, しかたがない becomes しかたがありません.