Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/enhancements #67

Merged
merged 3 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build/deploy/rocky-8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ RUN \
dnf -y install \
bash-completion \
ca-certificates \
dnf-plugins-core \
rpm-build \
sudo; \
dnf config-manager --enable devel; \
dnf config-manager --enable powertools; \
yap completion bash > /etc/bash_completion.d/yap; \
echo "source /usr/share/bash-completion/bash_completion" >> /etc/bashrc; \
dnf clean all
Expand Down
3 changes: 3 additions & 0 deletions build/deploy/rocky-9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ RUN \
dnf -y install \
bash-completion \
ca-certificates \
dnf-plugins-core \
rpm-build \
sudo; \
dnf config-manager --enable crb; \
dnf config-manager --enable devel; \
yap completion bash > /etc/bash_completion.d/yap; \
echo "source /usr/share/bash-completion/bash_completion" >> /etc/bashrc; \
dnf clean all
Expand Down
4 changes: 3 additions & 1 deletion cmd/yap/command/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
utils.Logger.Args("error", err))
}

if project.CleanBuild {
if project.CleanBuild || project.Zap {
if err := mpc.Clean(); err != nil {
utils.Logger.Fatal("fatal error",
utils.Logger.Args("error", err))
Expand Down Expand Up @@ -70,4 +70,6 @@ func init() {
"to", "", "", "Build until a defined package name")
buildCmd.PersistentFlags().BoolVarP(&pkgbuild.Verbose,
"verbose", "v", false, "Verbose output")
buildCmd.Flags().BoolVarP(&project.Zap,
"zap", "z", false, "Remove entire staging dir before building the package")
}
51 changes: 51 additions & 0 deletions cmd/yap/command/zap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package command

import (
"path/filepath"
"strings"

"github.com/M0Rf30/yap/pkg/project"
"github.com/M0Rf30/yap/pkg/utils"
"github.com/spf13/cobra"
)

var (
// zapCmd represents the command to build the entire project.
zapCmd = &cobra.Command{
Use: "zap [target] [path]",
Short: "Deeply clean the build environment of a project",
Args: cobra.MinimumNArgs(2),
Run: func(_ *cobra.Command, args []string) {
fullJSONPath, _ := filepath.Abs(args[1])
split := strings.Split(args[0], "-")
distro := split[0]
release := ""

if len(split) > 1 {
release = split[1]
}

mpc := project.MultipleProject{}
err := mpc.MultiProject(distro, release, fullJSONPath)
if err != nil {
utils.Logger.Fatal("fatal error",
utils.Logger.Args("error", err))
}

if err := mpc.Clean(); err != nil {
utils.Logger.Fatal("fatal error",
utils.Logger.Args("error", err))
}

utils.Logger.Info("zap done", utils.Logger.Args("distro", distro, "release", release))
},
}
)

func init() {
rootCmd.AddCommand(zapCmd)

project.NoMakeDeps = true
project.SkipSyncDeps = true
project.Zap = true
}
2 changes: 2 additions & 0 deletions pkg/dpkg/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package dpkg
var buildEnvironmentDeps = []string{
"autoconf",
"build-essential",
"libltdl7",
"libtool",
"reprepro",
"tzdata",
"ca-certificates",
Expand Down
7 changes: 7 additions & 0 deletions pkg/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
NoBuild bool
NoMakeDeps bool
SkipSyncDeps bool
Zap bool
)

// FromPkgName is used to start the build process from a specific package.
Expand Down Expand Up @@ -141,6 +142,12 @@ func (mpc *MultipleProject) Clean() error {
return err
}
}

if Zap {
if err := utils.RemoveAll(project.Builder.PKGBUILD.StartDir); err != nil {
return err
}
}
}

return nil
Expand Down
3 changes: 3 additions & 0 deletions pkg/rpm/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ const (
)

var buildEnvironmentDeps = []string{
"autoconf",
"automake",
"createrepo",
"expect",
"gcc",
"gcc-c++",
"libtool-ltdl",
"libtool-ltdl-devel",
"make",
"openssl",
"rpm-sign",
Expand Down