feat: support build arm&&arm64 dfget (#1286)
Signed-off-by: Jim Ma <majinjing3@gmail.com>
This commit is contained in:
parent
8b9230ae88
commit
4e08126f55
|
|
@ -20,7 +20,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gofrs/flock"
|
"github.com/gofrs/flock"
|
||||||
|
|
@ -92,13 +91,13 @@ func redirectStdoutAndStderr(console bool, logDir string) {
|
||||||
stdoutPath := path.Join(logDir, "daemon", "stdout.log")
|
stdoutPath := path.Join(logDir, "daemon", "stdout.log")
|
||||||
if stdout, err := os.OpenFile(stdoutPath, os.O_WRONLY|os.O_CREATE|os.O_APPEND|os.O_SYNC, 0644); err != nil {
|
if stdout, err := os.OpenFile(stdoutPath, os.O_WRONLY|os.O_CREATE|os.O_APPEND|os.O_SYNC, 0644); err != nil {
|
||||||
logger.Warnf("open %s error: %s", stdoutPath, err)
|
logger.Warnf("open %s error: %s", stdoutPath, err)
|
||||||
} else if err := syscall.Dup2(int(stdout.Fd()), 1); err != nil {
|
} else if err := dup2(int(stdout.Fd()), 1); err != nil {
|
||||||
logger.Warnf("redirect stdout error: %s", err)
|
logger.Warnf("redirect stdout error: %s", err)
|
||||||
}
|
}
|
||||||
stderrPath := path.Join(logDir, "daemon", "stderr.log")
|
stderrPath := path.Join(logDir, "daemon", "stderr.log")
|
||||||
if stderr, err := os.OpenFile(stderrPath, os.O_WRONLY|os.O_CREATE|os.O_APPEND|os.O_SYNC, 0644); err != nil {
|
if stderr, err := os.OpenFile(stderrPath, os.O_WRONLY|os.O_CREATE|os.O_APPEND|os.O_SYNC, 0644); err != nil {
|
||||||
logger.Warnf("open %s error: %s", stderrPath, err)
|
logger.Warnf("open %s error: %s", stderrPath, err)
|
||||||
} else if err := syscall.Dup2(int(stderr.Fd()), 2); err != nil {
|
} else if err := dup2(int(stderr.Fd()), 2); err != nil {
|
||||||
logger.Warnf("redirect stderr error: %s", err)
|
logger.Warnf("redirect stderr error: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
//go:build !windows && !arm && !arm64
|
||||||
|
// +build !windows,!arm,!arm64
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2022 The Dragonfly Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func dup2(from int, to int) (err error) {
|
||||||
|
return syscall.Dup2(from, to)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
//go:build !windows && (arm || arm64)
|
||||||
|
// +build !windows
|
||||||
|
// +build arm arm64
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2022 The Dragonfly Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func dup2(from int, to int) (err error) {
|
||||||
|
// linux_arm64 platform doesn't have syscall.Dup2
|
||||||
|
// so use the nearly identical syscall.Dup3 instead.
|
||||||
|
return syscall.Dup3(from, to, 0)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue