Ejemplo n.º 1
0
// startServer
func main() {
	config = cfg.Load("/etc/parcel/settings.ini")

	http.Handle("/", http.FileServer(http.Dir(config.Server.Rootdir)))
	if err := http.ListenAndServe(":"+config.Server.Port, nil); err != nil {
		fmt.Println(err)
	}
}
Ejemplo n.º 2
0
// New parcel type
func New(rootDir string) *Parcel {
	config = cfg.Load("/etc/parcel/settings.ini")

	initDatabase(rootDir + config.Main.Databasedir + "/packages.db")

	return &Parcel{
		id:       0,
		program:  "''",
		name:     "''",
		version:  "''",
		build:    "0",
		arch:     "''",
		desc:     "''",
		deps:     "''",
		dist:     "''",
		group:    "''",
		homepage: "''",
		sha256:   "''",
		status:   "''",
	}
}
Ejemplo n.º 3
0
func cmds(app *cli.App) {
	app.Commands = []cli.Command{
		{
			Name:  "clean",
			Usage: "Clean package cache",
			Action: func(c *cli.Context) error {
				if len(c.Args()) == 1 {
					println(c.Args()[0])
				} else {
					cli.ShowSubcommandHelp(c)
				}
				return nil
			},
		},

		{
			Name:  "generate",
			Usage: "Generate package buildfiles",
			Action: func(c *cli.Context) error {
				if len(c.Args()) == 1 {
					println(c.Args()[0])
				} else {
					cli.ShowSubcommandHelp(c)
				}
				return nil
			},
		},

		{
			Name:  "info",
			Usage: "Print package info",
			Action: func(c *cli.Context) error {
				if len(c.Args()) == 1 {
					println(c.Args()[0])
				} else {
					cli.ShowSubcommandHelp(c)
				}
				return nil
			},
		},

		{
			Name:  "install",
			Usage: "Install packages",
			BashComplete: func(c *cli.Context) {
				flags := []string{
					"--force",
					"--no-script",
					"--skip-checksum",
				}
				if len(c.Args()) > 0 {
					return
				}
				for _, f := range flags {
					fmt.Println(f)
				}
			},
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "force, f",
					Usage: "Force install",
				},
				cli.BoolFlag{
					Name:  "no-script, n",
					Usage: "Do not run install script",
				},
				cli.BoolFlag{
					Name:  "skip-checksum, s",
					Usage: "Skip checksum",
				},
			},
			Action: func(c *cli.Context) error {
				if len(c.Args()) > 0 {
					for i := 0; i < len(c.Args()); i++ {
						p := parcel.New(c.GlobalString("root"))
						p.Install(c.Args()[i], c)
					}
				} else {
					cli.ShowSubcommandHelp(c)
				}
				return nil
			},
		},

		{
			Name:  "list",
			Usage: "List packages",
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "all, a",
					Usage: "List all info",
				},
				cli.BoolFlag{
					Name:  "checksum, c",
					Usage: "List installation status",
				},
				cli.BoolFlag{
					Name:  "description, d",
					Usage: "List description",
				},
				cli.BoolFlag{
					Name:  "status, s",
					Usage: "List installation status",
				},
			},
			Action: func(c *cli.Context) error {
				p := parcel.New(c.GlobalString("root"))
				p.List(c)
				return nil
			},
		},

		{
			Name:  "make",
			Usage: "Make package from source",
			Action: func(c *cli.Context) error {
				p := parcel.New(c.GlobalString("root"))
				if _, err := os.Stat("Makefile"); err == nil {
					p.Make(c.Args())
				} else {
					cli.ShowSubcommandHelp(c)
				}
				return nil
			},
		},

		{
			Name:  "pack",
			Usage: "Pack package tarball",
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "test, t",
					Usage: "Test package. Do not update database.",
				},
			},
			Action: func(c *cli.Context) error {
				p := parcel.New(c.GlobalString("root"))
				if _, err := os.Stat("Makefile"); err == nil && len(c.Args()) == 2 {
					p.Pack(c)
				} else {
					cli.ShowSubcommandHelp(c)
				}
				return nil
			},
		},

		{
			Name:  "fetch",
			Usage: "Fetch package from server",
			Action: func(c *cli.Context) error {
				p := parcel.New(c.GlobalString("root"))
				if len(c.Args()) == 1 {
					p.Fetch(c.Args()[0], "/")
				} else {
					cli.ShowSubcommandHelp(c)
				}
				return nil
			},
		},

		{
			Name:  "remove",
			Usage: "Remove packages",
			Action: func(c *cli.Context) error {
				if len(c.Args()) == 1 {
					println(c.Args()[0])
				} else {
					cli.ShowSubcommandHelp(c)
				}
				return nil
			},
		},

		{
			Name:  "search",
			Usage: "Search for packages",
			Action: func(c *cli.Context) error {
				if len(c.Args()) == 1 {
					println(c.Args()[0])
				} else {
					cli.ShowSubcommandHelp(c)
				}
				return nil
			},
		},

		{
			Name:  "show",
			Usage: "Show package files",
			Action: func(c *cli.Context) error {
				if len(c.Args()) == 1 {
					println(c.Args()[0])
				} else {
					cli.ShowSubcommandHelp(c)
				}
				return nil
			},
		},

		{
			Name:  "update",
			Usage: "Update package database",
			Action: func(c *cli.Context) error {
				config := cfg.Load("/etc/parcel/settings.ini")
				parcel.UpdateDatabase(c.GlobalString("root"), config)
				return nil
			},
		},
	}
}