From 5f4bcfe91f78defca005fdef0849d3336e7b80f8 Mon Sep 17 00:00:00 2001 From: tts2k <33920021+tts2k@users.noreply.github.com> Date: Wed, 17 Jan 2018 20:43:38 +0700 Subject: [PATCH] cnf: new recipe (#2067) --- .../command_not_found-0.0.1.recipe | 47 ---------- .../command_not_found-0.0.1~git.recipe | 52 +++++++++++ .../patches/command_not_found-0.0.1.patchset | 59 ------------ .../command_not_found-0.0.1~git.patchset | 91 +++++++++++++++++++ 4 files changed, 143 insertions(+), 106 deletions(-) delete mode 100644 app-shells/command_not_found/command_not_found-0.0.1.recipe create mode 100644 app-shells/command_not_found/command_not_found-0.0.1~git.recipe delete mode 100644 app-shells/command_not_found/patches/command_not_found-0.0.1.patchset create mode 100644 app-shells/command_not_found/patches/command_not_found-0.0.1~git.patchset diff --git a/app-shells/command_not_found/command_not_found-0.0.1.recipe b/app-shells/command_not_found/command_not_found-0.0.1.recipe deleted file mode 100644 index d5f6461b4..000000000 --- a/app-shells/command_not_found/command_not_found-0.0.1.recipe +++ /dev/null @@ -1,47 +0,0 @@ -SUMMARY="A tool to find not-installed applications" -DESCRIPTION="Command-not-found hooks into the command_not_found_handle \ -to inform end users where to find an application if they don't have it. \ -It can also check for typos (a feature of zsh)." -HOMEPAGE="https://github.com/jrabbit-cnf/" -COPYRIGHT="2011 Jrabbit" -LICENSE="GNU GPL v2" -REVISION="1" -SOURCE_URI="git+https://github.com/jrabbit/haiku-cnf.git#87cd5d0c212e377cffa5d3e2a00c143fe751c6fb" -PATCHES="command_not_found-0.0.1.patchset" -DISABLE_SOURCE_PACKAGE="yes" - -ARCHITECTURES="?x86 ?x86_gcc2" - -PROVIDES=" - command_not_found = $portVersion - cmd:command_not_found = $portVersion - " -REQUIRES=" - haiku - cmd:python - " - -BUILD_REQUIRES=" - haiku${secondaryArchSuffix}_devel - " -BUILD_PREREQUIRES=" - cmd:python - " - -POST_INSTALL_SCRIPTS=" - boot/post-install/install_cnf.py - " - -BUILD() -{ - true -} - -INSTALL() -{ - mkdir -p $binDir - install -m 0755 haiku_cnf.py $binDir/command_not_found - - mkdir -p $postInstallDir - mv install_cnf.py $postInstallDir -} diff --git a/app-shells/command_not_found/command_not_found-0.0.1~git.recipe b/app-shells/command_not_found/command_not_found-0.0.1~git.recipe new file mode 100644 index 000000000..678c8a5e0 --- /dev/null +++ b/app-shells/command_not_found/command_not_found-0.0.1~git.recipe @@ -0,0 +1,52 @@ +SUMMARY="A tool to find not-installed applications" +DESCRIPTION="Command-not-found hooks into the command_not_found_handle \ +to inform end users where to find an application if they don't have it. \ +It can also check for typos (a feature of zsh)." +HOMEPAGE="https://github.com/jrabbit/haiku-cnf" +COPYRIGHT="2011 Jrabbit" +LICENSE="GNU GPL v2" +REVISION="1" +srcGitRev="db1be8b57dedff781dc68caa46f403d88c5eedb9" +SOURCE_URI="$HOMEPAGE/archive/$srcGitRev.tar.gz" +CHECKSUM_SHA256="a1ce4e6c8a7307c0d5c1e65a90b3d2a7ba9d16d9506a70aab1005129333d6121" +SOURCE_FILENAME="haiku-cnf-$portVersion-$srcGitRev.tar.gz" +SOURCE_DIR="haiku-cnf-$srcGitRev" +PATCHES="command_not_found-0.0.1~git.patchset" + +ARCHITECTURES="any" + +PROVIDES=" + command_not_found = $portVersion + cmd:command_not_found = $portVersion + " +REQUIRES=" + haiku + cmd:python + " + +BUILD_REQUIRES=" + haiku${secondaryArchSuffix}_devel + " +BUILD_PREREQUIRES=" + cmd:python + " + +GLOBAL_WRITABLE_FILES="settings/etc/profile.d/command-not-found.sh keep-old" + +BUILD() +{ + true +} + +INSTALL() +{ + profileDir=$settingsDir/etc/profile.d + install -d $binDir $profileDir + install -m 0755 haiku_cnf.py $binDir/command_not_found + + cat > $profileDir/command-not-found.sh << EOF +command_not_found_handle() { + command_not_found "$1" +} +EOF +} diff --git a/app-shells/command_not_found/patches/command_not_found-0.0.1.patchset b/app-shells/command_not_found/patches/command_not_found-0.0.1.patchset deleted file mode 100644 index 2cdfb4774..000000000 --- a/app-shells/command_not_found/patches/command_not_found-0.0.1.patchset +++ /dev/null @@ -1,59 +0,0 @@ -From 475d61b3d40fc506e47a492fb9ef391f246cc2f3 Mon Sep 17 00:00:00 2001 -From: Humdinger -Date: Sun, 19 Jul 2015 09:51:15 +0200 -Subject: Creating patchset from original patch. - - -diff --git a/install_cnf.py b/install_cnf.py -index 3e976a3..4104419 100644 ---- a/install_cnf.py -+++ b/install_cnf.py -@@ -1,32 +1,29 @@ - #!/bin/env python - import os - --hacks = """# command-not-found tomfoolery --if [ -e /boot/common/bin/python ]; then -- command_not_found_handle(){ -- /boot/common/bin/python /boot/common/bin/command_not_found.py "$1" -- } --else -- command_not_found_handle(){ -- echo "$1 not found: try installoptionalpkg $1; and check installoptionalpkg -l" -- } --fi -+hacks = """ -+#!/bin/env python -+command_not_found_handle(){ -+ /bin/env python /bin/command_not_found "$1" -+} - \n - """ - -- - default_options="""{ - "autocorrect": false, - "spellcheck": false, - "haikuports": false - }\n""" --home = os.environ['HOME'] --if not os.path.exists("%s/config/settings/command-not-found/options.json" % home): -- profile = open("/etc/profile", "a") -+ -+if not os.path.exists("/boot/common/etc/profile.d/command-not-found.sh") -+ os.mkdir("/boot/common/etc/profile.d") -+ profile = open("/boot/common/etc/profile.d/command-not-found.sh", "a") - profile.write(hacks) - profile.close() -+ -+home = os.environ['HOME'] -+if not os.path.exists("%s/config/settings/command-not-found/options.json" % home): - os.mkdir("%s/config/settings/command-not-found/" % home) - options = open("%s/config/settings/command-not-found/options.json" % home, "w") - options.write(default_options) - options.close() --os.system("install -m 755 haiku_cnf.py /boot/common/bin/command_not_found.py") -\ No newline at end of file --- -2.2.2 - diff --git a/app-shells/command_not_found/patches/command_not_found-0.0.1~git.patchset b/app-shells/command_not_found/patches/command_not_found-0.0.1~git.patchset new file mode 100644 index 000000000..bfa9e7851 --- /dev/null +++ b/app-shells/command_not_found/patches/command_not_found-0.0.1~git.patchset @@ -0,0 +1,91 @@ +From 192f2f912f75b7304f09f2b255e24427eef800c1 Mon Sep 17 00:00:00 2001 +From: tts2k +Date: Sun, 7 Jan 2018 02:49:19 +0000 +Subject: Add read permission + + +diff --git a/haiku_cnf.py b/haiku_cnf.py +index 7c68057..c7f51d9 100644 +--- a/haiku_cnf.py ++++ b/haiku_cnf.py +@@ -17,7 +17,7 @@ def update_db(): + db['base-pkgs'] = json.dumps(read_basepkgs()) + if Popen(['which', 'haikuporter'],stdout=PIPE).communicate()[0]: + home = os.path.expanduser('~') +- with open("%s/config/settings/command-not-found/options.json" % home, "w") as options: ++ with open("%s/config/settings/command-not-found/options.json" % home, "rw") as options: + d = json.load(options) + d['haikuports'] = True + # json.dump(d, options) +diff --git a/install_cnf.py b/install_cnf.py +index 1e1dd35..fc0051b 100644 +--- a/install_cnf.py ++++ b/install_cnf.py +@@ -35,7 +35,6 @@ def main(): + options = open("%s/config/settings/command-not-found/options.json" % home, "w") + options.write(default_options) + options.close() +- os.system("install -m 755 haiku_cnf.py /boot/system/non-packaged/bin/command_not_found.py") + + + if __name__ == '__main__': +-- +2.15.0 + + +From b0ab9db5c1938def17e0785eb03fb709c060dbfe Mon Sep 17 00:00:00 2001 +From: tts2k +Date: Tue, 9 Jan 2018 12:27:13 +0000 +Subject: write default option if not available + + +diff --git a/haiku_cnf.py b/haiku_cnf.py +index c7f51d9..d9e0644 100644 +--- a/haiku_cnf.py ++++ b/haiku_cnf.py +@@ -1,6 +1,7 @@ + #!/bin/env python + #GPL v3 (c) 2011, 2016-2017 Jack Laxson "jrabbit" + import anydbm ++import commands + import json + import os + import pprint +@@ -106,6 +107,26 @@ def our_help(): + -- + %(app)s reads options from ~/config/settings/command-not-found/options.json""" % {'app': sys.argv[0]} + ++ ++ ++def write_default_opt(): ++ default_options="""{ ++"autocorrect": false, ++"spellcheck": false, ++"haikuports": false ++}\n""" ++ ++ home = commands.getoutput('finddir B_USER_SETTINGS_DIRECTORY') ++ if not os.path.exists("%s/command-not-found/options.json" % home): ++ try: ++ os.mkdir("%s/command-not-found/" % home) ++ except OSError: ++ # Folder exists ++ pass ++ options = open("%s/command-not-found/options.json" % home, "w") ++ options.write(default_options) ++ options.close() ++ + def cnf(command): + logger.debug("Entered CNF: %s", command) + db = get_db() +@@ -131,6 +152,7 @@ if __name__ == '__main__': + sys.exit() + logging.basicConfig(level=logging.DEBUG) + command = sys.argv[1] ++ write_default_opt() + options = get_options() + if 'meta-setup' not in get_db(): + logger.debug("Running for first time") +-- +2.15.0 +