Skip to content

Commit

Permalink
fix: rpm spec files
Browse files Browse the repository at this point in the history
  • Loading branch information
arlac77 committed May 23, 2019
1 parent 79d0654 commit 207e6cd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 31 deletions.
5 changes: 4 additions & 1 deletion src/npm-pkgbuild-cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ program
await rpmspec(
context,
staging,
createWriteStream(join(staging, "xxx.spec"), utf8StreamOptions),
createWriteStream(
join(staging, `${context.name}.spec`),
utf8StreamOptions
),
{ npmDist: program.npmDist, npmModules: program.npmModules }
);
break;
Expand Down
51 changes: 21 additions & 30 deletions src/rpmspec.mjs
Original file line number Diff line number Diff line change
@@ -1,46 +1,37 @@
import globby from "globby";
import { quote } from "./util.mjs";

export async function rpmspec(context, stagingDir, out, options = {}) {
const pkg = { contributors: [], pacman: {}, ...context.pkg };

const properties =
{
Name: pkg.name,
Summary: pkg.description,
License: pkg.license,
Version: context.properties.pkgver.replace(/\-.*$/, ""),
Release: context.properties.pkgrel
};


out.write(`${Object.keys(properties)
.filter(k => properties[k] !== undefined)
.map(k => `${k}=${quote(properties[k])}`)
.join("\n")}
const pkg = { contributors: [], pacman: {}, ...context.pkg };

const properties = {
Name: pkg.name,
Summary: pkg.description,
License: pkg.license,
Version: context.properties.pkgver.replace(/\-.*$/, ""),
Release: context.properties.pkgrel
};

out.write(`${Object.keys(properties)
.filter(k => properties[k] !== undefined)
.map(k => `${k}=${quote(properties[k])}`)
.join("\n")}
%description
This is my first RPM package, which does nothing.
${pkg.description}
%prep
# we have no source, so nothing here
%build
cat > hello-world.sh <<EOF
#!/usr/bin/bash
echo Hello world
EOF
%install
mkdir -p %{buildroot}/usr/bin/
install -m 755 hello-world.sh %{buildroot}/usr/bin/hello-world.sh
%files
/usr/bin/hello-world.sh
%changelog
# let's skip this for now
`);

for (const name of await globby("**/*", { cwd: stagingDir })) {
out.write(name + "\n");
}

out.end();
out.end();
}

0 comments on commit 207e6cd

Please sign in to comment.