@@ -542,20 +542,21 @@ func InstallMany(st *state.State, names []string, userID int) ([]string, []*stat
// RefreshCandidates gets a list of candidates for update
// Note that the state must be locked by the caller.
func RefreshCandidates (st *state .State , user *auth .UserState ) ([]*snap .Info , error ) {
- updates , _ , err := refreshCandidates (st, nil , user)
+ updates , _ , _ , err := refreshCandidates (st, nil , user)
return updates, err
}
-func refreshCandidates (st *state .State , names []string , user *auth .UserState ) ([]*snap .Info , map [string ]*SnapState , error ) {
+func refreshCandidates (st *state .State , names []string , user *auth .UserState ) ([]*snap .Info , map [string ]*SnapState , map [ string ] bool , error ) {
snapStates , err := All (st)
if err != nil {
- return nil , nil , err
+ return nil , nil , nil , err
}
sort.Strings (names)
stateByID := make (map [string ]*SnapState, len (snapStates))
candidatesInfo := make ([]*store.RefreshCandidate , 0 , len (snapStates))
+ ignoreValidation := make (map [string ]bool )
for _ , snapst := range snapStates {
if len (names) == 0 && (snapst.TryMode || snapst.DevMode ) {
// no auto-refresh for trymode nor devmode
@@ -588,17 +589,21 @@ func refreshCandidates(st *state.State, names []string, user *auth.UserState) ([
// get confinement preference from the snapstate
candidateInfo := &store.RefreshCandidate {
// the desired channel (not info.Channel!)
- Channel: snapst.Channel ,
- SnapID: snapInfo.SnapID ,
- Revision: snapInfo.Revision ,
- Epoch: snapInfo.Epoch ,
+ Channel: snapst.Channel ,
+ SnapID: snapInfo.SnapID ,
+ Revision: snapInfo.Revision ,
+ Epoch: snapInfo.Epoch ,
+ IgnoreValidation: snapst.IgnoreValidation ,
}
if len (names) == 0 {
candidateInfo.Block = snapst.Block ()
}
candidatesInfo = append (candidatesInfo, candidateInfo)
+ if snapst.IgnoreValidation {
+ ignoreValidation[snapInfo.SnapID ] = true
+ }
}
theStore := Store (st)
@@ -607,14 +612,14 @@ func refreshCandidates(st *state.State, names []string, user *auth.UserState) ([
updates , err := theStore.ListRefresh (candidatesInfo, user)
st.Lock ()
if err != nil {
- return nil , nil , err
+ return nil , nil , nil , err
}
- return updates, stateByID, nil
+ return updates, stateByID, ignoreValidation, nil
}
// ValidateRefreshes allows to hook validation into the handling of refresh candidates.
-var ValidateRefreshes func (st *state .State , refreshes []*snap .Info , userID int ) (validated []*snap .Info , err error )
+var ValidateRefreshes func (st *state .State , refreshes []*snap .Info , ignoreValidation map [ string ] bool , userID int ) (validated []*snap .Info , err error )
// UpdateMany updates everything from the given list of names that the
// store says is updateable. If the list is empty, update everything.
@@ -625,13 +630,13 @@ func UpdateMany(st *state.State, names []string, userID int) ([]string, []*state
return nil , nil , err
}
- updates , stateByID , err := refreshCandidates (st, names, user)
+ updates , stateByID , ignoreValidation , err := refreshCandidates (st, names, user)
if err != nil {
return nil , nil , err
}
if ValidateRefreshes != nil && len (updates) != 0 {
- updates, err = ValidateRefreshes (st, updates, userID)
+ updates, err = ValidateRefreshes (st, updates, ignoreValidation, userID)
if err != nil {
// not doing "refresh all" report the error
if len (names) != 0 {
@@ -930,6 +935,7 @@ func Update(st *state.State, name, channel string, revision snap.Revision, userI
// see if we need to update the channel
if infoErr == store.ErrNoUpdateAvailable && snapst.Channel != channel {
+ // TODO: do we want to treat ignore-validation similarly?
snapsup := &SnapSetup{
SideInfo: snapst.CurrentSideInfo (),
// update the tracked channel
@@ -963,15 +969,15 @@ func Update(st *state.State, name, channel string, revision snap.Revision, userI
func infoForUpdate (st *state .State , snapst *SnapState , name , channel string , revision snap .Revision , userID int , flags Flags ) (*snap .Info , error ) {
if revision.Unset () {
// good ol' refresh
- info , err := updateInfo (st, snapst, channel, userID)
+ info , err := updateInfo (st, snapst, channel, flags. IgnoreValidation , userID)
if err != nil {
return nil , err
}
if err := validateInfoAndFlags (info, snapst, flags); err != nil {
return nil , err
}
if ValidateRefreshes != nil && !flags.IgnoreValidation {
- _ , err := ValidateRefreshes (st, []*snap.Info {info}, userID)
+ _ , err := ValidateRefreshes (st, []*snap.Info {info}, nil , userID)
if err != nil {
return nil , err
}