Example #1
0
func (s *Source) loadBackPANSource() error {
	log.Info("Loading BackPAN index: backpan-index")

	file, err := os.Open("backpan-index")
	if err != nil {
		log.Warn(err.Error())
		return nil
	}

	index, err := ioutil.ReadAll(file)
	file.Close()
	if err != nil {
		log.Fatal(err)
	}

	for _, p := range strings.Split(string(index), "\n") {
		if !strings.HasPrefix(p, "authors/id/") {
			continue
		}

		//log.Printf("Parsing: %s\n", p)
		m := s.ModuleFromBackPANIndex(p)
		if m != nil {
			s.ModuleList[m.Name+"-"+m.Version] = m
		}
	}

	log.Printf("Found %d packages for source: %s", len(s.ModuleList), s)
	return nil
}
Example #2
0
func NewSource(Type string, Index string, URL string) *Source {
	priority := 1000

	matches := sourceRe.FindStringSubmatch(URL)

	if len(matches[1]) > 0 {
		i, err := strconv.Atoi(strings.TrimSuffix(matches[1], ":"))
		if err != nil {
			log.Fatal(err)
		}
		priority = i
		URL = strings.TrimPrefix(URL, matches[1])
	}

	return &Source{
		Priority:   priority,
		Type:       Type,
		Index:      Index,
		URL:        URL,
		ModuleList: make(map[string]*Module),
	}
}
Example #3
0
File: util.go Project: djui/necd
func Assert(cond bool, msg string) {
	if !cond {
		log.Fatal(msg)
	}
}