You are not logged in.

#1 2016-05-31 00:35:36

STREBLO
Member
Registered: 2015-02-15
Posts: 135

Editing File With sed in PKGBUILD Results in Empty File

The problem I'm having is a systemd unit in my PKGBUILD is trying to reference the wrong location with

ExecStart=/usr/local/bin/${pkgname}

instead of

ExecStart=/usr/bin/${pkgname}

The file i'm trying to edit is in "${pkgname}-${pkgver}/init/${pkgname}.service"

sed -i 's:ExecStart=/usr/local/bin/${pkgname}:ExecStart=/usr/bin/${pkgname}:' "init/${pkgname}.service"

and then install it

install "init/${pkgname}.service" "${pkgdir}/etc/systemd/system/${pkgname}.service"

but while sed changes the original file, the file that gets copied to "${pkgdir}/etc/systemd/system/" is empty. What am I doing wrong?

package() {
    cd "${pkgname}-${pkgver}"
    sed -i 's:ExecStart=/usr/local/bin/${pkgname}:ExecStart=/usr/bin/${pkgname}:' "init/${pkgname}.service"
    install "init/${pkgname}.service" "${pkgdir}/etc/systemd/system/${pkgname}.service"
    # Other stuff
}

Offline

#2 2016-05-31 00:48:56

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Editing File With sed in PKGBUILD Results in Empty File

This wouldn't lead to an empty file, but your sed command definitely will not work.  The pkgname variable will not be expanded in single quotes.

If you post the full PKGBUILD we will be able to test too.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2016-05-31 01:00:01

STREBLO
Member
Registered: 2015-02-15
Posts: 135

Re: Editing File With sed in PKGBUILD Results in Empty File

Trilby wrote:

This wouldn't lead to an empty file, but your sed command definitely will not work.  The pkgname variable will not be expanded in single quotes.

If you post the full PKGBUILD we will be able to test too.

Whoops, my original wasn't using a variable. I'm getting the original edited correctly, but in the directory "pkg" that's made, the file "${pkgdir}/etc/systemd/system/${pkgname}.service" is empty. The pkg directory should show the final version, right?

Offline

#4 2016-05-31 01:03:48

STREBLO
Member
Registered: 2015-02-15
Posts: 135

Re: Editing File With sed in PKGBUILD Results in Empty File

Crap. The "pkg" directory isn't the final version. I tried installing my package and it worked.

Thanks for your help.

Offline

Board footer

Powered by FluxBB