You are not logged in.
this is my first try to make a PKGBUILD file
# Author: shamela team <shamela.ws>
# Maintainer: dj.zak <dz.wbdev@gmail.com>
pkgname=shamela
pkgver=4
pkgrel=1
pkgdesc="A digital library which enables you to download, read and search arabic books."
arch=('x86_64')
url="https://shamela.ws/page/download"
license=('custom')
depends=('wine' 'winetricks')
source=('shamela4.tar.xz::https://archive.org/download/shamela4.tar/shamela4.tar.xz')
sha256sums=("3b0db8b2f97419cb291c3a546cfd6adc65e911ffb2c717020b82f9778e16fdac")
package() {
cd $srcdir
mkdir -p "${pkgdir}/opt/${pkgname}"
mv "${srcdir}/shamela4/"* "${pkgdir}/opt/${pkgname}/"
mkdir -p "${pkgdir}/usr/bin/"
ln -s "/opt/$pkgname/launcher.exe" "$pkgdir/usr/bin/$pkgname"
}
post_install() {
cd /opt/${pkgname}
winetricks vb6run
}
this software is for windows, it can be launcher with: wine "filename.exe"
after installing this package with "makepkg -si" i can find it in the pamac-manager, but how to open it? there is no icon for the software in Application launcher
1- how to add an icon for the software in the application launcher?
i also want to add some DLLs to system32 folder in the winreprefix folder
2- how to print the winrepefix location so as to get the full path of system32?
3- how to add an icon to the software?
Offline
Read https://wiki.archlinux.org/title/Wine_p … guidelines
some additional comments :
menus / application launchers on linux rely on desktop entries .
Windows doesn't use those, you may have to create one yourself.
packages are only allowed to deal with systemwide stuff and forbidden to touch userspace.
read up on wine prefixes on the [url=https://wiki.archlinux.org/title/Wine[]archwiki wine page[/url] to understand why winetricks commands in a PKGBUILD won't work .
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Online
Read https://wiki.archlinux.org/title/Wine_p … guidelines
some additional comments :
menus / application launchers on linux rely on desktop entries .
Windows doesn't use those, you may have to create one yourself.packages are only allowed to deal with systemwide stuff and forbidden to touch userspace.
read up on wine prefixes on the [url=https://wiki.archlinux.org/title/Wine[]archwiki wine page[/url] to understand why winetricks commands in a PKGBUILD won't work .
what if i put that winetricks command in a file and i run that file command after installation? and then the command file will be deleted automatically?
Offline
No need to delete it, just make sure you add a test to verify this run is the first one so it doesn't get run multiple times.
Such things are typically done by adding a wrapper script to the package with the same name as the application will be placed in /usr/bin .
The wrapper script would replace the symlink you create with ln -s "/opt/$pkgname/launcher.exe" "$pkgdir/usr/bin/$pkgname" .
https://aur.archlinux.org/cgit/aur.git/ … reecol-git and https://aur.archlinux.org/cgit/aur.git/ … e?h=oolite are examples of such wrapper scripts.
P.S. The original versions of those 2 wrapper scripts were created by me long ago.
Last edited by Lone_Wolf (2024-04-06 10:00:35)
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Online
No need to delete it, just make sure you add a test to verify this run is the first one so it doesn't get run multiple times.
Such things are typically done by adding a wrapper script to the package with the same name as the application will be placed in /usr/bin .
The wrapper script would replace the symlink you create with ln -s "/opt/$pkgname/launcher.exe" "$pkgdir/usr/bin/$pkgname" .
https://aur.archlinux.org/cgit/aur.git/ … reecol-git and https://aur.archlinux.org/cgit/aur.git/ … e?h=oolite are examples of such wrapper scripts.
P.S. The original versions of those 2 wrapper scripts were created by me long ago.
thank you
but i did not understand how to use this code. i hope that you can help.
this is my current code:
pkgname=shamela
pkgver=4
pkgrel=1
pkgdesc="A digital library which enables you to download, read and search arabic books. to run it you need to install vb6run: 'winetricks vb6run'. "
arch=('x86_64')
url="https://shamela.ws/page/download"
license=('custom')
depends=('wine' 'winetricks')
source=('shamela4.tar.xz::https://archive.org/download/shamela4.tar/shamela4.tar.xz')
sha256sums=("3b0db8b2f97419cb291c3a546cfd6adc65e911ffb2c717020b82f9778e16fdac")
package() {
cd ${srcdir}
mkdir -p "${pkgdir}/opt/${pkgname}"
mv "${srcdir}/shamela4/"* "${pkgdir}/opt/${pkgname}/"
mkdir -p "${pkgdir}/usr/bin/"
# cp "${srcdir}/shamela.desktop" "${pkgdir}/usr/share/applications"
ln -s "/opt/$pkgname/launcher.exe" "$pkgdir/usr/bin/$pkgname" .
}
post_install() {
cd /opt/${pkgname}
winetricks vb6run
wine launcher.exe
}
my problem is: how to run the wintricks code -which is necessary- after installing the package
Last edited by ardv (2024-08-17 11:32:52)
Offline
PKGBUILDs don't have a post_install function , and winetricks doesn't work systemwide but per user .
You need to create a wrapper script called shamela.sh (or similar) with content like this
#!/bin/bash
cd /opt/shamela
winetricks vb6run
wine launcher.exe
Add that to the source array and regenerate checksums .
In package() you need to copy that script from $srcdir to $pkgdir/usr/bin .
Once you're sure the command works you should look at shamela.desktop and verify if it will execute the wrapper.
If it doesn't, you'll have to change it.
Note that when usng a bash-script in a package you should add bash to its depends array.
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Online
PKGBUILDs don't have a post_install function , and winetricks doesn't work systemwide but per user .
You need to create a wrapper script called shamela.sh (or similar) with content like this
#!/bin/bash cd /opt/shamela winetricks vb6run wine launcher.exe
Add that to the source array and regenerate checksums .
In package() you need to copy that script from $srcdir to $pkgdir/usr/bin .
Once you're sure the command works you should look at shamela.desktop and verify if it will execute the wrapper.
If it doesn't, you'll have to change it.Note that when usng a bash-script in a package you should add bash to its depends array.
thank you.
according to this page: https://man.archlinux.org/man/PKGBUILD.5 there is a post build in pckgbuild.
so, this is my new PKGBUILD file:
# Author: shamela team <shamela.ws>
# Maintainer: dj.zak <dz.wbdev@gmail.com>
pkgname=shamela
pkgver=4
pkgrel=1
pkgdesc="A digital library which enables you to download, read and search arabic books. to run it you need to install vb6run: 'winetricks vb6run'. "
arch=('x86_64')
url="https://shamela.ws/page/download"
license=('custom')
depends=('wine' 'winetricks' 'bash')
source=('shamela4.tar.xz::https://archive.org/download/shamela4.tar/shamela4.tar.xz')
sha256sums=("f1f29c99a98fdffd1cdcaf5ea626deee53186da0e43cf41b1c18fc3aafa99d5b")
package() {
cd "${srcdir}"
mkdir -p "${pkgdir}/opt/${pkgname}"
mv "${srcdir}/shamela4/"* "${pkgdir}/opt/${pkgname}/"
mkdir -p "${pkgdir}/usr/bin/"
cp "${srcdir}/shamela.sh" "$pkgdir/usr/bin/"
mkdir -p "${pkgdir}/usr/share/applications"
cp "${srcdir}/shamela.desktop" "${pkgdir}/usr/share/applications"
}
this is the shamela.desktop file:
[Desktop Entry]
Categories=Application;Education;
Comment=Islamic Library.
Exec=/usr/bin/shamela.sh
GenericName=Islamic Library
Keywords=shamela;الشاملة
Name=shamela
Terminal=true
TryExec=shamela
Type=Application
when i run it i get: the desktop entry file is not valid.
and i have a question: the winetricks code will be executred every time the software opens? i just need it to be run the first time and then the software can just be run with: wine laincher.exe
Offline
according to this page: https://man.archlinux.org/man/PKGBUILD.5 there is a post build in pckgbuild.
You're probably referring to https://man.archlinux.org/man/PKGBUILD. … _SCRIPTING .
That describes the use of a separate .install script to perform systemwide stuff .
Most of its functionality is nowadays taken care of by pacman hooks and it's not suited for your purpose .
the winetricks code will be executred every time the software opens? i just need it to be run the first time and then the software can just be run with: wine laincher.exe
Correct, winetricks should detect vb6run is already installed and (hopefully) abort silently.
It would be better to check for vb6run in the script, but you'll have to figure out what to test for .
The desktop file misses an icon entry but should use a fallback icon instead.
Try running desktop-file-validate on the file to get more info what is wrong with it.
Don't forget to add shamela.sh to the source array. for now it should work for you but if you would like to add it to shore with others at some point it will have to be in the source array to ensure it's present & found .
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Online
according to this page: https://man.archlinux.org/man/PKGBUILD.5 there is a post build in pckgbuild.
You're probably referring to https://man.archlinux.org/man/PKGBUILD. … _SCRIPTING .
That describes the use of a separate .install script to perform systemwide stuff .
Most of its functionality is nowadays taken care of by pacman hooks and it's not suited for your purpose .the winetricks code will be executred every time the software opens? i just need it to be run the first time and then the software can just be run with: wine laincher.exe
Correct, winetricks should detect vb6run is already installed and (hopefully) abort silently.
It would be better to check for vb6run in the script, but you'll have to figure out what to test for .The desktop file misses an icon entry but should use a fallback icon instead.
Try running desktop-file-validate on the file to get more info what is wrong with it.Don't forget to add shamela.sh to the source array. for now it should work for you but if you would like to add it to shore with others at some point it will have to be in the source array to ensure it's present & found .
thank you.
the validation shows an error in: Categories=Application;Education;
i removed: "Application" and now the validation shows no error. but there is no shamela entry shown in the applications menu (i'm using KDE Plasma), and when trying to execute shamela.desktop is still shows: the desktop entry file .. is not valid
edit: the problem was in this line: "TryExec=shamela"
i have removed it and the file is now working well
Last edited by ardv (2024-08-19 16:32:32)
Offline
The shamela.sh & shamela.desktop had incorrect permissions .
Most PKGBUILDs use install instead of cp to ensure correct permissions are set .
Below is a (dirty) PKGBUILD that corrects that.
When you run shamela.sh wine will complain about several missing things, so the program is not yet usable .
## Author: shamela team <shamela.ws>
# Maintainer: dj.zak <dz.wbdev@gmail.com>
pkgname=shamela
pkgver=4
pkgrel=1
pkgdesc="A digital library which enables you to download, read and search arabic books. to run it you need to install vb6run: 'winetricks vb6run'. "
arch=('x86_64')
url="https://shamela.ws/page/download"
license=('custom')
depends=('wine' 'winetricks' 'bash')
source=('shamela4.tar.xz::https://archive.org/download/shamela4.tar/shamela4.tar.xz'
'shamela.sh'
'shamela.desktop'
)
sha256sums=('3b0db8b2f97419cb291c3a546cfd6adc65e911ffb2c717020b82f9778e16fdac'
'9df6b4cab9314bab2a590c5a5999a43595568955580877dd0ffd8f138db415d2'
'3e7e4d7c18651a9991afe581dc484746105cf8037a1288c041f22379cfe54f3c')
package() {
# cd "${srcdir}"
# package() always starts in $srcdir
mkdir -p "${pkgdir}/opt/${pkgname}"
mv "${srcdir}/shamela4/"* "${pkgdir}/opt/${pkgname}/"
install -Dm755 "${srcdir}/shamela.sh" "${pkgdir}/usr/bin/shamela.sh"
# mkdir -p "${pkgdir}/usr/bin/"
# cp "${srcdir}/shamela.sh" "$pkgdir/usr/bin/"
install -Dm755 "${srcdir}/shamela.sh" "${pkgdir}/usr/bin/"
# mkdir -p "${pkgdir}/usr/share/applications"
# cp "${srcdir}/shamela.desktop" "${pkgdir}/usr/share/applications"
install -Dm644 shamela.desktop "${pkgdir}/usr/share/applications/shamela.desktop"
}
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Online
The shamela.sh & shamela.desktop had incorrect permissions .
Most PKGBUILDs use install instead of cp to ensure correct permissions are set .Below is a (dirty) PKGBUILD that corrects that.
When you run shamela.sh wine will complain about several missing things, so the program is not yet usable .
thank you very much. i really appreciate your help.
this is my new package file:
## Author: shamela team <shamela.ws>
# Maintainer: dj.zak <dz.wbdev@gmail.com>
pkgname=shamela
pkgver=4
pkgrel=1
pkgdesc="A digital library which enables you to download, read and search arabic books."
arch=('x86_64')
url="https://shamela.ws/page/download"
license=('custom')
depends=('wine' 'winetricks' 'bash')
source=('shamela4.tar.xz::https://archive.org/download/shamela4.tar/shamela4.tar.xz'
'https://archive.org/download/shamela4.tar/shamela.sh'
'https://archive.org/download/shamela4.tar/shamela.desktop')
sha256sums=('3b0db8b2f97419cb291c3a546cfd6adc65e911ffb2c717020b82f9778e16fdac'
'9df6b4cab9314bab2a590c5a5999a43595568955580877dd0ffd8f138db415d2'
'c14311e11eaaa861fdb860ec750d213e27691121591d7492505351c8f2bcf177')
package() {
mkdir -p "${pkgdir}/opt/${pkgname}"
mv "${srcdir}/shamela4/"* "${pkgdir}/opt/${pkgname}/"
chmod 777 ${pkgdir}/opt/${pkgname}
install -Dm755 "${srcdir}/shamela.sh" "${pkgdir}/usr/bin/shamela.sh"
install -Dm644 "${srcdir}/shamela.desktop" "${pkgdir}/usr/share/applications/shamela.desktop"
}
the problem now is in the "shamela" folder. in order to work the software needs the permission to write in that folder
i hve added: " chmod 777 ${pkgdir}/opt/${pkgname}" but when i go to opt folder i find that only the root have the write permission, and i think that "install -Dm" just works for individual files and not for folders, so how to fix this?
Offline
That will be tricky to setup correctly for multiple users .
Packaging windows programs for linux is not easy.
read the wiki page I linked in #2 several times and think about it.
What is your ultimate goal here and is a PKGBUILD needed to achieve it ?
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Online
That will be tricky to setup correctly for multiple users .
Packaging windows programs for linux is not easy.
read the wiki page I linked in #2 several times and think about it.
What is your ultimate goal here and is a PKGBUILD needed to achieve it ?
i think that the PKGBUILD should be like that:
package() {
mkdir -p "${pkgdir}/usr/share/${pkgname}"
mv "${srcdir}/shamela4/"* "${pkgdir}/usr/share/${pkgname}/"
find "$pkgdir"/usr/share -type d -exec chmod 755 "{}" \;
install -Dm755 "${srcdir}/shamela.sh" "${pkgdir}/usr/bin/shamela.sh"
install -Dm644 "${srcdir}/shamela.desktop" "${pkgdir}/usr/share/applications/shamela.desktop"
}
and the shamela.sh should be like this:
#!/bin/bash
winetricks vb6run
unset WINEPREFIX
if [ ! -d "$HOME"shamela ] ; then
mkdir -p "$HOME"shamela
#prepare the environment here
fi
WINEDEBUG=-all wine "$HOME"/.shamela/launcher.exe"$@"
am i right?
What is your ultimate goal here and is a PKGBUILD needed to achieve it ?
my goal is to package that software and upload it in AUR since linux users that uses this software doesnt know how to run it, and the idea is the vb6run installation from winetricks.
Last edited by ardv (2024-08-20 14:17:00)
Offline
Moderator note :
OP reported his answer by mistake, I copied it here.
my goal is to upload this PKGBUILD to the AUR so as arch linux users can use this software which is one of the biggest popular softwares in the islamic research domain, especially that the vb6run dependency is not known for almost linux users to run that software, and i spent time to find that was the way to run that software correctly in linux.
End of mod note
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Online
read the wiki page I linked in #2 several times and think about it.
i have read that page, and accourding to what i understand from it the PKGBUILD should be like this:
package() {
mkdir -p "${pkgdir}/usr/share/${pkgname}"
mv "${srcdir}/shamela4/"* "${pkgdir}/usr/share/${pkgname}/"
find "$pkgdir"/usr/share -type f -exec chmod 644 "{}" \;
find "$pkgdir"/usr/share -type d -exec chmod 755 "{}" \;
install -Dm755 "${srcdir}/shamela.sh" "${pkgdir}/usr/bin/shamela.sh"
install -Dm644 "${srcdir}/shamela.desktop" "${pkgdir}/usr/share/applications/shamela.desktop"
}
and the shamela.sh should be like this:
#!/bin/bash
winetricks vb6run
unset WINEPREFIX
if [ ! -d "$HOME"/.shamela ] ; then
mkdir -p "$HOME"/.shamela
#prepare the environment here
ln -s /usr/share/shamela/app "$HOME"/.shamela/app
ln -s /usr/share/shamela/launcher.exe "$HOME"/.shamela/launcher.exe
cp -r /usr/share/shamela/database "$HOME"/.shamela/database
fi
WINEDEBUG=-all wine "$HOME"/.shamela/launcher.exe "$@"
edit: when i run shamela.exe it prints in the terminal:
/usr/bin/shamela.sh: line 6: [: missing `]'
the fix: the problem was a missing space before ]
the software seems to work now. thank you for hep help. if i face any problem i will post it.
Last edited by ardv (2024-08-26 10:21:00)
Offline
i have added the package to the AUR: https://aur.archlinux.org/packages/shamela
thank you for your help
Offline
Looking good now.
A few comments :
if either of the 3 files in source array are changed by upstream, the aur package will have to be updated .
Also it would be cleaner (and maybe give a small decrease in internet traffic for archive.org ) if the .desktop & .sh files were included in the shamela4 tarball .
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Online
Looking good now.
A few comments :
if either of the 3 files in source array are changed by upstream, the aur package will have to be updated .
Also it would be cleaner (and maybe give a small decrease in internet traffic for archive.org ) if the .desktop & .sh files were included in the shamela4 tarball .
- i have changed the tar file and uploaded the new one on archive and updated the sha256sum in the PKGBUILD file, and now when i try: yay -S shamela it prints:
-> Found shamela4.tar.xz
-> Found shamela.sh
-> Found shamela.desktop
==> Validating source files with sha256sums...
shamela4.tar.xz ... FAILED
shamela.sh ... Passed
shamela.desktop ... Passed
==> ERROR: One or more files did not pass the validity check!
-> error making: shamela-exit status 1
-> Failed to install the following packages. Manual intervention is required:
so the problem seems to be that file downloaded before still exists in the temporary folder, and it does not pass the verification because it is not the same in archive.org, the old file should be deleted and the new one should be downloaded.
i tried: yay -Rns shamela, i get: exit status 1
so: do i need to manually remove the file? or do i have to change the package version so as yay delete the old file automatically?
and for the 3 files, what if i just need to change the shamela.sh file later? i think it is better that this file is separated from the other one so as the user will not download the other big file. what do you think?
EDIT: the solution was to choose to clean build the packages when installing via yay.
edit2: is it notmal that the home/.shamela folder that the .sh file created will not be deleted when removing the software with pacman -R shamela? or i need to add uninstall script so as to clean the system from the software files completely?
Last edited by ardv (2024-08-28 05:18:10)
Offline
and for the 3 files, what if i just need to change the shamela.sh file later? i think it is better that this file is separated from the other one so as the user will not download the other big file. what do you think?
There's no good or bad in this case, as it is an upstream choice.
edit2: is it notmal that the home/.shamela folder that the .sh file created will not be deleted when removing the software with pacman -R shamela? or i need to add uninstall script so as to clean the system from the software files completely?
Yes, packages are not allowed to touch user files.
You can add a uninstall script in /usr/bin or add the removal option to shamela.sh .
Sidenote
Since this program is for arabic readers I guess there are reasons why you're using archive.org instead of the more common alternatives.
https://european-alternatives.eu/alternative-to/github lists 3 european hosters with servers in europe, maybe they are useful for you/your team ?
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Online
Yes, packages are not allowed to touch user files.
You can add a uninstall script in /usr/bin or add the removal option to shamela.sh .
Sidenote
Since this program is for arabic readers I guess there are reasons why you're using archive.org instead of the more common alternatives.
https://european-alternatives.eu/alternative-to/github lists 3 european hosters with servers in europe, maybe they are useful for you/your team ?
thank you for your valuable help and comments.
i'm not in the developing team of that software, and it is not open source, so i think it is not suitable to upload it in that git hosting websites.
and i choosed not to download the software file from their website in the PKGBUILD because they publish it with an installer for windows os and it is not suitable for linux, and i have added multiple dll files to the software folders so as it works fine with wine in linux after installing vb6run from winetricks.
Offline