I'm trying to include WSO2 WSF/C custom package into a buildroot cross-compile ARM project. Here is the wsfc.mk file so far:
################################################################################
#
# WSO2 WSF/C
#
################################################################################
WSFC_VERSION = 2.0.0
WSFC_SOURCE_BASENAME = wso2-wsf-c-src-$(WSFC_VERSION)
WSFC_SOURCE = $(WSFC_SOURCE_BASENAME).zip
WSFC_SITE = $(BR2_EXTERNAL)/package/wsfc/
WSFC_SITE_METHOD = file
WSFC_PREFIX = /usr/local/wso/wsf_c/
WSFC_CONF_OPTS = --prefix=$(WSFC_PREFIX) --exec-prefix=$(WSFC_PREFIX) \
--enable-rampart=no --enable-sandesha=no --enable-savan=no
define WSFC_EXTRACT_CMDS
unzip $(DL_DIR)/$(WSFC_SOURCE) -d $(#D)
mv $(#D)/$(WSFC_SOURCE_BASENAME)/* $(#D)
rmdir $(#D)/$(WSFC_SOURCE_BASENAME)
endef
$(eval $(autotools-package))
The problem,
When WSFC_PREFIX = /usr/local/wso/wsf_c/, it tries to install samples in the host, hence the Permission denied
[... lot of buildroot log output then:]
/usr/bin/make install-data-hook
make[5]: Entering directory `/home/masteruser/Downloads/buildroot-2015.05/output/build/wsfc-2.0.0/axis2c'
mkdir -p /usr/local/wso/wsf_c/samples/src/axis2c
mkdir: cannot create directory ‘/usr/local/wso’: Permission denied
make[5]: *** [install-data-hook] Error 1
make[5]: Leaving directory `/home/masteruser/Downloads/buildroot-2015.05/output/build/wsfc-2.0.0/axis2c'
make[4]: *** [install-data-am] Error 2
make[4]: Leaving directory `/home/masteruser/Downloads/buildroot-2015.05/output/build/wsfc-2.0.0/axis2c'
make[3]: *** [install-am] Error 2
make[3]: Leaving directory `/home/masteruser/Downloads/buildroot-2015.05/output/build/wsfc-2.0.0/axis2c'
make[2]: *** [install-recursive] Error 1
make[2]: Leaving directory `/home/masteruser/Downloads/buildroot-2015.05/output/build/wsfc-2.0.0/axis2c'
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory `/home/masteruser/Downloads/buildroot-2015.05/output/build/wsfc-2.0.0'
make: *** [/home/masteruser/Downloads/buildroot-2015.05/output/build/wsfc-2.0.0/.stamp_target_installed] Error 2
When WSFC_PREFIX = $(TARGET_DIR)/usr/local/wso/wsf_c/, there is no error, but it duplicates the prefix, installing several files in the wrong place (..home../target/home/...)
[... lot of buildroot log output then:]
test -z "/home/masteruser/Downloads/buildroot-2015.05/output/target/usr/local/wso/wsf_c" || /bin/mkdir -p "/home/masteruser/Downloads/buildroot-2015.05/output/target/home/masteruser/Downloads/buildroot-2015.05/output/target/usr/local/wso/wsf_c"
test -z "/home/masteruser/Downloads/buildroot-2015.05/output/target/usr/local/wso/wsf_c/docs" || /bin/mkdir -p "/home/masteruser/Downloads/buildroot-2015.05/output/target/home/masteruser/Downloads/buildroot-2015.05/output/target/usr/local/wso/wsf_c/docs"
/usr/bin/install -c -m 644 'config/axis2.xml' '/home/masteruser/Downloads/buildroot-2015.05/output/target/home/masteruser/Downloads/buildroot-2015.05/output/target/usr/local/wso/wsf_c/axis2.xml'
/usr/bin/install -c -m 644 'README' '/home/masteruser/Downloads/buildroot-2015.05/output/target/home/masteruser/Downloads/buildroot-2015.05/output/target/usr/local/wso/wsf_c/README'
/usr/bin/install -c -m 644 'INSTALL' '/home/masteruser/Downloads/buildroot-2015.05/output/target/home/masteruser/Downloads/buildroot-2015.05/output/target/usr/local/wso/wsf_c/INSTALL'
/usr/bin/install -c -m 644 'COPYING' '/home/masteruser/Downloads/buildroot-2015.05/output/target/home/masteruser/Downloads/buildroot-2015.05/output/target/usr/local/wso/wsf_c/COPYING'
/usr/bin/install -c -m 644 'NEWS' '/home/masteruser/Downloads/buildroot-2015.05/output/target/home/masteruser/Downloads/buildroot-2015.05/output/target/usr/local/wso/wsf_c/NEWS'
/usr/bin/install -c -m 644 'CREDITS' '/home/masteruser/Downloads/buildroot-2015.05/output/target/home/masteruser/Downloads/buildroot-2015.05/output/target/usr/local/wso/wsf_c/CREDITS'
/usr/bin/install -c -m 644 'NOTICE' '/home/masteruser/Downloads/buildroot-2015.05/output/target/home/masteruser/Downloads/buildroot-2015.05/output/target/usr/local/wso/wsf_c/NOTICE'
[... lot of buildroot log output ]
I think it would require a patch to be fixed, but I'm not familiar with autotools, I don't know where should I patch and how buildroot appends the prefix during make in order to avoid such behavior.
The WSF/C source is not properly using autotools. There are some manually written installation hooks, but they don't include the $(DESTDIR)/ prefix in the target location. So these things are installed in the host system rather than in the output/target directory.
The simplest solution is not to install the samples.
Here are the files and the patch to fix the source and integrate it to buildroot.
wsfc.mk
################################################################################
#
# WSO2 WSF/C
#
################################################################################
WSFC_VERSION = 2.0.0
WSFC_SOURCE_BASENAME = wso2-wsf-c-src-$(WSFC_VERSION)
WSFC_SOURCE = $(WSFC_SOURCE_BASENAME).zip
WSFC_SITE = $(BR2_EXTERNAL)/package/wsfc/
WSFC_SITE_METHOD = file
WSFC_PREFIX = /usr/local/wso/wsf_c/
WSFC_CONF_OPTS = --prefix=$(WSFC_PREFIX) --exec-prefix=$(WSFC_PREFIX) --enable-rampart=no --enable-sandesha=no --enable-savan=no
define WSFC_EXTRACT_CMDS
unzip $(DL_DIR)/$(WSFC_SOURCE) -d $(#D)
mv $(#D)/$(WSFC_SOURCE_BASENAME)/* $(#D)
rmdir $(#D)/$(WSFC_SOURCE_BASENAME)
endef
$(eval $(autotools-package))
0001-samples-destdir-fix.patch
diff -ENwbur wso2-wsf-c-src-2.0.0.orig/axis2c/Makefile.am wso2-wsf-c-src-2.0.0/axis2c/Makefile.am
--- wso2-wsf-c-src-2.0.0.orig/axis2c/Makefile.am 2015-08-21 16:33:24.807351795 -0300
+++ wso2-wsf-c-src-2.0.0/axis2c/Makefile.am 2015-08-21 16:37:58.994193027 -0300
## -30,6 +30,8 ##
rm -rf axis2c-bin-${PACKAGE_VERSION}-linux
install-data-hook:
- mkdir -p $(samplesdir)/src/axis2c
- cp -rf samples/* $(samplesdir)/src/axis2c
+ #:
+
+ #mkdir -p $(samplesdir)/src/axis2c
+ #cp -rf samples/* $(samplesdir)/src/axis2c
diff -ENwbur wso2-wsf-c-src-2.0.0.orig/axis2c/Makefile.in wso2-wsf-c-src-2.0.0/axis2c/Makefile.in
--- wso2-wsf-c-src-2.0.0.orig/axis2c/Makefile.in 2015-08-21 16:33:25.191159781 -0300
+++ wso2-wsf-c-src-2.0.0/axis2c/Makefile.in 2015-08-21 16:38:25.178193336 -0300
## -823,8 +823,10 ##
rm -rf axis2c-bin-${PACKAGE_VERSION}-linux
install-data-hook:
- mkdir -p $(samplesdir)/src/axis2c
- cp -rf samples/* $(samplesdir)/src/axis2c
+ #:
+
+ #mkdir -p $(samplesdir)/src/axis2c
+ #cp -rf samples/* $(samplesdir)/src/axis2c
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff -ENwbur wso2-wsf-c-src-2.0.0.orig/Makefile.am wso2-wsf-c-src-2.0.0/Makefile.am
--- wso2-wsf-c-src-2.0.0.orig/Makefile.am 2015-08-21 16:33:24.775367794 -0300
+++ wso2-wsf-c-src-2.0.0/Makefile.am 2015-08-21 16:40:42.506194955 -0300
## -10,24 +10,28 ##
sh dist_hook.sh
samples:
- sh build_samples.sh $(prefix)
- mkdir -p $(samplesdir)/src/wsf_c
- cp -rf examples/* $(samplesdir)/src/wsf_c
- cd $(samplesdir)
- rm -rf `find $(samplesdir)/ -type d -name *.svn`
- rm -rf `find $(samplesdir)/ -type d -name *.libs`
- rm -rf `find $(samplesdir)/ -type d -name *.deps`
- rm -rf `find $(samplesdir)/ -type f -name Makefile`
- rm -rf `find $(samplesdir)/ -type d -name autom4te.cache`
- cp config/axis2.xml $(prefix)
+ #:
+
+ #sh build_samples.sh $(prefix)
+ #mkdir -p $(samplesdir)/src/wsf_c
+ #cp -rf examples/* $(samplesdir)/src/wsf_c
+ #cd $(samplesdir)
+ #rm -rf `find $(samplesdir)/ -type d -name *.svn`
+ #rm -rf `find $(samplesdir)/ -type d -name *.libs`
+ #rm -rf `find $(samplesdir)/ -type d -name *.deps`
+ #rm -rf `find $(samplesdir)/ -type f -name Makefile`
+ #rm -rf `find $(samplesdir)/ -type d -name autom4te.cache`
+ #cp config/axis2.xml $(prefix)
install-data-hook:
- cp -rf docs/* $(docsdir)
- rm -rf `find $(samplesdir)/ -type d -name *.svn`
- rm -rf `find $(samplesdir)/ -type d -name *.libs`
- rm -rf `find $(samplesdir)/ -type d -name *.deps`
- rm -rf `find $(samplesdir)/ -type f -name Makefile`
- rm -rf `find $(samplesdir)/ -type d -name autom4te.cache`
+ #:
+
+ #cp -rf docs/* $(docsdir)
+ #rm -rf `find $(samplesdir)/ -type d -name *.svn`
+ #rm -rf `find $(samplesdir)/ -type d -name *.libs`
+ #rm -rf `find $(samplesdir)/ -type d -name *.deps`
+ #rm -rf `find $(samplesdir)/ -type f -name Makefile`
+ #rm -rf `find $(samplesdir)/ -type d -name autom4te.cache`
EXTRA_DIST=build_samples.sh config build.bat clean.bat docs CREDITS NOTICE examples LICENSE configure.in link_samples.sh link.sh build/build_optional.bat build/optional.mk build/init.bat build/versions.in test build/codegen
diff -ENwbur wso2-wsf-c-src-2.0.0.orig/Makefile.in wso2-wsf-c-src-2.0.0/Makefile.in
--- wso2-wsf-c-src-2.0.0.orig/Makefile.in 2015-08-21 16:33:26.042733811 -0300
+++ wso2-wsf-c-src-2.0.0/Makefile.in 2015-08-21 16:41:35.322195578 -0300
## -714,24 +714,28 ##
sh dist_hook.sh
samples:
- sh build_samples.sh $(prefix)
- mkdir -p $(samplesdir)/src/wsf_c
- cp -rf examples/* $(samplesdir)/src/wsf_c
- cd $(samplesdir)
- rm -rf `find $(samplesdir)/ -type d -name *.svn`
- rm -rf `find $(samplesdir)/ -type d -name *.libs`
- rm -rf `find $(samplesdir)/ -type d -name *.deps`
- rm -rf `find $(samplesdir)/ -type f -name Makefile`
- rm -rf `find $(samplesdir)/ -type d -name autom4te.cache`
- cp config/axis2.xml $(prefix)
+ #:
+
+ #sh build_samples.sh $(prefix)
+ #mkdir -p $(samplesdir)/src/wsf_c
+ #cp -rf examples/* $(samplesdir)/src/wsf_c
+ #cd $(samplesdir)
+ #rm -rf `find $(samplesdir)/ -type d -name *.svn`
+ #rm -rf `find $(samplesdir)/ -type d -name *.libs`
+ #rm -rf `find $(samplesdir)/ -type d -name *.deps`
+ #rm -rf `find $(samplesdir)/ -type f -name Makefile`
+ #rm -rf `find $(samplesdir)/ -type d -name autom4te.cache`
+ #cp config/axis2.xml $(prefix)
install-data-hook:
- cp -rf docs/* $(docsdir)
- rm -rf `find $(samplesdir)/ -type d -name *.svn`
- rm -rf `find $(samplesdir)/ -type d -name *.libs`
- rm -rf `find $(samplesdir)/ -type d -name *.deps`
- rm -rf `find $(samplesdir)/ -type f -name Makefile`
- rm -rf `find $(samplesdir)/ -type d -name autom4te.cache`
+ #:
+
+ #cp -rf docs/* $(docsdir)
+ #rm -rf `find $(samplesdir)/ -type d -name *.svn`
+ #rm -rf `find $(samplesdir)/ -type d -name *.libs`
+ #rm -rf `find $(samplesdir)/ -type d -name *.deps`
+ #rm -rf `find $(samplesdir)/ -type f -name Makefile`
+ #rm -rf `find $(samplesdir)/ -type d -name autom4te.cache`
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
Related
I'm trying to loop in the SOURCE directory, tar each subfolder to DEST directory without success.
I've tested a few variations, but none is acceptable, so I'm looking for some help.
These are the closest ones.
Thanks
Structure:
/srv/source
sub1
sub2
sub3
I would like to have a tar for each sub as this:
/srv/dest
sub1.{DATE}.tar.gz
sub2.{DATE}.tar.gz
sub3.{DATE}.tar.gz
These where the tests I made:
#!/bin/bash
DATE=$(date '+%Y.%m.%d')
SOURCE=/srv/source
DEST=/srv/dest
find ${SOURCE} -maxdepth 1 -mindepth 1 -type d -printf '%f\n' -execdir tar zcvf ${DEST}/{}-${DATE}.tar.gz -C ${DEST}/{} . \;
#!/bin/bash
DATE=$(date '+%Y.%m.%d')
SOURCE=/srv/source
DEST=/srv/dest
for DIR in "$(find ${SOURCE} -maxdepth 1 -mindepth 1 -type d -printf '%f\n' | xargs -0)"
do
tar zcvf ${DEST}/${DIR}-${DATE}.tar.gz -C ${SOURCE}/${DIR} .
done
EDIT:
This is working
for DIR in ${SOURCE}/*
do
[ -d "${DIR}" ] && tar zcf ${DEST}/$(basename "${DIR}")-${DATE}.tar.gz -C ${SOURCE}/$(basename "${DIR}") .
done
How to run a Bash script when starting Windows 10?
I can only find soulations for ubuntu.
Thanks.
#!/bin/bash
# Desktop PATH
Desktop=/c/Users/118883/Desktop
# folder with the script
executeFolder=Clean-up-folder-structure
# mainfolder
sortingFolder=sorting
# inner folders
docFolder=1.word_docs
excelFolder=2.excel_docs
imageFolder=3.images
cd $Desktop
# moves all folders from desktop to a sorting folder
function moveMyFiles(){
find * -mindepth 0 -maxdepth 0 -not -name $sortingFolder -not -name
$executeFolder -exec mv -v -t $sortingFolder {} +
}
# Sort al the .docx files
function sortDocs(){
cd $sortingFolder
if [ -d $docFolder ]
then
find *.docx -mindepth 0 -maxdepth 0 -exec mv -v -t $docFolder {} +
else
mkdir $docFolder
find *.docx -mindepth 0 -maxdepth 0 -exec mv -v -t $docFolder {} +
fi
}
function sortExcel(){
cd $sortingFolder
if [ -d $excelFolder ]
then
find *.xlsx -mindepth 0 -maxdepth 0 -exec mv -v -t $excelFolder {} +
else
mkdir $excelFolder
find *.xlsx -mindepth 0 -maxdepth 0 -exec mv -v -t $excelFolder {} +
fi
}
function sortImages(){
cd $sortingFolder
if [ -d $imageFolder ]
then
find *.PNG -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
find *.JPEG -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
find *.jpeg -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
find *.jpg -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
find *.GIF -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
else
mkdir $imageFolder
find *.PNG -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
find *.JPEG -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
find *.jpeg -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
find *.jpg -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
find *.GIF -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
fi
}
#main execute
if [ -d $sortingFolder ]
then
cd $Desktop
moveMyFiles
sortDocs
sortExcel
sortImages
else
# zo niet maak een folder
cd $Desktop
mkdir $sortingFolder
moveMyFiles
sortDocs
sortExcel
sortImages
fi
When running in Powershell error appear.
syntax errors and parse errors.
like:
At line:1 char:3
+ if [ -d $sortingFolder ]
+ ~
Missing '(' after 'if' in if statement.
At line:1 char:5
+ if [ -d $sortingFolder ]
+ ~
Missing type name after '['.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingOpenParenthesisInIfStatement
I'd suggest the same as gazzo, but not with powershell, rather with a virtual shell such as git bash. If possible of course.
Due to how our environments set up at work, i use bash scripts through git bash to download git repositories, setup projects dynamically etc. You could set up windows to run git bash exe and pass in your bash script's path to run it.
maybe a bit complicated but it works: you can run the sh script in powershell using
sh yourShScript
you can put this command in a powershell script file (e.g. yourScript.ps1), then put this powershell script in a cmd script that you can then run at startup. Write this in the cmd file:
PowerShell pathToYourScript\yourscript.ps1
in powershell use:
wsl sh
this starts up the wsl subsystem, not just powershell
I am using some shell script coding , here it is
DBHOSTNAME=********
DBUSERNAME=*****
DBPASSWORD=******
DBNAME=******
BACKUPFOLDER=$HOME/*******
DELETEFILES=Y
DAILYBACKUP=Y
NUMDAILYBACKUPS=2
WEEKLYBACKUP=Y
NUMWEEKLYBACKUPS=2
MONTHLYBACKUP=Y
NUMMONTHLYBACKUPS=2
TODATE=$(date +%d)
TOMORROW=`date +%d -d "1 day"`
TODAY=$(date +%a)
MONTH=$(date +%B)
WEEK=$(date +%U)
if [ $TODATE -gt $TOMORROW ] && [ "$MONTHLYBACKUP" == "Y" ]
then
/usr/bin/mysqldump -h $DBHOSTNAME -u $DBUSERNAME -p$DBPASSWORD $DBNAME | gzip > $BACKUPFOLDER/$DBNAME'_'`date '+%m-%d-%Y'`'_'$MONTH.sql.gz
else
if [ "$TODAY" == "Sat" ] && [ "$WEEKLYBACKUP" == "Y" ]
then
/usr/bin/mysqldump -h $DBHOSTNAME -u $DBUSERNAME -p$DBPASSWORD $DBNAME | gzip > $BACKUPFOLDER/$DBNAME'_'`date '+%m-%d-%Y'`'_'Week$WEEK.sql.gz
else
if [ "$DAILYBACKUP" == "Y" ]
then
/usr/bin/mysqldump -h $DBHOSTNAME -u $DBUSERNAME -p$DBPASSWORD $DBNAME | gzip > $BACKUPFOLDER/$DBNAME'_'`date '+%m-%d-%Y'`'_'$TODAY.sql.gz
fi
fi
fi
if [ $DELETEFILES == Y ]
then
NUMWEEKLY=$[$NUMWEEKLYBACKUPS*7]
NUMMONTHLY=$[$NUMMONTHLYBACKUPS*31]
find $BACKUPFOLDER/*Sun.sql.gz -type f -mtime +$NUMDAILYBACKUPS -delete 2> /dev/null
find $BACKUPFOLDER/*Mon.sql.gz -type f -mtime +$NUMDAILYBACKUPS -delete 2> /dev/null
find $BACKUPFOLDER/*Tue.sql.gz -type f -mtime +$NUMDAILYBACKUPS -delete 2> /dev/null
find $BACKUPFOLDER/*Wed.sql.gz -type f -mtime +$NUMDAILYBACKUPS -delete 2> /dev/null
find $BACKUPFOLDER/*Thu.sql.gz -type f -mtime +$NUMDAILYBACKUPS -delete 2> /dev/null
find $BACKUPFOLDER/*Fri.sql.gz -type f -mtime +$NUMDAILYBACKUPS -delete 2> /dev/null
find $BACKUPFOLDER/*Sat.sql.gz -type f -mtime +$NUMDAILYBACKUPS -delete 2> /dev/null
find $BACKUPFOLDER/*Week*.sql.gz -type f -mtime +$NUMWEEKLY -delete 2> /dev/null
find $BACKUPFOLDER/*January.sql.gz -type f -mtime +$NUMMONTHLY -delete 2> /dev/null
find $BACKUPFOLDER/*February.sql.gz -type f -mtime +$NUMMONTHLY -delete 2> /dev/null
find $BACKUPFOLDER/*March.sql.gz -type f -mtime +$NUMMONTHLY -delete 2> /dev/null
find $BACKUPFOLDER/*April.sql.gz -type f -mtime +$NUMMONTHLY -delete 2> /dev/null
find $BACKUPFOLDER/*May.sql.gz -type f -mtime +$NUMMONTHLY -delete 2> /dev/null
find $BACKUPFOLDER/*June.sql.gz -type f -mtime +$NUMMONTHLY -delete 2> /dev/null
find $BACKUPFOLDER/*July.sql.gz -type f -mtime +$NUMMONTHLY -delete 2> /dev/null
find $BACKUPFOLDER/*August.sql.gz -type f -mtime +$NUMMONTHLY -delete 2> /dev/null
find $BACKUPFOLDER/*September.sql.gz -type f -mtime +$NUMMONTHLY -delete 2> /dev/null
find $BACKUPFOLDER/*October.sql.gz -type f -mtime +$NUMMONTHLY -delete 2> /dev/null
find $BACKUPFOLDER/*November.sql.gz -type f -mtime +$NUMMONTHLY -delete 2> /dev/null
find $BACKUPFOLDER/*December.sql.gz -type f -mtime +$NUMMONTHLY -delete 2> /dev/null
fi
it is working fine, but doesnt delete old files, i taken this from following address http://www.htpcbeginner.com/automatic-mysql-database-backup-on-godaddy/3/
what i need is backup of 3 days
like
Today files in folder
03/01/2017
04/01/2017
05/01/2017
and tommorow it should be
04/01/2017
05/01/2017
06/01/2017
it should delete 3jan file
Besides what the commenters have said, I think a key issue is your find command. You have, for one example:
find $BACKUPFOLDER/*Sun.sql.gz -type f -mtime +$NUMDAILYBACKUPS -delete 2> /dev/null
But that should be
find "$BACKUPFOLDER" -name '*Sun.sql.gz' -type f -mtime "+$NUMDAILYBACKUPS" -delete
When using find, you list the paths ("$BACKUPFOLDER") and the filenames (-name '*Sun.sql.gz') separately. You also single-quote the filenames to prevent the shell from expanding them.
While debugging, don't use 2> /dev/null. That discards error messages you might otherwise find helpful in solving your problem :) .
I want to "join" these two tasks:
for dir in /blabla/bleble/*; do (cd "$dir" && mkdir -p Folder1/Folder1a && mkdir -p Folder2); done
and
find -amin -10
How can I do this?
I've tried this, but it doesn't work:
find -amin -2 -exec sh -c '
for dir in /blabla/bleble/*; do (cd "$dir" && mkdir -p Folder1/Folder1a && mkdir -p Folder2);
done' sh {} +
Something like this is might do:
find /a/b/ -mindepth 1 -maxdepth 1 -type d -amin -2 \
-exec sh -c 'for f; do mkdir -p -- "$f/Folder1/Folder1a" "$f/Folder2; done"' "" {} +
Breakdown:
-mindepth 1 -maxdepth 1 will limit result to current directory only.
-type d makes sure you only list directories
-exec foo "" {} + will execute foo with matches as arguments:
foo "" "/a/b/c" "/a/b/john" "a/b/doe"
for f will iterate over all positional arguments ($1, $2, ...)
for f; do
mkdir -p -- "$f/Folder1/Folder1a" "$f/Folder2"
done
Running sh -c 'code' arg1 arg2 will set $0 to arg1, and $1 to arg2, therefore the empty argument: foo "" {} +:
% sh -c 'echo $0' john
john
Assuming there aren't so many folders in /blabla/bleble that you overflow the command line, you can use find to search the target directory. -prune prevents recursing into the directories.
find /blabla/bleble/* -prune -type d -amin -10 -exec mkdir -p {}/Folder1/Folder1a {}/Folder2 \;
If you are using GNU find or another version that supports them, use -mindepth and -maxdepth instead to find the top-level subdirectories, no matter how many there are.
find /blabla/bleble -maxdepth 1 -mindepth 1 -type d -amin -10 -exec mkdir -p {}/Folder1/Folder1a {}/Folder2 \;
I am getting an error during compilation of a source code. I searched it but fail to find name of package which fix the problem.
Error
ls: cannot access /lib/modules/3.5.0-17-generic/source: No such file or directory
source code of make file
# Makefile for bcm_wimax module
# Customized for ZTE AX226
# Makefile recreated be Minhazul Haq Shawon
KERNEL_VER := $(shell uname -r)
KDIR := /lib/modules/$(KERNEL_VER)/build
KSRC := /lib/modules/$(KERNEL_VER)/source
INSTALL_DIR := /lib/modules/$(KERNEL_VER)/kernel/drivers/staging/bcm/
TARGET_DRV := bcm_wimax
EXTRAFLAGS := -Wall O=$(KDIR)
PWD:= $(shell pwd)
obj-m = $(TARGET_DRV).o
$(TARGET_DRV)-objs :=InterfaceDld.o InterfaceIdleMode.o InterfaceInit.o InterfaceRx.o \
InterfaceIsr.o InterfaceMisc.o InterfaceTx.o \
CmHost.o IPv6Protocol.o Qos.o Transmit.o\
Bcmnet.o DDRInit.o HandleControlPacket.o\
LeakyBucket.o Misc.o sort.o Bcmchar.o hostmibs.o PHSModule.o\
led_control.o nvm.o vendorspecificextn.o
default:
$(MAKE) $(EXTRAFLAGS) -C $(KSRC) SUBDIRS=$(PWD) modules
rm -f *.o *.mod.* .*.cmd
install:
cp $(TARGET_DRV).ko $(INSTALL_DIR)
clean:
find . -name \*.o -exec rm -rf '{}' ';'
find . -name .\*.o.cmd -exec rm -rf '{}' ';'
find . -name \*.*~ -exec rm -rf '{}' ';'
find . -name \*.*.bak -exec rm -rf '{}' ';'
rm -f *.ko *.o *.mod.* .*.cmd
rm -fr .tmp_versions
rm -rf Module.symvers
You have to compile kernel source first.