Mozilla JetPack Invalid Filename - firefox-addon-sdk

I'm trying to create simple Mozilla add-on which is using external JS file;
Folders & Files
/var/www/html/add-ons/hello
/var/www/html/add-ons/hello/index.js
/var/www/html/add-ons/hello/package.json
/var/www/html/add-ons/hello/script/data/test.js
/var/www/html/add-ons/hello/index.js
// Import the page-mod API
var pageMod = require("sdk/page-mod");
// Create a page-mod
pageMod.PageMod({
include : "*",
contentScriptFile : "./test.js",
contentScript: 'window.alert("loaded");'
});
/var/www/html/add-ons/hello/package.json
{
"title": "My Jetpack Addon",
"name": "test",
"version": "0.0.1",
"description": "A basic add-on",
"main": "index.js",
"author": "",
"engines": {
"firefox": ">=38.0a1",
"fennec": ">=38.0a1"
},
"license": "MIT",
"keywords": [
"jetpack"
]
}
/var/www/html/add-ons/hello/script/data/test.js
alert("Hello World");
Commands I Run to Test
cd /var/www/html/add-ons/hello
jpm init (actually package.json file was created by this command)
jpm run -b /usr/bin/firefox (I use Ubuntu so I run it this way)
I test it live and I get loaded alert however I get following error;
console.error: script:
Error opening input stream (invalid filename?): resource://script/data/test.js
The folders and file are already exist within the root folder.
If this is the root;
/var/www/html/add-ons/hello shouldn't resource://script/data/test.js be referring to /var/www/html/add-ons/hello/script/data/test.js?
Where am I doing wrong?

Create your folder structure as below:
root folder: /var/www/html/add-ons/hello
place index.js, package.json within root folder.
move all the data that is packaged within your add-on to: /var/www/html/add-ons/hello/data
go to root folder - /var/www/html/add-ons/hello
run jpm run -b
this will create an xpi package, launch firefox.exe with temporary profile, install add-on.
ex: this is from win 7 x64 test project:
root directory: E:\Training\using_Angular
Directory of E:\Training\using_Angular
11/01/2015 08:26 AM <DIR> .
11/01/2015 08:26 AM <DIR> ..
09/29/2015 05:04 PM <DIR> data
09/29/2015 05:02 PM 548 index.js
08/12/2015 08:26 PM 221 package.json
Directory of E:\Training\using_Angular\data
09/29/2015 05:04 PM <DIR> .
09/29/2015 05:04 PM <DIR> ..
09/29/2015 05:04 PM <DIR> images
08/12/2015 08:26 PM 446 lang.json
09/29/2015 05:04 PM <DIR> lib
09/29/2015 05:04 PM <DIR> scripts
09/29/2015 05:04 PM <DIR> styles
09/29/2015 05:04 PM <DIR> html
Directory of E:\Training\using_Angular\data\html
08/12/2015 08:26 PM 446 pagescript.html
During run, the 'resource://' folder refers to contents packaged in your add-on.
for ex: resource://caaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/data/html/pagescript.html

Related

Bitbake build of simple source file not generating object file unless I set the -f (forced) flag option

Let me just say that I am new to Yocto. I have been able to create recipes, packages, images etc. however I am encountering the following issue. Using online references of which there are many, I have tried to create and build a simple Yocto 'helloworld' recipe using bitbake, which has the following structure:
├── conf
│ └── layer.conf
├── COPYING.MIT
├── README
└── recipes-example
├── example
│ └── example_0.1.bb
└── helloworld
├── files
│ └── hellopeterworld.c
└── helloworld_0.1.bb
The content of the hellopeterworld.c source file is as follows:
#include <stdio.h>
int main() {
printf("Hello, C Programming World! This is Peter!");
return 0;
}
The content of the helloworld_0.1.bb recipe is as follows:
SUMMARY = "bitbake-layers recipe"
DESCRIPTION = "A friendly program that prints Hello World!"
PRIORITY = "optional"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302
SRC_URI = file://hellopeterworld.c
S = "${WORKDIR}"
do_compile() {
${CC} ${CFLAGS} ${LDFLAGS} hellopeterworld.c -o hellopeterworld
}
do_install() {
install -d ${D}${bindir}
install -m 0755 hellopeterworld ${D}${bindir}
}
When attempting to build the recipe, say, the build output in the folder:
/tmp-glibc/work/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi/helloworld/0.1-r0/
is as follows:
-rw-r—r—1 pgroves pgroves 65 Feb 23 10:45 configure.sstate
drwxr-xr-x 3 pgroves pgroves 4096 Feb 23 10:20 deploy-debs
-rwxr-xr-x 1 pgroves pgroves 13512 Feb 23 10:45 hellopeterworld
-rw-rw-r—1 pgroves pgroves 101 Feb 23 10:15 hellopeterworld.c
drwxr-xr-x 3 pgroves pgroves 4096 Feb 23 10:45 image
drwxr-xr-x 2 pgroves pgroves 4096 Feb 23 10:45 patches
drwxrwxr-x 2 pgroves pgroves 4096 Feb 23 10:45 pseudo
drwxrwxr-x 5 pgroves pgroves 4096 Feb 23 10:45 recipe-sysroot
drwxrwxr-x 7 pgroves pgroves 4096 Feb 23 10:45 recipe-sysroot-native
drwxr-xr-x 2 pgroves pgroves 4096 Feb 23 10:45 source-date-epoch
drwxrwxr-x 2 pgroves pgroves 4096 Feb 23 10:55 sstate-install-package_write_deb
drwxrwxr-x 2 pgroves pgroves 20480 Feb 23 10:55 temp
The problem is that the ‘hellopeterworld’ object is not always being generated on subsequent 'bitbake helloworld' builds. Running a bitbake -c clean helloworld removes the contents of '0.1-r0' directory. The contents is restored only if I force the build using bitbake -f -c compile helloworld but this has a side effect with the following WARNING being raised:
'helloworld_0.1.bb:do_compile is tainted from a forced run'.
The funny thing is that if I edit the source file and add a deliberate bad syntax change, the rebuild detects the bad syntax and generates an error, as expected:
NOTE: Executing Tasks
ERROR: helloworld-0.1-r0 do_compile: Execution of
'<my_workspace>/build-
openstlinuxweston-stm32mp13-disco/tmp-glibc/work/cortexa7t2hf-neon-vfpv4-ostl-linux-
gnueabi/helloworld/0.1-r0/temp/run.do_compile.83597' failed with exit code 1:
hellopeterworld.c: In function 'main':
hellopeterworld.c:4:1: error: expected expression before '?' token
4 | ? printf("Hello, C Programming World! This is Peter!");
| ^
But if I then re-edit and fix the file and rebuild, the build completes but the the object file still isn’t being regenerated. I'm seeing the same thing with more complex examples.
Does anyone know the reason for this? Am I missing something here?
First of all, it is weird why it didn't fail because of a syntax error in variables SRC_URI and LIC_FILES_CHKSUM, they need to be in ".
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://hellopeterworld.c"
I have tested your recipe and the build restarts automatically when I change the hellopeterworld.c file in the recipe folder.
However, when you run do_clean it does not remove the sstate object of the recipe, it only removes the build output, so when you rerun again it will do nothing.
In order to clean the sstate object you need to run do_cleansstate.
Other than that, I do not see any issue with your recipe.

How to open a file in D drive through command prompt

Path of the folder: D:\Brian\adrk_v1_0 ; this folder has a file called 'filename' I wish to open the file, 'filename' using the command prompt.
I tried doing it, by writing the following
C:\Users\Anshuman
C:\Users\Anshuman> cd /d D:Brian\adrk_v1_0
D:\Brian\adrk_v1_0>
But when I try to open the 'makefile' this happens:
Directory of D:\Brian\adrk_v1_0
03-10-2021 11:13 <DIR> .
03-10-2021 11:13 <DIR> ..
13-12-2002 22:16 <DIR> Const
13-12-2002 22:16 <DIR> Energy
13-12-2002 22:16 <DIR> Form
13-12-2002 22:16 <DIR> GMICPP
13-12-2002 22:16 <DIR> Group
13-12-2002 22:16 <DIR> Input
14-12-2002 04:13 1,046 i_data.txt
11-12-2002 03:50 3,294 makefile
13-12-2002 22:16 <DIR> Master
13-12-2002 22:16 <DIR> Output
14-12-2002 04:20 223 o_rmv.dat
14-12-2002 04:20 3,718 o_sdf.dat
14-12-2002 04:20 223 o_sum.dat
14-12-2002 04:20 151 o_vac.dat
13-12-2002 22:16 <DIR> PD
14-12-2002 06:16 2,394 readme.txt
13-12-2002 22:16 <DIR> SDF
13-12-2002 22:16 <DIR> Vector
7 File(s) 11,049 bytes
13 Dir(s) 579,931,025,408 bytes free
D:\Brian\adrk_v1_0>makefile
'makefile' is not recognized as an internal or external command,
operable program or batch file.
I have tried changing the path to C: System 32 in the environment variable.
Looks like you should specify a texteditor, for Example:
notepad makefile

babel . --copy-files incorrectly copy node_modules

I have a project structure like the following:
-rw-r--r-- 1 chung2014 staff 2774 Nov 7 19:13 README.md
-rw-r--r-- 1 chung2014 staff 75 Nov 26 23:27 babel.config.js
drwxr-xr-x 588 chung2014 staff 18816 Nov 26 23:01 node_modules
-rw-r--r-- 1 chung2014 staff 781 Nov 26 22:25 nodemon.json
-rw-r--r-- 1 chung2014 staff 377691 Nov 26 22:08 package-lock.json
-rw-r--r-- 1 chung2014 staff 1551 Nov 26 23:27 package.json
-rw-r--r-- 1 chung2014 staff 2941 Nov 26 23:29 server.js
drwxr-xr-x 11 chung2014 staff 352 Nov 26 23:03 src
drwxr-xr-x 5 chung2014 staff 160 Nov 26 21:55 test
if I have all the source code inside the src directory, (e.g put server.js into src as well), I can have a script babel src --out-dir dist/ --copy-files in my package.json to compile the all the source code in src to dist/ directory.
However, due to some restriction, I cannot put my server.js inside src directory. So when I try to have a script babel . --out-dir dist/ --copy-files in my package.json, I let babel incorrectly copy files in node_modules to dist, which is not what I want.
So my question is how I can just only compile and copy files from both server.js and src/ to the destination directory dist/ without copying files in node_modules/?
$ cat babel.config.js
const presets = [
"#babel/preset-env",
];
module.exports = { presets };
New solution available
--no-copy-ignored is a new argument which allows the value of --ignore to be respected when copying files.
Usage
Example:
babel src -d dist --ignore 'src/**/*.spec.js' --copy-files --no-copy-ignored
The spec files are not going to be present on the output directory.
Source: https://github.com/babel/babel/issues/6226#issuecomment-590283042
The only way to do this would be to drop --copy-files and do --ignore node_modules, e.g.
babel . --out-dir dist/ --ignore node_modules
and you'll also want to ignore dist/ and babel.config.js and anything else in the root that might contain JS files.
babel . --out-dir dist/ --ignore node_modules,dist,babel.config.js
Realistically, the better option would be for server.js to just proxy through to dist instead through, so you could do
babel src --out-dir dist/
and move server.js to src/server.js. If having a server.js is 100% necessary, then have it do require("./dist/server");.
create a script like:
require('fs-extra').copy(
process.argv.slice(-2).shift(),
process.argv.slice(-2).pop(),
{ filter: (src,dist)=>{ return (src.match(/\.js|\.jsx|stories|test/)===null)} },
err => { if (err) return console.error (err); console.log ('Copy success!');
});
and append this to your build command
&& ./scripts/--copy-files src dist/commonjs
the gist:
https://gist.github.com/kmrk/bbc52a4d54b407398aff1695e5b710b7

Postgresql could not load library

after days of regular fight with postgis I stuck on this:
postgres=# CREATE EXTENSION postgis; ERROR: could not load library
"/usr/pgpro-9.6/lib/rtpostgis-2.4.so": libgdal.so.20: cannot open
shared object file: No such file or directory
and have no idea how to pass it, because library path is correct...
[combat#urpordfinal ~]$ ls -alt /usr/pgpro-9.6/lib/ total 13080
-rwxr-xr-x 1 root root 1440056 Apr 23 11:52 postgis_topology-2.4.so
drwxr-xr-x 5 root root 8192 Apr 23 11:52 .
-rwxr-xr-x 1 root root 1878728 Apr 23 11:52 rtpostgis-2.4.so
I'm running pgsql 9.6.8 and psotgis build from source
You have to make sure that libgdal.so.20 is on the shared library path.
Find out where the library is and add that directory to the shared library path.
On Linux, you would normally do that by adding the directory to /etc/ld.so.conf (or, better, to a PostGIS configuration file in /etc/ld.so.conf.d) and running ldconfig.

Can't open .py fileon cmd when working directory folder and path is set

Following is the output from the CMD. Receiving [Errno 2]. Notice a.py is in the folder with python.exe and i am able to launch python through py command.
C:\Users\x\AppData\Local\Programs\Python\Python36>a.py
C:\Users\x\AppData\Local\Programs\Python\Python36\python.exe: can't open file '#': [Errno 2] No such file or directory
C:\Users\x\AppData\Local\Programs\Python\Python36>dir
Volume in drive C has no label.
Volume Serial Number is x
Directory of C:\Users\x\AppData\Local\Programs\Python\Python36
04/02/2018 06:46 PM <DIR> .
04/02/2018 06:46 PM <DIR> ..
04/01/2018 07:30 PM 600 a.py
12/23/2016 08:09 AM 100,504 python.exe
12/23/2016 08:06 AM 52,888 python3.dll
12/23/2016 08:06 AM 3,555,992 python36.dll
12/23/2016 08:09 AM 98,968 pythonw.exe
12/23/2016 07:10 AM 8,434 README.txt
C:\Users\x\AppData\Local\Programs\Python\Python36>py
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
You have to run like this
python.exe a.py
or if path is set correctly,
python a.py