Need help with an AUR Package

I’m testing an aur package I’m creating and it keeps giving me an error.

cp: cannot create directory '/home/s4ndm4n/RocketUi/pkg/rocketui/etc/skel/.config/': No such file or directory

Below is the PKGBUILD code.

# Maintainer : S4NDM4N <sadaruwan12 at gmail dot com>

pkgname=rocketui
pkgver=1.0.1
pkgrel=1
pkgdesc="An alternative user interface based on Xfce desktop environment."
arch=('any')
url="https://github.com/SwiftScripters/${pkgname}.git"
license=('GPL')
depends=(
        'appmenu-gtk-module-git'
        'dbus'
        'dconf'
        'ffmpegthumbnailer'
        'linux-firmware'
        'hardinfo'
        'lightdm'
        'lightdm-slick-greeter'
        'papirus-icon-theme'
        'pavucontrol'
        'pipewire-audio'
        'plank'
        'tumbler'
        'tumbler-extra-thumbnailers'
        'thunar'
        'thunar-archive-plugin'
        'thunar-media-tags-plugin'
        'thunar-volman'
        'ulauncher'
        'vala-panel-git'
        'vala-panel-appmenu-xfce-git'
        'vala-panel-appmenu-registrar-git'
        'vala-panel-appmenu-common-git'
        'xfce4-appfinder'
        'xf86-input-libinput'
        'xfce4-appfinder'
        'xfce4-battery-plugin'
        'xfce4-datetime-plugin'
        'xfce4-mount-plugin'
        'xfce4-netload-plugin'
        'xfce4-notifyd'
        'xfce4-panel'
        'xfce4-power-manager'
        'xfce4-pulseaudio-plugin'
        'xfce4-screensaver'
        'xfce4-screenshooter'
        'xfce4-session'
        'xfce4-settings'
        'xfce4-taskmanager'
        'xfce4-terminal'
        'xfce4-wavelan-plugin'
        'xfce4-xkb-plugin'
        'xfconf'
        'xfdashboard-git'
        'xfdesktop'
        'xfsprogs'
        'xfwm4'
        'xfwm4-themes'
        'xdg-desktop-portal-gtk'
        'xf86-input-libinput'
        'yaru-gtk-theme'
        'yaru-icon-theme'
        'yaru-sound-theme'
        'yaru-xfwm4-theme'
        )
source=("${pkgname}::git+https://github.com/SwiftScripters/${pkgname}.git")
sha256sums=('SKIP')

package() {
    skelPath=/etc/skel
    usrSharePath=/usr/share
    usrBinPath=/usr/bin
    usrSharePathSource=usr/share
    usrBinPathSource=usr/bin

    # Going in to the folder with files.
    #cd "${pkgname}"

    # Installing readme.
    install -Dm644 "${pkgname}/README.md" -t "${pkgdir}${usrSharePath}/doc/${pkgname}"

    # Installing license.
    install -Dm644 "${pkgname}/LICENSE" -t "${pkgdir}${usrSharePath}/licenses/$pkgname/"

    # Starting the installation.
    for i in autostart cortile plank rofi ulauncher xfce4; do
       cp -r "${pkgname}/.config/${i}" "${pkgdir}${skelPath}/.config/"
    done

    cp plankthemesettings/docks.ini "${pkgdir}${skelPath}/.config"
    cp ${usrSharePathSource}/applications/* "${pkgdir}${usrSharePath}/applications"
    cp ${usrSharePathSource}/icons/* "${pkgdir}${usrSharePath}/icons"
    cp -r "${usrBinPathSource}/themes/*" "${pkgdir}${usrSharePath}/themes"
    cp -r ${usrSharePathSource}/plank/themes/rocketplank "${pkgdir}${usrSharePath}/plank/themes"
    install -Dm755 "etc/xdg/xdg-rocket/.bashrc" -t "${pkgdir}/etc/xdg/xdg-rocket"
    install -Dm755 "etc/xdg/xdg-rocket/.xinitrc" -t "${pkgdir}/etc/xdg/xdg-rocket"
    install -Dm755 "etc/xdg/xdg-rocket/xinitrc" -t "${pkgdir}/etc/xdg/xdg-rocket"
    install -Dm644 "etc/lightdm/lightdm.conf.d/60-rocket.conf" -t "${pkgdir}/etc/lightdm/lightdm.conf.d"
    install -Dm644 "${usrSharePathSource}/xessions/Rocket.xsession" -t "${pkgdir}${usrSharePath}/xsessions"

    # Setting the current system to use rocket Ui.
    if ! [[ -d "${homedir}/.config" ]]; then
        mkdir -p "${homedir}/.config"
    fi

    for i in autostart cortile plank rofi ulauncher xfce4; do
        cp -r "${skelPath}/.config/${i}" "${homedir}/.config"
        chown -cR "${USER}:${USER}" "${homedir}/.config/${i}"
    done

    if ! [[ -f "${homedir}/.config/docks.ini" ]]; then
        cp -r "${skelPath}/.config/docks.ini" "${homedir}/.config"
    fi

    chown -cR "${USER}:${USER}" "${homedir}/.config/docks.ini"

    cp "/etc/xdg/xdg-rocket/.bashrc" "${homedir}/.bashrc"
    papirus-folders -C violet --theme Papirus-Dark
}

The sources for the for loops is in the path ${pkgname}/.config/. I does create the and copies the two file at the start. LICENSE and README but when it hits the for loop it gives me an error.

Can someone please help me?

just a guess, but before the first for loop you should create the "${pkgdir}${skelPath}/.config/" directory if it’s not there, probably something is missing in the path, so you should try a mkdir before the loop

1 Like

Where is variable homedir defined?

That seems like a terrible PKGBUILD, bordering malicious.

Installing a package from the AUR should not touch your home directory. And it should definitely not overwrite your .bashrc! :open_mouth:

2 Likes

Why don’t you tell me or teach me how to put the files I need to be in the user’s .config folder without being as you say malicious.

Also, if you take a look I’m not installing any software.

I thought ${homedir} is a system variable for the script to get the user’s local .config file.

You shouldn’t be doing that. You shouldn’t be touching the user’s home directory and anything within it.

If you want to install some configs, that’s what /etc is for.

2 Likes

As already pointed out, this PKGBUILD is doing some things it shouldn’t. This isn’t suitable for posting to the AUR.

A package should never write into a user’s home directory. More importantly, building a package should never modify the system. Only installing the package should do that. Also, you can’t assume that the user building the package is the same as the user installing it.

More things:

  • This should be named rocketui-git based on what you are doing here.
  • You should be using a pkgver function for this

User config that is needed for a DE is typically delivered to /etc/skel and then it is automatically added to new users when they are created. Either that or you a deploy a script that modifies the files in the user’s home dir and provide instructions for the user to run it manually.

2 Likes

That won’t always be available. You can’t count on that in a script. $HOME is more widely available but you shouldn’t use it in a PKGBUILD.

2 Likes

If you really need something in the user directory, it should be handled by the program/script when it is launched the first time.

Thank you. I should break out the part where I’m handling the copying files to the user’s .config folder and put it in a .sh script.

And leave the rest as it is. I’ve made a lot of changes since I posted this post. This is my first PKGBUILD so, I am bound to make mistakes. Thank you for pointing them out.

I’ll post my updated script after some more testing.

As @dalto mentioned I will rename this to rocketui-git. Also, one more question what do you mean by,

I do have the pkgver and pkgrel defined at the top. Do you mean I should use '${pkgver} instead of '${pkgname}?

No, he means you should create a new function. If you use source from git, copy here:

pkgver() {
  cd "$srcdir/${pkgname%-git}"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

This function is just an example. You can change it whatever you want.

  • This function automatically changes the version to your PKGBUILD when running makepkg. You don’t need to set the version manually.

  • You don’t need to update this version in PKGBUILD when the git source gets a new commit, because any executable AUR helper will automatically recognize the new commit from this source. It will prompt you to update.

1 Like

Thank you @Zesko. I’ll look into this. The main documents didn’t say anything about something like this. Or I might have missed it.

Here:

https://wiki.archlinux.org/title/VCS_package_guidelines#The_pkgver()_function

1 Like

I didn’t read that one thank you.