Skip to content

Commit

Permalink
Fix #120 Allow to build base.tgz with our own internal repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
herpiko committed Apr 26, 2021
1 parent e4ac931 commit c7cbc0d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
15 changes: 12 additions & 3 deletions cmd/builder/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/manifoldco/promptui"
)

func InitBase() (err error) {
func InitBase(useInternalRepo bool) (err error) {
logPath := irgshConfig.Builder.Workdir
logPath += "/irgsh-builder-init-base-" + uuid.New().String() + ".log"
go systemutil.StreamLog(logPath)
Expand Down Expand Up @@ -62,8 +62,17 @@ func InitBase() (err error) {
fmt.Printf("error: %v\n", err)
return
}

// Determine the upstream repo
upstreamDistUrl := irgshConfig.Repo.UpstreamDistUrl
upstreamDistCodename := irgshConfig.Repo.UpstreamDistCodename
if useInternalRepo {
upstreamDistUrl = irgshConfig.Repo.DistUrl // Use internal repo
upstreamDistCodename = irgshConfig.Repo.DistCodename
}

cmdStr = "pbuilder create --debootstrapopts --variant=buildd"
if strings.Contains(irgshConfig.Repo.UpstreamDistUrl, "debian") && (strings.Contains(distribution, "Ubuntu") ||
if (strings.Contains(upstreamDistUrl, "debian") || strings.Contains(upstreamDistUrl, "blankon")) && (strings.Contains(distribution, "Ubuntu") ||
strings.Contains(distribution, "Pop")) {
_, err = systemutil.CmdExec(
"apt-get update && apt-get -y install debian-archive-keyring",
Expand All @@ -74,7 +83,7 @@ func InitBase() (err error) {
fmt.Printf("error: %v\n", err)
return
}
cmdStr = "pbuilder create --distribution " + irgshConfig.Repo.UpstreamDistCodename + " --mirror " + irgshConfig.Repo.UpstreamDistUrl + " --debootstrapopts \"--keyring=/usr/share/keyrings/debian-archive-keyring.gpg\""
cmdStr = "pbuilder create --distribution " + upstreamDistCodename + " --mirror " + upstreamDistUrl + " --debootstrapopts \"--keyring=/usr/share/keyrings/debian-archive-keyring.gpg\""
}
_, err = systemutil.CmdExec(
cmdStr,
Expand Down
10 changes: 8 additions & 2 deletions cmd/builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ func main() {
Name: "init-base",
Aliases: []string{"i"},
Usage: "Initialize pbuilder base.tgz. This need to be run under sudo or root",
Action: func(c *cli.Context) error {
err := InitBase()
Flags: []cli.Flag{
cli.BoolFlag{
Name: "internalrepo",
Usage: "Use internal repo",
},
},
Action: func(ctx *cli.Context) error {
err := InitBase(ctx.Bool("internalrepo"))
return err
},
},
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type RepoConfig struct {
UpstreamDistUrl string `json:"upstream_dist_url" validate:"required"` // http://kartolo.sby.datautama.net.id/debian
UpstreamDistComponents string `json:"upstream_dist_components" validate:"required"` // main non-free>restricted contrib>extras
GnupgDir string `json:"gnupg_dir" validate:"required"` // GNUPG dir path
DistUrl string `json:"dist_url" validate:"required"` // http://arsip-dev.blankonlinux.or.id/blankon
}

// LoadConfig load irgsh config from file
Expand Down
1 change: 1 addition & 0 deletions utils/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ repo:
upstream_dist_url: 'http://kartolo.sby.datautama.net.id/debian'
upstream_dist_components: 'main non-free>restricted contrib>extras'
gnupg_dir: '/var/lib/irgsh/gnupg'
dist_url: 'http://arsip-dev.blankonlinux.or.id/blankon'

iso:
workdir: '/var/lib/irgsh/iso'
Expand Down

1 comment on commit c7cbc0d

@samsulmaarif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, without updating the /etc/irgsh/config.yml will cause :

$ irgsh-chief --version
2021/04/26 06:01:01 config.go:71: load config from :  /etc/irgsh/config.yml
2021/04/26 06:01:01 main.go:64: Key: 'IrgshConfig.Repo.DistUrl' Error:Field validation for 'DistUrl' failed on the 'required' tag

Please sign in to comment.