@@ -32,14 +32,14 @@ import (
3232// RepositoryList is an array of Repository definitions
3333type RepositoryList []* Repository
3434
35- // Contains check if a repository definition is already contained
35+ // Contains checks if a repository definition is contained
3636// in the RepositoryList
3737func (r RepositoryList ) Contains (repo * Repository ) bool {
3838 return r .Find (repo ) != nil
3939}
4040
41- // Find search a repo in the RepositoryList that has metadata
42- // matching with the one passed as parameter
41+ // Find search in the RepositoryList a repo that has the same
42+ // metadata as the one passed as parameter
4343func (r RepositoryList ) Find (repoToFind * Repository ) * Repository {
4444 for _ , repo := range r {
4545 if repoToFind .Equals (repo ) {
@@ -49,7 +49,7 @@ func (r RepositoryList) Find(repoToFind *Repository) *Repository {
4949 return nil
5050}
5151
52- // Repository is a repository installed in the system
52+ // Repository contains metadata about a repository installed in the system
5353type Repository struct {
5454 Enabled bool
5555 SourceRepo bool
@@ -62,8 +62,9 @@ type Repository struct {
6262 configFile string
6363}
6464
65- // Equals check if the Repository definition is equivalent to the
66- // one provided as parameter
65+ // Equals check if the Repository metadata are equivalent to the
66+ // one provided as parameter. Two Repository are equivalent if all
67+ // metadata matches with the exception of Enabled and Comment.
6768func (r * Repository ) Equals (repo * Repository ) bool {
6869 if r .Components != repo .Components {
6970 return false
@@ -83,7 +84,8 @@ func (r *Repository) Equals(repo *Repository) bool {
8384 return true
8485}
8586
86- // APTConfigLine returns the source.list config line for the Repository
87+ // APTConfigLine returns the "deb" or "deb-src" config line to put in
88+ // source.list to install the Repository
8789func (r * Repository ) APTConfigLine () string {
8890 res := ""
8991 if ! r .Enabled {
@@ -145,7 +147,8 @@ func parseAPTConfigFile(configPath string) (RepositoryList, error) {
145147}
146148
147149// ParseAPTConfigFolder scans an APT config folder (usually /etc/apt) to
148- // get information about configured repositories
150+ // get information about all configured repositories, it scans also
151+ // "source.list.d" subfolder to find all the "*.list" files.
149152func ParseAPTConfigFolder (folderPath string ) (RepositoryList , error ) {
150153 sources := []string {filepath .Join (folderPath , "sources.list" )}
151154
@@ -171,7 +174,7 @@ func ParseAPTConfigFolder(folderPath string) (RepositoryList, error) {
171174 return res , nil
172175}
173176
174- // AddRepository adds the specified repository to the specified APT
177+ // AddRepository adds the specified repository by changing the specified APT
175178// config folder (usually /etc/apt). The new repository is saved into
176179// a file named "managed.list"
177180func AddRepository (repo * Repository , configFolderPath string ) error {
@@ -242,8 +245,8 @@ func RemoveRepository(repo *Repository, configFolderPath string) error {
242245 return nil
243246}
244247
245- // EditRepository replace the an old repo configuration with a new repo
246- // configuration found in the specified APT config folder (usually /etc/apt).
248+ // EditRepository replace an old repo configuration with a new repo
249+ // configuration in the specified APT config folder (usually /etc/apt).
247250func EditRepository (old * Repository , new * Repository , configFolderPath string ) error {
248251 // Read all repos configurations
249252 repos , err := ParseAPTConfigFolder (configFolderPath )
0 commit comments