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

WIP 🚧 TO BE SPLIT UP: Some new features added #94

Open
wants to merge 45 commits into
base: master
Choose a base branch
from

Conversation

hydra1983
Copy link

@hydra1983 hydra1983 commented Nov 7, 2017

  • Add break mode with option -b for both install and uninstall

In break mode, global install and local install do the same thing which is going to download files to specified dirs.

  • Install from local git repo
  • Install from public remote git repo other than github.com, private git repo is not considered to support
# local git repo
bpkg install .

# coding.net
bpkg install https://coding.net/u/{user}/p/{project}

# self hosted gitlab
bpkg install https://{gitlabhost}/{group}/{project}
bpkg install https://{gitlabhost}/{group}/{subgroup}/{project}

# github.com
bpkg install https://github.com/{user}/{project}

Tested sites including github.com, coding.net and self hosted gitlab

  • Add uninstall command
# local git repo
bpkg uninstall .

# coding.net
bpkg uninstall https://coding.net/u/{user}/p/{project}

# self hosted gitlab
bpkg uninstall https://{gitlabhost}/{group}/{project}
bpkg uninstall https://{gitlabhost}/{group}/{subgroup}/{project}

# github.com
bpkg uninstall https://github.com/{user}/{project}

In break mode, uninstall will remove the files in specified dirs directly. In legacy mode(without -b option), for local installation, the behavior is the same as break mode, for global installation, make uninstall will be executed

  • A __load func is added to import script from project and project dependencies

Import script from project

$ tree
.
β”œβ”€β”€ lib
β”‚Β Β  β”œβ”€β”€ myshlib1.sh
β”‚Β Β  └── myshlib2.sh
β”œβ”€β”€ mysh
└── package.json

$ cat mysh
__load "${BASH_SOURCE[0]}" "lib/myshlib1.sh"
__load "${BASH_SOURCE[0]}" "lib/myshlib2.sh"

Import sciprt from project dependencies

__load "${BASH_SOURCE[0]}" "shcore"
__load "${BASH_SOURCE[0]}" "shcompatibility"
__load "${BASH_SOURCE[0]}" "shlogging"

${BASH_SOURCE[0]} is required as I cannot find a better way to locate the script path at runtime

For developers, to support legacy mode, in the Makefile, the deps should be installed and copied to share dir as __load func will check the existence of ${script_dir}/../share/${script_name} to determine how to load deps. Below is an example

PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
SHAREDIR=$(PREFIX)/share/$(SCRIPT)

CP = cp -rvfa
RM = rm -rfv
MKDIR = mkdir -p

install:
	$(MKDIR) $(BINDIR)
	$(CP) $(SCRIPT) $(BINDIR)/$(SCRIPT)
	chmod a+x $(BINDIR)/$(SCRIPT)
	
	$(MKDIR) $(SHAREDIR)
	cp -t $(SHAREDIR) -r vendor

	bpkg getdeps
	[[ -d deps ]] && cp -t $(SHAREDIR) -r deps

uninstall:
	rm -f $(BINDIR)/$(SCRIPT)
	rm -rf $(SHAREDIR)
  • Prefer using BPKG_LOG_LEVEL instead of LOG_LEVEL
BPKG_LOG_LEVEL="${BPKG_LOG_LEVEL:-${LOG_LEVEL:-2}}"
  • Add Personal Access Token support
BPKG_LOG_LEVEL=1 bpkg install "raw-access|{gitlab_access_token}|https://{gitlabhost}/{group}/{project}@{tag}" -b

By the way, thanks for math.boyaval who sent me the code through gmail. @mbl-35 is that you?

  • Add BPKG_PKG_PREFIX to overwrite default deps dir
BPKG_PKG_PREFIX="bpkg_modules" bpkg install "raw-access|{gitlab_access_token}|https://{gitlabhost}/{group}/{project}@{tag}" -b

You can also set BPKG_PKG_PREFIX in /etc/bpkgrc, ${HOME}/.bpkgrc or $(pwd)/.bpkgrc

@hydra1983 hydra1983 changed the title Add coding.net and gitlab support Add full url and coding.net and gitlab support Nov 7, 2017
@hydra1983 hydra1983 changed the title Add full url and coding.net and gitlab support Add full url support for coding.net and self hosted gitlab and github.com Nov 7, 2017
Copy link
Member

@stephenmathieson stephenmathieson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we're expecting users to include the hostname when installing packages with this change.

I don't think that's a breaking change we should be making right now. Can you refactor so we (continue to) default to github instead?

README.md Outdated
@@ -52,6 +52,12 @@ Paste the following on your shell and you're good to go:
$ curl -Lo- "https://raw.githubusercontent.com/bpkg/bpkg/master/setup.sh" | bash
```

Or
```sh
$ curl -Lo- "https://coding.net/u/hydra1983/p/bpkg/git/raw/master/setup.sh" | \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should suggest installing bpkg from your fork.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about this, I will remove it :D

@@ -112,6 +118,22 @@ As a bonus, you can specify a **specific version**:
$ bpkg install jwerle/suggest.sh@0.0.1 -g
```

Install from github directly
```sh
bpkg install "https://github.com/{user}/{project}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why include the host here?

Copy link
Author

@hydra1983 hydra1983 Nov 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the host is not included, the line below will work

BPKG_REMOTES[0]=${BPKG_REMOTE-https://raw.githubusercontent.com}

It means the default behavior is still supported. And you can install from github as

 bpkg install hydra1983/shlog                                                                                                                                          ξ‚² 10:31   17-11-08

    info: Install /hydra1983/shlog/master from remote https://raw.githubusercontent.com [https://github.com]
    check: https://raw.githubusercontent.com
    check: https://raw.githubusercontent.com/hydra1983/shlog/master/package.json?1510108773
    fetch: https://raw.githubusercontent.com/hydra1983/shlog/master/package.json
    write: /Users/edison/tmp/deps/shlog/package.json
    fetch: https://raw.githubusercontent.com/hydra1983/shlog/master/shlog
    write: /Users/edison/tmp/deps/shlog/shlog
    shlog to PATH: /Users/edison/tmp/deps/bin/shlog
    fetch: https://raw.githubusercontent.com/hydra1983/shlog/master/README.md
    write: /Users/edison/tmp/deps/shlog/README.md
    fetch: https://raw.githubusercontent.com/hydra1983/shlog/master/shlog.1
    write: /Users/edison/tmp/deps/shlog/shlog.1

For this line

bpkg install "https://github.com/{user}/{project}"

It will not work until I refactored the code as the parsed repo and url is incorrect

@hydra1983 hydra1983 changed the title Add full url support for coding.net and self hosted gitlab and github.com Some new features added Nov 8, 2017
@mbl-35
Copy link

mbl-35 commented Nov 15, 2017

Very good job ... thanks for these new features. I am also interested in using gitlab private repos with authentication by Personal Access Token. But we should review the construction of curls queries (authentication passed in parameter by specifying the curls -u or --header parameters for each repository type). Maybe another raw-oauth type in the BPKG_REMOTES strings ?

This was referenced Nov 25, 2017
@hydra1983
Copy link
Author

It's sad that bpkg show is broken in this pull request

@cha87de
Copy link
Member

cha87de commented Jan 17, 2018

Great features, something we were discussing internally as well is to support other git locations and versions.

@hydra1983 Do you have any plans to extend different versions by adding git tags or git commit tokens to the install command? Something like https://{githost}/{group}/{project}:{version}, where version reflects a git tag or commit?

But I agree with other comments: the changes should not break current the bpkg behaviour but should be compatible with fallbacks etc

@mbl-35
Copy link

mbl-35 commented Jan 25, 2018

What does actually break the current bpkg behavour, blocking this Pull Request ?

@hydra1983
Copy link
Author

hydra1983 commented Feb 8, 2018

@cha87de I think bpkg install https://{githost}/{group}/{project}@{version} -b has been supported already. Here version reflects to a git tag, this is already being used in production env. But I take no tests with git commit.

@mbl-35 It's long after my last commit. I may spend some time on a breaking changes list if I can got some spare time. And I need to fix the conflicts before this merge request can be accepted.

In my plan, one new breaking change may be replacing package.json instead of bpkg.json, but package.json should also be supported for the legacy packages. Another one would be remove -b option from the install, uninstall, getdeps commands and make it as the default behavior.

Please verify the list below for the completion of the planed tasks.

  • Fix merge conflicts
  • Replacing package.json instead of bpkg.json
  • Make -b as the default behavior of related commands

Welcome for any suggestion.

@dexpota
Copy link

dexpota commented Jul 8, 2019

Any plan on fixing conflicts and merging?

@Potherca
Copy link
Member

Potherca commented Jul 27, 2019

I can't speak for any of the other maintainers, but for me, this MR is too large and tries to add too many things all at once.

Personally, I'd rather get the unit-tests and shellcheck issue sresolved (#72 and #78) and then break these changes up into smaller pieces (with tests) and merge them one thing at a time...

@hydra1983
Copy link
Author

hydra1983 commented Nov 15, 2019

@Potherca Good idea. :D.

Here is an update and new plan.

@jwerle
Copy link
Member

jwerle commented Nov 15, 2019

Looks like there are lots of goodies here but I would love to see this broken up into smaller PRs πŸ™

@Potherca
Copy link
Member

I've opened #116 to coordinate the effort to get these changes incorporated into the BPKG code-base.

@hydra1983
Copy link
Author

hydra1983 commented Nov 17, 2019

@Potherca Got it. Should I close this issue and working on the new issue?

@Potherca Potherca changed the title Some new features added WIP 🚧 TO BE SPLIT UP: Some new features added Nov 18, 2019
@Potherca
Copy link
Member

I've marked this pull-request as work-in-progress. We can leave it open for now, until all the work has been ported over into smaller PRs.

@reelsense
Copy link

reelsense commented Mar 18, 2020

bump #115

@hinell
Copy link

hinell commented Mar 19, 2021

Any progress here?

@Potherca
Copy link
Member

After the refactor of #140 and release of V1, several of the changes from this MR can be added/implemented.

Any news MRs will be listed and at #116

@Potherca Potherca self-assigned this Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants