Template for automatically tracking and building a package when the upstream Arch Linux project upgrade a new tag.
This template allow to rebuild a required by package if needed.
This can only be used at `Obcore` and `Obextra` repository. If you want to add a package to `Obcommunity`, use the [prototype-pkg](https://git.obarun.org/pkg/prototype-pkg) instead.
We are using the `acpid` package as an example. Therefore, substitute `acpid` with the one you require.
# Install for a new project
## Create a clone
Make a clone of this [repository](https://git.obarun.org/pkg/prototype-apkg)
- Under **Project visibility** pick **public** at drop-down menu.
## Schedule the project
Connect to [`gitlab`](https://git.obarun.org) obarun instance.
- On the left sidebar, select **Search or go to** and find your project.
- Select **Build** > **Pipeline schedules**.
- Select **New schedule** and fill the form. *Consider at least 24hours between schedule update*.
See complete gitlab [documentation](https://docs.gitlab.com/ee/ci/pipelines/schedules.html#add-a-pipeline-schedule) about pipeline schedule.
# diff directory explanation
This directory can be used to add files or other patch files depending of your needs.
It also allow you to define packages that need to be rebuild if `acpid` get a new tag from Arch upstream.
## diff/file
This directory is used to add extra files to the build directory. For example you may want to add a `acpid.install` file. This is the good place to do it. Simply add any files that you want and a verbatim copy will be made at `acpid` submodule directory before any build.
## diff/patch
This directory contains patch files as `PKG.patch` created automatically previously. You can place any patch file that you want is this directory but you need to conform to the `-Np1` option used by the runner script to patch the files. So, be sure to conform to this rule.
## diff/rebuild
This directory is used to define which packages need to be rebuild against a new project tag.
For instance, if `acpid` receives a new tag, you might also consider rebuilding `vte3`. Please note that this example is not meaningful as `vte3` does not have `acpid` as a dependency. It is provided purely for illustrative purposes.
In this scenario, just generate an empty file using the following syntax: `path@of@project`, where `@` substitutes for `/`.
For example create an empty file `pkg@obextra@vte3`.
```
touch diff/rebuild/pkg@obextra@vte3
```
At execution time the `@` will be replaced by `/` to retrieve the path of the projects `https://git.obarun.org/pkg/obextra/vte3`.
Create one file by project.
# Update an existing project
Go to a temporary directory, clone this template project.
Go to your local project directory to migrate. Obviously, replace the `/home/obarun/pkg/local/obcore/acpid` path with our specific path in this example.
```
cd /home/obarun/pkg/local/obcore/acpid
```
Remove all files and directories ***execpt*** the `.git` directory, we want to keep the history of the project.
Copy the templates files to your local project directory.
```
cp -rT /tmp/prototype-apkg .
```
Clean up the template clone directory
```
rm -rf /tmp/prototype-apkg
```
Follow the [Prepare the submodule](#prepare-the-submodule), [Prepare the necessary directories](#prepare-the-necessary-directories), [Make the patch file](#make-the-patch-file) and [Schedule the project](#schedule-the-project) instructions.
finally, Add, commit and push your changes
```
git add .
git commit -m"update to new format"
git push
```
# Reverse Patch Process
## Clone the Project
Begin by cloning the project from the Obarun GitLab instance using the following command:
```
git clone --recurse-submodules acpid
```
## Copy Patch Preparation Files
Copy the patch-prepare.sh and patch-make.sh files from the original [template](https://git.obarun.org/pkg/prototype-apkg).
Make sure these files are made executable. You can use the chmod command to do this:
```
chmod +x patch-prepare.sh patch-make.sh
```
## Execute the Patch Preparation Script
Run the `patch-prepare.sh` script, specifying the project name as an argument. This can be done as follows:
```
./patch-prepare.sh acpid
```
Change directory to the b/ directory:
```
cd b/
```
## Apply the Patch to the `PKGBUILD` File
Use the patch command to apply the patch to the `PKGBUILD` file. Be sure to specify the correct path to the PKG.patch patch file in the diff/patch/ directory. Using `-Np1` indicates the level of directory to skip in the patch path:
```
patch -Np1 -i ../diff/patch/PKG.patch
```
# Upgrading the Patch
Ensure that you are in the root directory of your project.
Execute the following command to fetch all the latest changes from the project repository:
```
git pull
```
Update the submodules using the following command to fetch the latest changes from the project's submodules:
```
git submodule update --remote --merge
```
Use the `patch-prepare.sh` script, specifying your project's name to prepare the patch. This can be done as follows:
```
./patch-prepare.sh acpid
```
Navigate to the `b/` directory where you need to can make changes to the necessary files.
Once you have made the required changes, execute the `patch-make.sh` script to finalize the patch:
```
./patch-make.sh
```
If desired, check the changes with the `git diff` command.
Add the changes to the staging area with the following command:
```
git add .
```
Commit the changes with an informative message regarding the patch update:
```
git commit -m "Update patch"
```
Finally, push the changes to your own Git repository using the command: