mirror of
https://github.com/Jguer/yay
synced 2024-07-01 07:56:37 +00:00
Compare commits
5 Commits
0263bf7734
...
3fc021b8ac
Author | SHA1 | Date | |
---|---|---|---|
|
3fc021b8ac | ||
|
9ed9b0b4e1 | ||
|
ecd25a894f | ||
|
494b22470a | ||
|
24845d30a9 |
|
@ -35,10 +35,10 @@ If you are migrating from another AUR helper, you can simply install Yay with th
|
|||
The initial installation of Yay can be done by cloning the PKGBUILD and
|
||||
building with makepkg:
|
||||
|
||||
We start with updating the package lists and make sure we have the `base-devel` package group installed.
|
||||
We make sure we have the `base-devel` package group installed.
|
||||
|
||||
```sh
|
||||
pacman -Sy --needed git base-devel
|
||||
pacman -S --needed git base-devel
|
||||
git clone https://aur.archlinux.org/yay.git
|
||||
cd yay
|
||||
makepkg -si
|
||||
|
|
|
@ -272,13 +272,13 @@ func Test_getPackageRepoURL(t *testing.T) {
|
|||
func TestABSPKGBUILDRepo(t *testing.T) {
|
||||
t.Parallel()
|
||||
cmdRunner := &testRunner{}
|
||||
want := "/usr/local/bin/git --no-replace-objects -C /tmp/doesnt-exist clone --no-progress --single-branch https://gitlab.archlinux.org/archlinux/packaging/packages/linux.git linux"
|
||||
want := "/usr/local/bin/git --no-replace-objects -C /tmp/doesnt-exist clone --no-progress --origin=origin --single-branch https://gitlab.archlinux.org/archlinux/packaging/packages/linux.git linux"
|
||||
if os.Getuid() == 0 {
|
||||
ld := "systemd-run"
|
||||
if path, _ := exec.LookPath(ld); path != "" {
|
||||
ld = path
|
||||
}
|
||||
want = fmt.Sprintf("%s --service-type=oneshot --pipe --wait --pty --quiet -p DynamicUser=yes -p CacheDirectory=yay -E HOME=/tmp --no-replace-objects -C /tmp/doesnt-exist clone --no-progress --single-branch https://gitlab.archlinux.org/archlinux/packaging/packages/linux.git linux", ld)
|
||||
want = fmt.Sprintf("%s --service-type=oneshot --pipe --wait --pty --quiet -p DynamicUser=yes -p CacheDirectory=yay -E HOME=/tmp --no-replace-objects -C /tmp/doesnt-exist clone --no-progress --origin=origin --single-branch https://gitlab.archlinux.org/archlinux/packaging/packages/linux.git linux", ld)
|
||||
}
|
||||
|
||||
cmdBuilder := &testGitBuilder{
|
||||
|
|
|
@ -81,13 +81,13 @@ func TestGetAURPkgbuild(t *testing.T) {
|
|||
// THEN a clone command should be formed
|
||||
func TestAURPKGBUILDRepo(t *testing.T) {
|
||||
t.Parallel()
|
||||
want := "/usr/local/bin/git --no-replace-objects -C /tmp/doesnt-exist clone --no-progress https://aur.archlinux.org/yay-bin.git yay-bin"
|
||||
want := "/usr/local/bin/git --no-replace-objects -C /tmp/doesnt-exist clone --no-progress --origin=origin https://aur.archlinux.org/yay-bin.git yay-bin"
|
||||
if os.Getuid() == 0 {
|
||||
ld := "systemd-run"
|
||||
if path, _ := exec.LookPath(ld); path != "" {
|
||||
ld = path
|
||||
}
|
||||
want = fmt.Sprintf("%s --service-type=oneshot --pipe --wait --pty --quiet -p DynamicUser=yes -p CacheDirectory=yay -E HOME=/tmp --no-replace-objects -C /tmp/doesnt-exist clone --no-progress https://aur.archlinux.org/yay-bin.git yay-bin", ld)
|
||||
want = fmt.Sprintf("%s --service-type=oneshot --pipe --wait --pty --quiet -p DynamicUser=yes -p CacheDirectory=yay -E HOME=/tmp --no-replace-objects -C /tmp/doesnt-exist clone --no-progress --origin=origin https://aur.archlinux.org/yay-bin.git yay-bin", ld)
|
||||
}
|
||||
|
||||
cmdRunner := &testRunner{}
|
||||
|
|
|
@ -44,7 +44,7 @@ func downloadGitRepo(ctx context.Context, cmdBuilder exe.GitCmdBuilder,
|
|||
gitArgs = append(gitArgs, pkgURL, pkgName)
|
||||
|
||||
cloneArgs := make([]string, 0, len(gitArgs)+4)
|
||||
cloneArgs = append(cloneArgs, "clone", "--no-progress")
|
||||
cloneArgs = append(cloneArgs, "clone", "--no-progress", "--origin=origin")
|
||||
cloneArgs = append(cloneArgs, gitArgs...)
|
||||
cmd := cmdBuilder.BuildGitCmd(ctx, dest, cloneArgs...)
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@ var gitDenyList = mapset.NewThreadUnsafeSet(
|
|||
"GIT_WORK_TREE",
|
||||
"GIT_DIR",
|
||||
)
|
||||
var gitConfigOverrides = map[string]string{
|
||||
"clone.defaultRemoteName": "origin",
|
||||
}
|
||||
|
||||
type GitCmdBuilder interface {
|
||||
Runner
|
||||
|
@ -113,6 +116,20 @@ func gitFilteredEnv() []string {
|
|||
return env
|
||||
}
|
||||
|
||||
func gitConfigEnv() []string {
|
||||
var env []string
|
||||
|
||||
count := 0
|
||||
for key, value := range gitConfigOverrides {
|
||||
env = append(env, fmt.Sprintf("GIT_CONFIG_KEY_%d=%s", count, key))
|
||||
env = append(env, fmt.Sprintf("GIT_CONFIG_VALUE_%d=%s", count, value))
|
||||
count++
|
||||
}
|
||||
env = append(env, "GIT_CONFIG_COUNT="+strconv.Itoa(count))
|
||||
|
||||
return env
|
||||
}
|
||||
|
||||
func (c *CmdBuilder) BuildGitCmd(ctx context.Context, dir string, extraArgs ...string) *exec.Cmd {
|
||||
args := make([]string, len(c.GitFlags), len(c.GitFlags)+len(extraArgs))
|
||||
copy(args, c.GitFlags)
|
||||
|
@ -128,6 +145,7 @@ func (c *CmdBuilder) BuildGitCmd(ctx context.Context, dir string, extraArgs ...s
|
|||
cmd := exec.CommandContext(ctx, c.GitBin, args...)
|
||||
|
||||
cmd.Env = gitFilteredEnv()
|
||||
cmd.Env = append(cmd.Env, gitConfigEnv()...)
|
||||
|
||||
cmd = c.deElevateCommand(ctx, cmd)
|
||||
|
||||
|
@ -153,6 +171,8 @@ func (c *CmdBuilder) BuildMakepkgCmd(ctx context.Context, dir string, extraArgs
|
|||
cmd := exec.CommandContext(ctx, c.MakepkgBin, args...)
|
||||
cmd.Dir = dir
|
||||
|
||||
cmd.Env = append(cmd.Env, gitConfigEnv()...)
|
||||
|
||||
cmd = c.deElevateCommand(ctx, cmd)
|
||||
|
||||
return cmd
|
||||
|
|
Loading…
Reference in New Issue
Block a user