=== modified file 'stagebuilder.prolog' --- stagebuilder.prolog 2011-11-25 01:47:11 +0000 +++ stagebuilder.prolog 2011-11-25 00:58:03 +0000 @@ -160,43 +160,35 @@ % list_escape(Unescapeds,Escapeds) :- % maplist(escape,Unescapeds,Escapeds) - -check_returncode(Tokens, TokensChecked) :- - append(Tokens, ["||", "exit", "$?"], TokensChecked). - -cmd_tokens(run(List) , Checked) :- - maplist(escape, List, Escaped), - check_returncode(Escaped, Checked). -cmd_tokens( run_append(List, File) , Checked) :- + +cmd_tokens(run(List) , Escaped) :- + maplist(escape, List, Escaped). +cmd_tokens( run_append(List, File) , Escaped) :- maplist(escape, List, Escaped0), append(Escaped0, [">>", FileEscaped], Escaped), - escape(File, FileEscaped), - check_returncode(Escaped, Checked). -cmd_tokens(run_replace(List, File) , Checked) :- + escape(File, FileEscaped). +cmd_tokens(run_replace(List, File) , Escaped) :- maplist(escape, List, Escaped0), append(Escaped0, [">", FileEscaped], Escaped), - escape(File, FileEscaped), - check_returncode(Escaped, Checked). -cmd_tokens( run_outvar(List, Var) , Checked) :- + escape(File, FileEscaped). +cmd_tokens( run_outvar(List, Var) , Escaped) :- maplist(escape, List, Escaped0), concat([Var, "=$("], Pre), - concat([[Pre], Escaped0, [")"]], Escaped), - check_returncode(Escaped, Checked). -cmd_tokens(run_outarray(List, Var) , Checked) :- + concat([[Pre], Escaped0, [")"]], Escaped). +cmd_tokens(run_outarray(List, Var) , Escaped) :- maplist(escape, List, Escaped0), concat([Var, "=( $("], Pre), - concat([[Pre], Escaped0, [") )"]], Escaped), - check_returncode(Escaped, Checked). + concat([[Pre], Escaped0, [") )"]], Escaped). cmd_tokens( echo_append(String, File), Escaped) :- cmd_tokens( run_append([echo, String], File), Escaped). cmd_tokens(echo_replace(String, File), Escaped) :- cmd_tokens(run_replace([echo, String], File), Escaped). cmd_tokens(chroot(Dir, Args) , Escaped) :- cmd_tokens(run([Dir +/+ 'chroot.sh'|Args]) , Escaped). -cmd_tokens(comment(Text), [Escaped]) :- +cmd_tokens(comment(Text), Escaped) :- str(Text, String), make_comment(String, EscapedString), - append("\n# ", EscapedString, Escaped). + append("\n", EscapedString, Escaped). make_comment([ ], "\n"). make_comment([Char|String], EscapedString) :- @@ -208,7 +200,8 @@ format_cmd(Cmd, String) :- cmd_tokens(Cmd, Tokens), - str_join(" ", Tokens, String). + append(Tokens, ["||", "exit", "$?"], CheckedResults), + str_join(" ", CheckedResults, String). % format_cmds(Cmds, Strings) :- % maplist(format_cmd, Cmds, Strings). @@ -489,9 +482,9 @@ create_gentoo_builddir(Name, Dir) --> {gentoo_stage(Name, ArchName, _)}, download_gentoo_stage(Tarball, Name), - prepend([comment('prepare build directory') - ,run([mkdir, '-p', Dir +/+ 'usr/portage', Dir +/+ 'var/portage']) - ]), + [comment('prepare build directory') + ,run([mkdir, '-p', Dir +/+ 'usr/portage', Dir +/+ 'var/portage']) + ], unpack_tarball(Tarball, Dir), create_chroot_script(Dir, ArchName), {work_dir(Work), site_conf_dir(Conf)},