forked from ALHP/ALHP.GO
moved all working dirs into a workdir structure
This commit is contained in:
@@ -27,10 +27,7 @@ db:
|
|||||||
|
|
||||||
basedir:
|
basedir:
|
||||||
repo: /var/lib/alhp/repo/
|
repo: /var/lib/alhp/repo/
|
||||||
chroot: /var/lib/alhp/chroot/
|
work: /var/lib/alhp/chroot/
|
||||||
makepkg: /var/lib/alhp/makepkg/
|
|
||||||
upstream: /var/lib/alhp/upstream/
|
|
||||||
build: /var/lib/alhp/build/
|
|
||||||
|
|
||||||
march:
|
march:
|
||||||
- x86-64-v3
|
- x86-64-v3
|
||||||
|
14
main.go
14
main.go
@@ -124,8 +124,8 @@ func (b *BuildManager) buildWorker(id int, march string) {
|
|||||||
makepkgFile = "makepkg-%s.conf"
|
makepkgFile = "makepkg-%s.conf"
|
||||||
}
|
}
|
||||||
cmd := exec.Command("sh", "-c",
|
cmd := exec.Command("sh", "-c",
|
||||||
"cd "+filepath.Dir(pkg.Pkgbuild)+"&&makechrootpkg -c -D "+conf.Basedir.Makepkg+" -l worker-"+march+"-"+strconv.Itoa(id)+" -r "+conf.Basedir.Chroot+" -- "+
|
"cd "+filepath.Dir(pkg.Pkgbuild)+"&&makechrootpkg -c -D "+filepath.Join(conf.Basedir.Work, makepkgDir)+" -l worker-"+march+"-"+strconv.Itoa(id)+" -r "+filepath.Join(conf.Basedir.Work, chrootDir)+" -- "+
|
||||||
"-m --noprogressbar --config "+filepath.Join(conf.Basedir.Makepkg, fmt.Sprintf(makepkgFile, pkg.March)))
|
"-m --noprogressbar --config "+filepath.Join(conf.Basedir.Work, makepkgDir, fmt.Sprintf(makepkgFile, pkg.March)))
|
||||||
var out bytes.Buffer
|
var out bytes.Buffer
|
||||||
cmd.Stdout = &out
|
cmd.Stdout = &out
|
||||||
cmd.Stderr = &out
|
cmd.Stderr = &out
|
||||||
@@ -603,7 +603,7 @@ func (b *BuildManager) repoWorker(repo string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *BuildManager) syncWorker() {
|
func (b *BuildManager) syncWorker() {
|
||||||
check(os.MkdirAll(conf.Basedir.Upstream, 0755))
|
check(os.MkdirAll(filepath.Join(conf.Basedir.Work, upstreamDir), 0755))
|
||||||
|
|
||||||
for i := 0; i < runtime.NumCPU(); i++ {
|
for i := 0; i < runtime.NumCPU(); i++ {
|
||||||
go b.parseWorker()
|
go b.parseWorker()
|
||||||
@@ -613,7 +613,7 @@ func (b *BuildManager) syncWorker() {
|
|||||||
b.buildWG.Wait()
|
b.buildWG.Wait()
|
||||||
|
|
||||||
for gitDir, gitURL := range conf.Svn2git {
|
for gitDir, gitURL := range conf.Svn2git {
|
||||||
gitPath := filepath.Join(conf.Basedir.Upstream, gitDir)
|
gitPath := filepath.Join(conf.Basedir.Work, upstreamDir, gitDir)
|
||||||
|
|
||||||
if _, err := os.Stat(gitPath); os.IsNotExist(err) {
|
if _, err := os.Stat(gitPath); os.IsNotExist(err) {
|
||||||
cmd := exec.Command("git", "clone", "--depth=1", gitURL, gitPath)
|
cmd := exec.Command("git", "clone", "--depth=1", gitURL, gitPath)
|
||||||
@@ -659,7 +659,7 @@ func (b *BuildManager) syncWorker() {
|
|||||||
err = setupChroot()
|
err = setupChroot()
|
||||||
}
|
}
|
||||||
|
|
||||||
alpmHandle, err = initALPM(filepath.Join(conf.Basedir.Chroot, pristineChroot), filepath.Join(conf.Basedir.Chroot, pristineChroot, "/var/lib/pacman"))
|
alpmHandle, err = initALPM(filepath.Join(conf.Basedir.Work, chrootDir, pristineChroot), filepath.Join(conf.Basedir.Work, chrootDir, pristineChroot, "/var/lib/pacman"))
|
||||||
check(err)
|
check(err)
|
||||||
b.alpmMutex.Unlock()
|
b.alpmMutex.Unlock()
|
||||||
|
|
||||||
@@ -668,7 +668,7 @@ func (b *BuildManager) syncWorker() {
|
|||||||
b.queued = map[string]int{}
|
b.queued = map[string]int{}
|
||||||
b.queuedLock.Unlock()
|
b.queuedLock.Unlock()
|
||||||
|
|
||||||
pkgBuilds, err := Glob(filepath.Join(conf.Basedir.Upstream, "/**/PKGBUILD"))
|
pkgBuilds, err := Glob(filepath.Join(conf.Basedir.Work, upstreamDir, "/**/PKGBUILD"))
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
// Shuffle pkgbuilds to spread out long-running builds, otherwise pkgBuilds is alphabetically-sorted
|
// Shuffle pkgbuilds to spread out long-running builds, otherwise pkgBuilds is alphabetically-sorted
|
||||||
@@ -798,7 +798,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
syncMarchs()
|
syncMarchs()
|
||||||
|
|
||||||
alpmHandle, err = initALPM(filepath.Join(conf.Basedir.Chroot, pristineChroot), filepath.Join(conf.Basedir.Chroot, pristineChroot, "/var/lib/pacman"))
|
alpmHandle, err = initALPM(filepath.Join(conf.Basedir.Work, chrootDir, pristineChroot), filepath.Join(conf.Basedir.Work, chrootDir, pristineChroot, "/var/lib/pacman"))
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
go buildManager.syncWorker()
|
go buildManager.syncWorker()
|
||||||
|
28
utils.go
28
utils.go
@@ -32,7 +32,11 @@ const (
|
|||||||
makepkgConf = "/usr/share/devtools/makepkg-x86_64.conf"
|
makepkgConf = "/usr/share/devtools/makepkg-x86_64.conf"
|
||||||
logDir = "logs"
|
logDir = "logs"
|
||||||
pristineChroot = "root"
|
pristineChroot = "root"
|
||||||
|
buildDir = "build"
|
||||||
lastUpdate = "lastupdate"
|
lastUpdate = "lastupdate"
|
||||||
|
upstreamDir = "upstream"
|
||||||
|
chrootDir = "chroot"
|
||||||
|
makepkgDir = "makepkg"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -78,7 +82,7 @@ type Conf struct {
|
|||||||
Repos, March []string
|
Repos, March []string
|
||||||
Svn2git map[string]string
|
Svn2git map[string]string
|
||||||
Basedir struct {
|
Basedir struct {
|
||||||
Repo, Chroot, Makepkg, Upstream, Build string
|
Repo, Work string
|
||||||
}
|
}
|
||||||
Db struct {
|
Db struct {
|
||||||
Driver string
|
Driver string
|
||||||
@@ -221,7 +225,7 @@ func cleanBuildDir(dir string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *BuildPackage) setupBuildDir() (string, error) {
|
func (p *BuildPackage) setupBuildDir() (string, error) {
|
||||||
buildDir := filepath.Join(conf.Basedir.Build, p.March, p.Pkgbase+"-"+p.Version)
|
buildDir := filepath.Join(conf.Basedir.Work, buildDir, p.March, p.Pkgbase+"-"+p.Version)
|
||||||
|
|
||||||
err := cleanBuildDir(buildDir)
|
err := cleanBuildDir(buildDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -516,7 +520,7 @@ func (p *BuildPackage) SVN2GITVersion(h *alpm.Handle) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// upstream/upstream-core-extra/extra-cmake-modules/repos/extra-any/PKGBUILD
|
// upstream/upstream-core-extra/extra-cmake-modules/repos/extra-any/PKGBUILD
|
||||||
pkgBuilds, _ := Glob(filepath.Join(conf.Basedir.Upstream, "**/"+p.Pkgbase+"/repos/*/PKGBUILD"))
|
pkgBuilds, _ := Glob(filepath.Join(conf.Basedir.Work, upstreamDir, "**/"+p.Pkgbase+"/repos/*/PKGBUILD"))
|
||||||
|
|
||||||
var fPkgbuilds []string
|
var fPkgbuilds []string
|
||||||
for _, pkgbuild := range pkgBuilds {
|
for _, pkgbuild := range pkgBuilds {
|
||||||
@@ -569,7 +573,7 @@ func (p *BuildPackage) SVN2GITVersion(h *alpm.Handle) (string, error) {
|
|||||||
}
|
}
|
||||||
log.Infof("%s: resolving successful: MirrorRepo=%s; PKGBUILD chosen: %s", p.Pkgbase, iPackage.DB().Name(), fPkgbuilds[0])
|
log.Infof("%s: resolving successful: MirrorRepo=%s; PKGBUILD chosen: %s", p.Pkgbase, iPackage.DB().Name(), fPkgbuilds[0])
|
||||||
} else if len(fPkgbuilds) == 0 {
|
} else if len(fPkgbuilds) == 0 {
|
||||||
return "", fmt.Errorf("%s: no matching PKGBUILD found (searched: %s, canidates: %s)", p.Pkgbase, filepath.Join(conf.Basedir.Upstream, "**/"+p.Pkgbase+"/repos/*/PKGBUILD"), pkgBuilds)
|
return "", fmt.Errorf("%s: no matching PKGBUILD found (searched: %s, canidates: %s)", p.Pkgbase, filepath.Join(conf.Basedir.Work, upstreamDir, "**/"+p.Pkgbase+"/repos/*/PKGBUILD"), pkgBuilds)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command("sh", "-c", "cd "+filepath.Dir(fPkgbuilds[0])+"&&"+"makepkg --printsrcinfo")
|
cmd := exec.Command("sh", "-c", "cd "+filepath.Dir(fPkgbuilds[0])+"&&"+"makepkg --printsrcinfo")
|
||||||
@@ -627,19 +631,19 @@ func (p *BuildPackage) genSrcinfo() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setupChroot() error {
|
func setupChroot() error {
|
||||||
if _, err := os.Stat(filepath.Join(conf.Basedir.Chroot, pristineChroot)); err == nil {
|
if _, err := os.Stat(filepath.Join(conf.Basedir.Work, chrootDir, pristineChroot)); err == nil {
|
||||||
//goland:noinspection SpellCheckingInspection
|
//goland:noinspection SpellCheckingInspection
|
||||||
cmd := exec.Command("arch-nspawn", filepath.Join(conf.Basedir.Chroot, pristineChroot), "pacman", "-Syuu", "--noconfirm")
|
cmd := exec.Command("arch-nspawn", filepath.Join(conf.Basedir.Work, chrootDir, pristineChroot), "pacman", "-Syuu", "--noconfirm")
|
||||||
res, err := cmd.CombinedOutput()
|
res, err := cmd.CombinedOutput()
|
||||||
log.Debug(string(res))
|
log.Debug(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Unable to update chroot: %v\n%s", err, string(res))
|
return fmt.Errorf("Unable to update chroot: %v\n%s", err, string(res))
|
||||||
}
|
}
|
||||||
} else if os.IsNotExist(err) {
|
} else if os.IsNotExist(err) {
|
||||||
err := os.MkdirAll(conf.Basedir.Chroot, 0755)
|
err := os.MkdirAll(filepath.Join(conf.Basedir.Work, chrootDir), 0755)
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
cmd := exec.Command("mkarchroot", "-C", pacmanConf, filepath.Join(conf.Basedir.Chroot, pristineChroot), "base-devel")
|
cmd := exec.Command("mkarchroot", "-C", pacmanConf, filepath.Join(conf.Basedir.Work, chrootDir, pristineChroot), "base-devel")
|
||||||
res, err := cmd.CombinedOutput()
|
res, err := cmd.CombinedOutput()
|
||||||
log.Debug(string(res))
|
log.Debug(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -725,7 +729,7 @@ func housekeeping(repo string, wg *sync.WaitGroup) error {
|
|||||||
case dbpackage.RepositoryCommunity:
|
case dbpackage.RepositoryCommunity:
|
||||||
upstream = "upstream-community"
|
upstream = "upstream-community"
|
||||||
}
|
}
|
||||||
pkg.Pkgbuild = filepath.Join(conf.Basedir.Upstream, upstream, dbPkg.Pkgbase, "repos", pkg.DbPackage.Repository.String()+"-"+conf.Arch, "PKGBUILD")
|
pkg.Pkgbuild = filepath.Join(conf.Basedir.Work, upstreamDir, upstream, dbPkg.Pkgbase, "repos", pkg.DbPackage.Repository.String()+"-"+conf.Arch, "PKGBUILD")
|
||||||
|
|
||||||
// check if package is still part of repo
|
// check if package is still part of repo
|
||||||
dbs, err := alpmHandle.SyncDBs()
|
dbs, err := alpmHandle.SyncDBs()
|
||||||
@@ -882,10 +886,10 @@ func syncMarchs() {
|
|||||||
|
|
||||||
//goland:noinspection SpellCheckingInspection
|
//goland:noinspection SpellCheckingInspection
|
||||||
func setupMakepkg(march string) error {
|
func setupMakepkg(march string) error {
|
||||||
lMakepkg := filepath.Join(conf.Basedir.Makepkg, fmt.Sprintf("makepkg-%s.conf", march))
|
lMakepkg := filepath.Join(conf.Basedir.Work, makepkgDir, fmt.Sprintf("makepkg-%s.conf", march))
|
||||||
lMakepkgLTO := filepath.Join(conf.Basedir.Makepkg, fmt.Sprintf("makepkg-%s-lto.conf", march))
|
lMakepkgLTO := filepath.Join(conf.Basedir.Work, makepkgDir, fmt.Sprintf("makepkg-%s-lto.conf", march))
|
||||||
|
|
||||||
err := os.MkdirAll(conf.Basedir.Makepkg, 0755)
|
err := os.MkdirAll(filepath.Join(conf.Basedir.Work, makepkgDir), 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user