I'm new to using Makefile(s) and I'd like to create a command make package <PACKAGE_NAME>.
And I'd like it to run the following:
mkdir $PACKAGE_NAME
cd $PACKAGE_NAME
npm init -y
mkdir src
mkdir lib
mkdir test
I'm a little confused if I should put this in a shell script or If I can just have this directly in the make file itself (which is preferable), and I also am unsure how to have arguments in a Makefile.
This will do it:
package:
mkdir $(PACKAGE_NAME)
cd $(PACKAGE_NAME) ; npm init -y ; mkdir src lib test
The whitespace at the beginning of line 2 is a TAB, not four spaces. Likewise line 3.
Related
I'm trying to use a program that uses Linux versions of other programs.
I ran this in bash:
c3dpath=$( command -v c3d )
if [[ -z "${c3dpath}" ]]; then
echo "Command c3d was not found. Downloading and installing software to ${SCRIPTPATH}/depends/c3d. Path will be added to PATH environment variable."
mkdir -p "${SCRIPTPATH}/depends/c3d/"
wget https://downloads.sourceforge.net/project/c3d/c3d/Nightly/c3d-nightly-Linux-x86_64.tar.gz && \
tar -xzvf c3d-nightly-Linux-x86_64.tar.gz && mv c3d-1.1.0-Linux-x86_64/* "${SCRIPTPATH}/depends/c3d/" && \
rm c3d-nightly-Linux-x86_64.tar.gz
export PATH="${SCRIPTPATH}/depends/c3d/c3d-1.1.0-Linux-x86_64/bin/:$PATH"
fi
But it downloads the linux version of the program files into my directory -- yielding the error:
{..omitted}/HippMapp3r/depends/c3d/bin/c3d: cannot execute binary file
Return Code: 126
I understand in order for this to work on my computer, I need to use the version for Mac OS, however, I stuck on how one might go about "unarchiving" the files contained within a .dmg file so I can access c3d in bin.
I edited it to this, but I understand I cannot use the tar -xzvf command in this context -- is there an equivalent to tar -xzvf to "unpack" dmg files?
c3dpath=$( command -v c3d )
if [[ -z "${c3dpath}" ]]; then
echo "Command c3d was not found. Downloading and installing software to ${SCRIPTPATH}/depends/c3d. Path will be added to PATH environment variable."
mkdir -p "${SCRIPTPATH}/depends/c3d/"
wget https://downloads.sourceforge.net/project/c3d/c3d/Nightly/c3d-nightly-MacOS-x86_64.dmg && \
tar -xzvf c3d-nightly-MacOS-x86_64.dmg * "${SCRIPTPATH}/depends/c3d/" && \
rm c3d-nightly-MacOS-x86_64.dmg
export PATH="${SCRIPTPATH}/depends/c3d/c3d-nightly-MacOS-x86_64/bin/:$PATH"
fi
Try using 7-zip. You can install it on a Mac with homebrew using:
brew install p7zip
Then run it with:
7z
Please see comment by #StefanSchmidt about a possible alternative package.
First you have to mount the DMG file.
command: hdiutil mount test.dmg
I have been trying to make a VCS in C++ but the build file is not running in my LINUX(Ubuntu).
It is prompting the above message.
my build file is as follows:
#!/bin/bash
sudo apt-get update
udo apt-get install openssl -y
sudo apt-get install libssl-dev -y
mkdir -p ~/imperium/bin
cp imperium.sh ~/imperium
cd ..
make
cd ~/imperium/bin || echo "error"
chmod +x main
cd ..
if grep -q "source $PWD/imperium.sh" "$PWD/../.bashrc" ; then
echo 'already installed bash source';
else
echo "source $PWD/imperium.sh" >> ~/.bashrc;
fi
my imperium.sh file is also as follows:
function imperium(){
DIR=$PWD
export dir=$DIR
cd ~/imperium/bin || echo "Error"
./main "$#"
cd "$DIR" || echo "Error"
}
I will be heavily obliged if any one can solve this problem of mine. After chmod I have been doing:
./build.sh but its prompting that build.sh file does not exists.
For me it seems you have a typo right in the 3rd row "udo" ->
"sudo".
Also, You should avoid using cd .. and use relative paths for
the commands.
I'd like to check my VERSION argument, if the regex ".*feature.*" finds the exact string in the version which contains a "feature" in it, to make a conditional docker image.
The dockerfile looks like this right now:
FROM docker.INSERTURL.com/fe/plattform-nginx:1.14.0-01
ARG ARTIFACTORY_USER
ARG ARTIFACTORY_PW
ARG VERSION
# Download sources from Repository
ADD https://${ARTIFACTORY_USER}:${ARTIFACTORY_PW}#INSERTURL.com/artifactory/api/npm/angular.npm/angular-frontend-app/-/angular-frontend-app-${VERSION}.tgz app.tar.gz
# Extract and move to nginx html folder
RUN tar -xzf app.tar.gz
RUN mv ./package/dist/angular-frontend-app/* /usr/share/nginx/html
# Start nginx via script, which replaces static urls with environment variables
ADD start.sh /usr/share/nginx/start.sh
RUN chmod +x /usr/share/nginx/start.sh
# Overwrite nginx.conf
ADD nginx.conf /etc/nginx/nginx.conf
# Fix permissions for runtime
RUN chmod 777 /var/log/nginx /usr/share/nginx/html
CMD /usr/share/nginx/start.sh
I'd like it to only download the sources from Artifactory, if the VERSION doesn't contains "feature" in it's name.
I imagine it'd look like this:
FROM docker.INSERTURL.com/fe/plattform-nginx:1.14.0-01
ARG ARTIFACTORY_USER
ARG ARTIFACTORY_PW
ARG VERSION
if [ "$VERSION" = ".*feature.*" ]; then
# Download sources from Repository
ADD https://${ARTIFACTORY_USER}:${ARTIFACTORY_PW}#INSERTURL.com/artifactory/api/npm/angular.npm/angular-frontend-app/-/angular-frontend-app-${VERSION}.tgz app.tar.gz
fi
# Extract and move to nginx html folder
RUN tar -xzf app.tar.gz
RUN mv ./package/dist/angular-frontend-app/* /usr/share/nginx/html
# Start nginx via script, which replaces static urls with environment variables
ADD start.sh /usr/share/nginx/start.sh
RUN chmod +x /usr/share/nginx/start.sh
# Overwrite nginx.conf
ADD nginx.conf /etc/nginx/nginx.conf
# Fix permissions for runtime
RUN chmod 777 /var/log/nginx /usr/share/nginx/html
CMD /usr/share/nginx/start.sh
Do you know, if it's possible to check Dockerfile ARGs and ENVs with regex?
There are no conditionals in Dockerfiles. You can run arbitrary shell code inside a single RUN step, but that's as close as you can get.
If your base image has an HTTP client like curl you could build a combined command:
RUN if [ $(expr "$VERSION" : '.*feature.*') -eq 0 ]; then \
curl -o app.tar.gz https://${ARTIFACTORY_USER}:${ARTIFACTORY_PW}#INSERTURL.com/artifactory/api/npm/angular.npm/angular-frontend-app/-/angular-frontend-app-${VERSION}.tgz \
&& tar -xzf app.tar.gz \
&& mv ./package/dist/angular-frontend-app/* /usr/share/nginx/html \
&& rm -r app.tar.gz package \
; fi
(The expr invocation tries to match $VERSION against that regular expression, and absent any \(...\) match groups, returns the number of characters that matched; that is zero if the regexp does not match.)
You can also consider using multiple Dockerfiles for the different variants, or having an intermediate image with this frontend app installed and then dynamically selecting the FROM line for your final image. Also remember that these credentials will be visible in cleartext in the image's docker history to anyone who eventually gets the built image.
You can do your if + curl in RUN command this should work
I have a list of packages installed on my Ubuntu 16.04. I have a bash script which tries to download their sources one by one in the appropriate directories (created). I am getting an error:
Reading package lists...
E: Unable to find a source package for xxxx
~/source
~/sourcexxx
My bash script looks like this:
#!/bin/bash
while read package
do
#cd /mnt
mkdir $package
pushd $package
apt-get -d -q source $package
popd
done < ins.txt
I don't want to update any system files.
apt-get -d -q source xxx works on its own, but not in the script above. What could be the reason?
A part of my ins.txt:
adduser
adium-theme-ubuntu
adwaita-icon-theme
alacarte
alsa-base
alsa-utils
amd64-microcode
anacron
apg
app-install-data
app-install-data-partner
apparmor
apparmor-easyprof
When I do individually for eg apt-get -d -q source adduser , it works
Using your list, this seems to work fine for me (on Ubuntu 16.04) after removing the dpkg-query -f | part :
#!/bin/bash
while read package
do
echo "Package $package"
mkdir -v $package
pushd $package
apt-get -d -q source $package
popd
done < ins.txt
Maybe some packages don't have a source, or your ins.txt file contains invalid packages.
But that question would sure have been better posted on Ask Ubuntu.
Im trying to automate some dependency installing from an sh script, however, I feel that not all commands are getting through.
Here is an example:
#!/bin/sh
cd /Downloads
sudo wget https://github.com/tpaviot/oce/archive/OCE-0.16.1.tar.gz
sudo tar -xvf OCE-0.16.1.tar.gz
cd oce-OCE-0.16.1/
sudo mkdir build
cd build
sudo cmake ../
sudo make
sudo make install/strip
Is this valid in a .sh script?