mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
Ports: Introduce support for Git repositories
This commit is contained in:
parent
ce50dbb411
commit
e28ff48304
2 changed files with 94 additions and 8 deletions
|
@ -119,6 +119,10 @@ cd "${PORT_BUILD_DIR}"
|
||||||
# 2 = sha256sum
|
# 2 = sha256sum
|
||||||
FILES_SIMPLE_PATTERN='^(https?:\/\/.+)#([0-9a-f]{64})$'
|
FILES_SIMPLE_PATTERN='^(https?:\/\/.+)#([0-9a-f]{64})$'
|
||||||
|
|
||||||
|
# 1 = repository
|
||||||
|
# 2 = revision
|
||||||
|
FILES_GIT_PATTERN='^git\+(.+)#(.+)$'
|
||||||
|
|
||||||
cleanup_git() {
|
cleanup_git() {
|
||||||
echo "WARNING: Reverting changes to $workdir as we are in dev mode!"
|
echo "WARNING: Reverting changes to $workdir as we are in dev mode!"
|
||||||
run git clean -xffd >/dev/null 2>&1
|
run git clean -xffd >/dev/null 2>&1
|
||||||
|
@ -366,6 +370,38 @@ fetch_simple() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetch_git() {
|
||||||
|
repository="${1}"
|
||||||
|
revision="${2}"
|
||||||
|
|
||||||
|
directory="$(basename "${repository}")"
|
||||||
|
backing_copy="${PORT_META_DIR}/${directory}"
|
||||||
|
working_copy="${PORT_BUILD_DIR}/${directory}"
|
||||||
|
|
||||||
|
run_nocd git init --bare "${backing_copy}"
|
||||||
|
run_nocd git -C "${backing_copy}" config core.autocrlf false
|
||||||
|
run_nocd git -C "${backing_copy}" worktree prune
|
||||||
|
run_nocd git -C "${backing_copy}" fetch --tags "${repository}" "${revision}"
|
||||||
|
|
||||||
|
revision="$(git -C "${backing_copy}" rev-parse FETCH_HEAD)"
|
||||||
|
|
||||||
|
if [ ! -e "${working_copy}/.git" ]; then
|
||||||
|
run_nocd git -C "${backing_copy}" worktree add "${working_copy}" "${revision}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
old_revision=""
|
||||||
|
if [ -e "${backing_copy}/refs/tags/source" ]; then
|
||||||
|
old_revision="$(git -C "${working_copy}" rev-parse refs/tags/source)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [ "${old_revision}" = "${revision}" ]; then
|
||||||
|
run_nocd git -C "${working_copy}" clean -ffdx
|
||||||
|
run_nocd git -C "${working_copy}" reset --hard
|
||||||
|
run_nocd git -C "${working_copy}" tag --no-sign -f source "${revision}"
|
||||||
|
run_nocd git -C "${working_copy}" checkout "${revision}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# FIXME: Don't allow overriding fetch, support multiple protocols instead. See #20004
|
# FIXME: Don't allow overriding fetch, support multiple protocols instead. See #20004
|
||||||
func_defined fetch || fetch() {
|
func_defined fetch || fetch() {
|
||||||
pre_fetch
|
pre_fetch
|
||||||
|
@ -378,6 +414,13 @@ func_defined fetch || fetch() {
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "${f}" =~ ${FILES_GIT_PATTERN} ]]; then
|
||||||
|
repository="${BASH_REMATCH[1]}"
|
||||||
|
revision="${BASH_REMATCH[2]}"
|
||||||
|
fetch_git "${repository}" "${revision}"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
echo "error: Unknown syntax for files entry '${f}'"
|
echo "error: Unknown syntax for files entry '${f}'"
|
||||||
exit 1
|
exit 1
|
||||||
done
|
done
|
||||||
|
@ -394,16 +437,30 @@ func_defined pre_patch || pre_patch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func_defined patch_internal || patch_internal() {
|
func_defined patch_internal || patch_internal() {
|
||||||
|
if [ -n "${IN_SERENITY_PORT_DEV:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
# patch if it was not yet patched (applying patches multiple times doesn't work!)
|
# patch if it was not yet patched (applying patches multiple times doesn't work!)
|
||||||
if [ -z "${IN_SERENITY_PORT_DEV:-}" ] && [ -d "${PORT_META_DIR}/patches" ]; then
|
if [ -d "${PORT_META_DIR}/patches" ]; then
|
||||||
for filepath in "${PORT_META_DIR}"/patches/*.patch; do
|
for filepath in "${PORT_META_DIR}"/patches/*.patch; do
|
||||||
filename=$(basename $filepath)
|
filename=$(basename $filepath)
|
||||||
if [ ! -f "$workdir"/.${filename}_applied ]; then
|
if [ -f "$workdir"/.${filename}_applied ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e "${workdir}/.git" ]; then
|
||||||
|
run git am --keep-cr --keep-non-patch "${filepath}"
|
||||||
|
else
|
||||||
run patch -p"$patchlevel" < "$filepath"
|
run patch -p"$patchlevel" < "$filepath"
|
||||||
run touch .${filename}_applied
|
run touch .${filename}_applied
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -e "${workdir}/.git" ]; then
|
||||||
|
run git tag --no-sign -f patched
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
func_defined pre_configure || pre_configure() {
|
func_defined pre_configure || pre_configure() {
|
||||||
:
|
:
|
||||||
|
@ -440,6 +497,13 @@ clean_dist() {
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "${f}" =~ ${FILES_GIT_PATTERN} ]]; then
|
||||||
|
repository="${BASH_REMATCH[1]}"
|
||||||
|
directory=$(basename "$repository")
|
||||||
|
rm -rf "${PORT_META_DIR}/${directory}"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
echo "error: Unknown syntax for files entry '${f}'"
|
echo "error: Unknown syntax for files entry '${f}'"
|
||||||
exit 1
|
exit 1
|
||||||
done
|
done
|
||||||
|
@ -728,7 +792,7 @@ do_dev() {
|
||||||
if [ "${1:-}" != "--no-depends" ]; then
|
if [ "${1:-}" != "--no-depends" ]; then
|
||||||
do_installdepends
|
do_installdepends
|
||||||
fi
|
fi
|
||||||
if [ -d "$workdir" ] && [ ! -d "$workdir/.git" ]; then
|
if [ -d "$workdir" ] && [ ! -e "$workdir/.git" ]; then
|
||||||
if prompt_yes_no "- Would you like to clean the working directory (i.e. ./package.sh clean)?"; then
|
if prompt_yes_no "- Would you like to clean the working directory (i.e. ./package.sh clean)?"; then
|
||||||
do_clean
|
do_clean
|
||||||
fi
|
fi
|
||||||
|
@ -739,7 +803,7 @@ do_dev() {
|
||||||
[ -d "$workdir" ] || {
|
[ -d "$workdir" ] || {
|
||||||
do_fetch
|
do_fetch
|
||||||
pushd "$workdir"
|
pushd "$workdir"
|
||||||
if [ ! -d ".git" ]; then
|
if [ ! -e ".git" ]; then
|
||||||
git init .
|
git init .
|
||||||
git config core.autocrlf false
|
git config core.autocrlf false
|
||||||
git add --all --force
|
git add --all --force
|
||||||
|
@ -770,12 +834,12 @@ do_dev() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git tag --no-sign patched
|
git tag --no-sign -f patched
|
||||||
|
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -d "$workdir/.git" ] || {
|
[ -e "$workdir/.git" ] || {
|
||||||
>&2 echo "$workdir does not appear to be a git repository."
|
>&2 echo "$workdir does not appear to be a git repository."
|
||||||
>&2 echo "If you want to use './package.sh dev', please run './package.sh clean' first."
|
>&2 echo "If you want to use './package.sh dev', please run './package.sh clean' first."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -190,8 +190,11 @@ depends=(
|
||||||
|
|
||||||
#### `files`
|
#### `files`
|
||||||
|
|
||||||
An array of external files required by the port, one per line. The format of each
|
An array of external files required by the port, one per line.
|
||||||
entry is as follows:
|
|
||||||
|
##### Simple downloads
|
||||||
|
|
||||||
|
The format of each entry is as follows:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
URL#HASH
|
URL#HASH
|
||||||
|
@ -211,6 +214,25 @@ files=(
|
||||||
If a file is a compressed tar archive, a gzip compressed file or a zip
|
If a file is a compressed tar archive, a gzip compressed file or a zip
|
||||||
compressed file, it will be extracted.
|
compressed file, it will be extracted.
|
||||||
|
|
||||||
|
##### Git repositories
|
||||||
|
|
||||||
|
The format of each entry is as follows:
|
||||||
|
|
||||||
|
```text
|
||||||
|
git+URL#REVISION
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `URL` is the URL where the repository is located
|
||||||
|
and `REVISION` can be any revision qualifier that is accepted by `git fetch`.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
files=(
|
||||||
|
'git+https://gn.googlesource.com/gn#fae280eabe5d31accc53100137459ece19a7a295'
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
#### `icon_file`
|
#### `icon_file`
|
||||||
|
|
||||||
The file to use for the port launcher icon. The icon file is assumed to have a
|
The file to use for the port launcher icon. The icon file is assumed to have a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue