Closed mateusrovedaa closed 3 weeks ago
To run the script is necessary to setting up a env variable in .env.local
file to define the artifacts path.
ARTIFACTS_REPOSITORY_PATH=/opt/repman-artifacts
You need to pass the package name and the type.
$ sudo /opt/repman/current/resources/scripts/create-composer-package.sh wp-rocket-3.16.zip plugin
If you don't pass the package name and type, the script was run to all .zip in ARTIFACTS_REPOSITORY_PATH
.
$ sudo /opt/repman/current/resources/scripts/create-composer-package.sh wp-rocket-3.15.5.zip plugin
ls -lha /opt/repman/current/var/repo/
total 16K
drwxr-xr-x 4 repman repman 4.0K Jul 2 17:15 .
drwxr-xr-x 7 repman repman 4.0K Jun 21 17:58 ..
drwxr-xr-x 4 repman repman 4.0K Jul 2 17:15 aztec
drwxr-xr-x 2 repman repman 4.0K Jul 2 17:36 wp-rocket
$ ls -lha /opt/repman/current/var/repo/wp-rocket/
total 7.2M
drwxr-xr-x 2 repman repman 4.0K Jul 2 17:36 .
drwxr-xr-x 4 repman repman 4.0K Jul 2 17:15 ..
-rw-r--r-- 1 repman repman 3.5M Jul 2 17:36 wp-rocket-3.15.5.zip
-rw-r--r-- 1 repman repman 3.7M Jul 2 17:14 wp-rocket-3.16.zip
The Aztec folder is created when we use the sync command. The name is the same as the organization.
bash
$ ls -lha /opt/repman/current/var/repo/aztec/
total 16K
drwxr-xr-x 4 repman repman 4.0K Jul 2 17:15 .
drwxr-xr-x 4 repman repman 4.0K Jul 2 17:15 ..
drwxr-xr-x 3 repman repman 4.0K Jul 2 17:15 dist
drwxr-xr-x 3 repman repman 4.0K Jul 2 17:15 p
Test installing a package
I added the ARTIFACTS_REPOSITORY_PATH
variable on the .env
files that I think make senses (https://github.com/aztecweb/repman/pull/6/commits/87db6b2488e3a9dfc49080220616ed05c43249ca).
The script must validate if the package is already on Repman.
I'm my tests, I uploaded a new file and I executed the script again. In this execution I discovered that we first need to create the folder to store the packages, run the script and then add it to the interface.
$ sudo mkdir /opt/repman/shared/var/repo/wp-all-import-pro
$ sudo chown repman:repman /opt/repman/shared/var/repo/wp-all-import-pro
$ sudo /opt/repman/current/resources/scripts/create-composer-package.sh wp-all-import-pro-4.8.7.zip plugin
At the last, we need to create the package on interface.
Because of that, I create a new step into the script to create the folder if does not exists and output a message to create the package in Repman.
if ! package_exists; then
echo "${PACKAGE_NAME} package folder does not exists. Creating the folder... You need to create the package in Repman too."
mkdir "${package_destination}"
chown repman:repman "${package_destination}"
fi
I tested again with a non-exists package:
Before
$ ls -lha /opt/repman/current/var/repo/
total 20K
drwxr-xr-x 5 repman repman 4.0K Jul 19 14:59 .
drwxr-xr-x 7 repman repman 4.0K Jun 21 17:58 ..
drwxr-xr-x 4 repman repman 4.0K Jul 2 17:15 aztec
drwxr-xr-x 2 repman repman 4.0K Jul 19 14:59 wp-all-import-pro
drwxr-xr-x 2 repman repman 4.0K Jul 2 20:08 wp-rocket
After
$ sudo /opt/repman/current/resources/scripts/create-composer-package.sh ithemes-security-pro-8.5.0.zip plugin
...
+ [[ -d /opt/repman/releases/3112f9588bb37a58b0020692a36d6e3838d67047/var/repo/ithemes-security-pro ]]
+ echo -e '\033[31mithemes-security-pro package folder does not exists. Creating the folder... You need to create the package in Repman too.\033[0m'
ithemes-security-pro package folder does not exists. Creating the folder... You need to create the package in Repman too.
$ ls -lha /opt/repman/current/var/repo/
$ ls -lha /opt/repman/current/var/repo/
total 24K
drwxr-xr-x 6 repman repman 4.0K Jul 22 13:53 .
drwxr-xr-x 7 repman repman 4.0K Jun 21 17:58 ..
drwxr-xr-x 4 repman repman 4.0K Jul 2 17:15 aztec
drwxr-xr-x 2 repman repman 4.0K Jul 22 13:53 ithemes-security-pro
drwxr-xr-x 2 repman repman 4.0K Jul 19 14:59 wp-all-import-pro
drwxr-xr-x 2 repman repman 4.0K Jul 2 20:08 wp-rocket
The message is displayed in red to attract attention.
After that, I created the package in Repman UI.
I also created a new function to check if the script is running with sudo user.
Removed the issue script. We versioned it in another repository so as not to confuse it with repman files.
Create a script to make package artifacts available based on a repository.
The process to be followed will be:
Repository structure
plugin
theme
Artifact structure
oceanwp
wp-rocket