Skip to content

Commit 844aa9b

Browse files
authored
fix the mod setting when install (#362)
* fix the mod setting when install * do not use upx due to segmentation fault --------- Co-authored-by: Rick <[email protected]>
1 parent 03f8475 commit 844aa9b

File tree

7 files changed

+16
-28
lines changed

7 files changed

+16
-28
lines changed

.github/workflows/pull-request.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ jobs:
1717
id: go
1818
- name: Check out code into the Go module directory
1919
uses: actions/[email protected]
20-
- name: Upgrade upx
21-
run: |
22-
# try to fix https://github.com/jenkins-zh/jenkins-cli/issues/493
23-
wget https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz
24-
tar xvf upx-3.96-amd64_linux.tar.xz
25-
upx-3.96-amd64_linux/upx -V
26-
sudo mv upx-3.96-amd64_linux/upx $(which upx)
27-
upx -V
2820
- name: Run GoReleaser
2921
uses: goreleaser/[email protected]
3022
with:

.github/workflows/release.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ jobs:
1717
uses: actions/setup-go@v3
1818
with:
1919
go-version: 1.18
20-
- name: Upgrade upx
21-
run: |
22-
# try to fix https://github.com/jenkins-zh/jenkins-cli/issues/493
23-
wget https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz
24-
tar xvf upx-3.96-amd64_linux.tar.xz
25-
upx-3.96-amd64_linux/upx -V
26-
sudo mv upx-3.96-amd64_linux/upx $(which upx)
27-
rm -rf upx-3.96-amd64_linux
28-
rm -rf xvf upx-3.96-amd64_linux.tar.xz
29-
upx -V
3020
- name: Image Registry Login
3121
run: |
3222
docker login --username ${{ secrets.DOCKER_HUB_USER }} --password ${{secrets.DOCKER_HUB_TOKEN}}

.goreleaser.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ builds:
2222
goarch: arm64
2323
- goos: darwin
2424
goarch: arm
25-
hooks:
26-
post:
27-
- upx "{{ .Path }}"
2825
ldflags:
2926
- -X github.com/linuxsuren/cobra-extension/version.version={{.Version}}
3027
- -X github.com/linuxsuren/cobra-extension/version.commit={{.ShortCommit}}

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ Want to go through the code? [GitPod](https://gitpod.io/#https://github.com/linu
3535

3636
## Download
3737
```shell
38-
hd get https://github.com/jenkins-zh/jenkins-cli/releases/latest/download/jcli-linux-amd64.tar.gz --thread 6
38+
hd get https://github.com/jenkins-zh/jenkins-cli/releases/latest/download/mde-linux-amd64.tar.gz --thread 6
3939
```
4040

4141
Or use a simple way instead of typing the whole URL:
4242

4343
```shell
44-
hd get jcli
44+
hd get mde
4545
```
4646

4747
Or you might want to download a pre-released binary package from GitHub:
@@ -54,7 +54,8 @@ hd get --pre ks
5454
You can also install a package from GitHub:
5555

5656
```shell
57-
hd install jcli -t 6
57+
#!title: Install mde with specific threads
58+
hd install mde -t 6
5859
```
5960

6061
or install by a category name:

cmd/get.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,13 @@ func newGetCmd(ctx context.Context) (cmd *cobra.Command) {
4949
flags := cmd.Flags()
5050
opt.addFlags(flags)
5151
opt.addPlatformFlags(flags)
52+
opt.addDownloadFlags(flags)
5253
flags.StringVarP(&opt.Output, "output", "o", "", "Write output to <file> instead of stdout.")
5354
flags.BoolVarP(&opt.AcceptPreRelease, "accept-preRelease", "", false,
5455
"If you accept preRelease as the binary asset from GitHub")
5556
flags.BoolVarP(&opt.AcceptPreRelease, "pre", "", false,
5657
"Same with option --accept-preRelease")
5758
flags.BoolVarP(&opt.Force, "force", "f", false, "Overwrite the exist file if this is true")
58-
flags.IntVarP(&opt.Mod, "mod", "", -1, "The file permission, -1 means using the system default")
59-
flags.BoolVarP(&opt.SkipTLS, "skip-tls", "k", false, "Skip the TLS")
6059

6160
flags.DurationVarP(&opt.Timeout, "timeout", "", 15*time.Minute,
6261
`The default timeout in seconds with the HTTP request`)
@@ -143,6 +142,11 @@ const (
143142
ProviderGitee = "gitee"
144143
)
145144

145+
func (o *downloadOption) addDownloadFlags(flags *pflag.FlagSet) {
146+
flags.IntVarP(&o.Mod, "mod", "", -1, "The file permission, -1 means using the system default")
147+
flags.BoolVarP(&o.SkipTLS, "skip-tls", "k", false, "Skip the TLS")
148+
}
149+
146150
func (o *downloadOption) fetch() (err error) {
147151
if !o.Fetch {
148152
o.wait.Add(1)
@@ -331,7 +335,10 @@ func (o *downloadOption) runE(cmd *cobra.Command, args []string) (err error) {
331335

332336
// set file permission
333337
if o.Mod != -1 {
334-
err = sysos.Chmod(o.Output, fs.FileMode(o.Mod))
338+
logger.Printf("Setting file permission to %d", o.Mod)
339+
if err = sysos.Chmod(o.Output, fs.FileMode(o.Mod)); err != nil {
340+
return
341+
}
335342
}
336343

337344
if err == nil {

cmd/install.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Cannot find your desired package? Please run command: hd fetch --reset, then try
3939
flags := cmd.Flags()
4040
opt.addFlags(flags)
4141
opt.addPlatformFlags(flags)
42+
opt.addDownloadFlags(flags)
4243
flags.StringVarP(&opt.Category, "category", "c", "",
4344
"The category of the potentials packages")
4445
flags.BoolVarP(&opt.ShowProgress, "show-progress", "", true, "If show the progress of download")

pkg/net/multi_thread.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (d *MultiThreadDownloader) Download(targetURL, targetFilePath string, threa
146146

147147
// concat all these partial files
148148
var f *os.File
149-
if f, err = os.OpenFile(targetFilePath, os.O_CREATE|os.O_WRONLY, 0600); err == nil {
149+
if f, err = os.Create(targetFilePath); err == nil {
150150
defer func() {
151151
_ = f.Close()
152152
}()

0 commit comments

Comments
 (0)